use async_trait for RawCall
All checks were successful
Build && Deploy / cargo build (push) Successful in 1m5s

This commit is contained in:
Akulij 2025-06-07 03:33:13 +05:00
parent 12af8f3653
commit 7e01186178

View File

@ -1,3 +1,4 @@
use async_trait::async_trait;
use mongodb::Database; use mongodb::Database;
use super::CallDB; use super::CallDB;
@ -14,6 +15,7 @@ pub enum RawCallError {
} }
pub type RawCallResult<T> = Result<T, RawCallError>; pub type RawCallResult<T> = Result<T, RawCallError>;
#[async_trait]
pub trait RawCall { pub trait RawCall {
async fn get_database(&mut self) -> Database; async fn get_database(&mut self) -> Database;
async fn find_one(&mut self, collection: &str, query: Value) -> RawCallResult<Option<Value>> { async fn find_one(&mut self, collection: &str, query: Value) -> RawCallResult<Option<Value>> {
@ -31,7 +33,8 @@ pub trait RawCall {
} }
} }
impl<T: CallDB> RawCall for T { #[async_trait]
impl<T: CallDB + Send> RawCall for T {
async fn get_database(&mut self) -> Database { async fn get_database(&mut self) -> Database {
CallDB::get_database(self).await CallDB::get_database(self).await
} }