pub trait MongoClientwhere
Self: Sized,{
const NAME: &'static str;
// Required methods
fn new<'life0, 'async_trait>(
connection_str: &'life0 str,
) -> Pin<Box<dyn Future<Output = MongoResult<Self>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn new_with_client<'async_trait>(
client: DbClient,
) -> Pin<Box<dyn Future<Output = MongoResult<Self>> + Send + 'async_trait>>
where Self: 'async_trait;
fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MongoResult<Document>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn database(&self) -> &Database;
fn client(&self) -> &DbClient;
}
Expand description
Async trait that is implemented automatically on the database handler struct by [mongo_db
].
Required Associated Constants§
Required Methods§
Sourcefn new<'life0, 'async_trait>(
connection_str: &'life0 str,
) -> Pin<Box<dyn Future<Output = MongoResult<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn new<'life0, 'async_trait>(
connection_str: &'life0 str,
) -> Pin<Box<dyn Future<Output = MongoResult<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initializer funtion of the database.
Creates a database DbClient
and calls new_with_client
then.
Sourcefn new_with_client<'async_trait>(
client: DbClient,
) -> Pin<Box<dyn Future<Output = MongoResult<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn new_with_client<'async_trait>(
client: DbClient,
) -> Pin<Box<dyn Future<Output = MongoResult<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
Initializer function that uses the given client.
Useful when interacting with multiple databases.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.