#[non_exhaustive]
pub struct ConnectionString {
Show 22 fields pub host_info: HostInfo, pub app_name: Option<String>, pub tls: Option<Tls>, pub heartbeat_frequency: Option<Duration>, pub local_threshold: Option<Duration>, pub read_concern: Option<ReadConcern>, pub replica_set: Option<String>, pub write_concern: Option<WriteConcern>, pub server_selection_timeout: Option<Duration>, pub max_pool_size: Option<u32>, pub min_pool_size: Option<u32>, pub max_idle_time: Option<Duration>, pub compressors: Option<Vec<Compressor, Global>>, pub connect_timeout: Option<Duration>, pub retry_reads: Option<bool>, pub retry_writes: Option<bool>, pub direct_connection: Option<bool>, pub credential: Option<Credential>, pub default_database: Option<String>, pub load_balanced: Option<bool>, pub socket_timeout: Option<Duration>, pub read_preference: Option<ReadPreference>, /* private fields */
}
Expand description

Contains the options that can be set via a MongoDB connection string.

The format of a MongoDB connection string is described here.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§host_info: HostInfo

The initial list of seeds that the Client should connect to, or a DNS name used for SRV lookup of the initial seed list.

Note that by default, the driver will autodiscover other nodes in the cluster. To connect directly to a single server (rather than autodiscovering the rest of the cluster), set the direct_connection field to true.

§app_name: Option<String>

The application name that the Client will send to the server as part of the handshake. This can be used in combination with the server logs to determine which Client is connected to a server.

§tls: Option<Tls>

The TLS configuration for the Client to use in its connections with the server.

By default, TLS is disabled.

§heartbeat_frequency: Option<Duration>

The amount of time each monitoring thread should wait between performing server checks.

The default value is 10 seconds.

§local_threshold: Option<Duration>

When running a read operation with a ReadPreference that allows selecting secondaries, local_threshold is used to determine how much longer the average round trip time between the driver and server is allowed compared to the least round trip time of all the suitable servers. For example, if the average round trip times of the suitable servers are 5 ms, 10 ms, and 15 ms, and the local threshold is 8 ms, then the first two servers are within the latency window and could be chosen for the operation, but the last one is not.

A value of zero indicates that there is no latency window, so only the server with the lowest average round trip time is eligible.

The default value is 15 ms.

§read_concern: Option<ReadConcern>

Specifies the default read concern for operations performed on the Client. See the ReadConcern type documentation for more details.

§replica_set: Option<String>

The name of the replica set that the Client should connect to.

§write_concern: Option<WriteConcern>

Specifies the default write concern for operations performed on the Client. See the WriteConcern type documentation for more details.

§server_selection_timeout: Option<Duration>

The amount of time the Client should attempt to select a server for an operation before timing outs

The default value is 30 seconds.

§max_pool_size: Option<u32>

The maximum amount of connections that the Client should allow to be created in a connection pool for a given server. If an operation is attempted on a server while max_pool_size connections are checked out, the operation will block until an in-progress operation finishes and its connection is checked back into the pool.

The default value is 100.

§min_pool_size: Option<u32>

The minimum number of connections that should be available in a server’s connection pool at a given time. If fewer than min_pool_size connections are in the pool, connections will be added to the pool in the background until min_pool_size is reached.

The default value is 0.

§max_idle_time: Option<Duration>

The amount of time that a connection can remain idle in a connection pool before being closed. A value of zero indicates that connections should not be closed due to being idle.

By default, connections will not be closed due to being idle.

§compressors: Option<Vec<Compressor, Global>>

The compressors that the Client is willing to use in the order they are specified in the configuration. The Client sends this list of compressors to the server. The server responds with the intersection of its supported list of compressors. The order of compressors indicates preference of compressors.

§connect_timeout: Option<Duration>

The connect timeout passed to each underlying TcpStream when attempting to connect to the server.

The default value is 10 seconds.

§retry_reads: Option<bool>

Whether or not the client should retry a read operation if the operation fails.

The default value is true.

§retry_writes: Option<bool>

Whether or not the client should retry a write operation if the operation fails.

The default value is true.

§direct_connection: Option<bool>

Specifies whether the Client should directly connect to a single host rather than autodiscover all servers in the cluster.

The default value is false.

§credential: Option<Credential>

The credential to use for authenticating connections made by this client.

§default_database: Option<String>

Default database for this client.

By default, no default database is specified.

§load_balanced: Option<bool>

Whether or not the client is connecting to a MongoDB cluster through a load balancer.

§socket_timeout: Option<Duration>

Amount of time spent attempting to send or receive on a socket before timing out; note that this only applies to application operations, not server discovery and monitoring.

§read_preference: Option<ReadPreference>

Default read preference for the client.

Implementations§

Parses a MongoDB connection string into a ConnectionString struct. If the string is malformed or one of the options has an invalid value, an error will be returned.

Amount of time spent attempting to check out a connection from a server’s connection pool before timing out. Not supported by the Rust driver.

Relax TLS constraints as much as possible (e.g. allowing invalid certificates or hostname mismatches). Not supported by the Rust driver.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.