Trait mongodb::ThreadedClient
[−]
[src]
pub trait ThreadedClient: Sync + Sized { fn connect(host: &str, port: u16) -> Result<Self>; fn connect_with_options(
host: &str,
port: u16,
_: ClientOptions
) -> Result<Self>; fn with_uri(uri: &str) -> Result<Self>; fn with_uri_and_options(uri: &str, options: ClientOptions) -> Result<Self>; fn with_config(
config: ConnectionString,
options: Option<ClientOptions>,
description: Option<TopologyDescription>
) -> Result<Self>; fn db(&self, db_name: &str) -> Database; fn db_with_prefs(
&self,
db_name: &str,
read_preference: Option<ReadPreference>,
write_concern: Option<WriteConcern>
) -> Database; fn acquire_stream(
&self,
read_pref: ReadPreference
) -> Result<(PooledStream, bool, bool)>; fn acquire_write_stream(&self) -> Result<PooledStream>; fn get_req_id(&self) -> i32; fn database_names(&self) -> Result<Vec<String>>; fn drop_database(&self, db_name: &str) -> Result<()>; fn is_master(&self) -> Result<bool>; fn add_start_hook(
&mut self,
hook: fn(_: Client, _: &CommandStarted)
) -> Result<()>; fn add_completion_hook(
&mut self,
hook: fn(_: Client, _: &CommandResult)
) -> Result<()>; }
Required Methods
fn connect(host: &str, port: u16) -> Result<Self>
Creates a new Client directly connected to a single MongoDB server.
fn connect_with_options(host: &str, port: u16, _: ClientOptions) -> Result<Self>
Creates a new Client directly connected to a single MongoDB server with options.
fn with_uri(uri: &str) -> Result<Self>
Creates a new Client connected to a complex topology, such as a replica set or sharded cluster.
fn with_uri_and_options(uri: &str, options: ClientOptions) -> Result<Self>
Creates a new Client connected to a complex topology, such as a replica set or sharded cluster, with options.
fn with_config(
config: ConnectionString,
options: Option<ClientOptions>,
description: Option<TopologyDescription>
) -> Result<Self>
config: ConnectionString,
options: Option<ClientOptions>,
description: Option<TopologyDescription>
) -> Result<Self>
Create a new Client with manual connection configurations.
connect
and with_uri
should generally be used as higher-level constructors.
fn db(&self, db_name: &str) -> Database
Creates a database representation.
fn db_with_prefs(
&self,
db_name: &str,
read_preference: Option<ReadPreference>,
write_concern: Option<WriteConcern>
) -> Database
&self,
db_name: &str,
read_preference: Option<ReadPreference>,
write_concern: Option<WriteConcern>
) -> Database
Creates a database representation with custom read and write controls.
fn acquire_stream(
&self,
read_pref: ReadPreference
) -> Result<(PooledStream, bool, bool)>
&self,
read_pref: ReadPreference
) -> Result<(PooledStream, bool, bool)>
Acquires a connection stream from the pool, along with slave_ok and should_send_read_pref.
fn acquire_write_stream(&self) -> Result<PooledStream>
Acquires a connection stream from the pool for write operations.
fn get_req_id(&self) -> i32
Returns a unique operational request id.
fn database_names(&self) -> Result<Vec<String>>
Returns a list of all database names that exist on the server.
fn drop_database(&self, db_name: &str) -> Result<()>
Drops the database defined by db_name
.
fn is_master(&self) -> Result<bool>
Reports whether this instance is a primary, master, mongos, or standalone mongod instance.
fn add_start_hook(
&mut self,
hook: fn(_: Client, _: &CommandStarted)
) -> Result<()>
&mut self,
hook: fn(_: Client, _: &CommandStarted)
) -> Result<()>
Sets a function to be run every time a command starts.
fn add_completion_hook(
&mut self,
hook: fn(_: Client, _: &CommandResult)
) -> Result<()>
&mut self,
hook: fn(_: Client, _: &CommandResult)
) -> Result<()>
Sets a function to be run every time a command completes.
Implementors
impl ThreadedClient for Client