Trait MongoClient

Source
pub trait MongoClient
where 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§

Source

const NAME: &'static str

The database’s name.

Required Methods§

Source

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.

Source

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.

Source

fn ping<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = MongoResult<Document>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Method that sends a ping command to the database.

Source

fn database(&self) -> &Database

Returns a reference to the database object.

Source

fn client(&self) -> &DbClient

Returns a reference to the mongodb client object.

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.

Implementors§