#[non_exhaustive]
pub struct ConnectionString {
Show 25 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_connecting: Option<u32>, pub max_idle_time: Option<Duration>, pub compressors: Option<Vec<Compressor>>, 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>, pub uuid_representation: Option<UuidRepresentation>, pub srv_max_hosts: Option<u32>, /* 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 10.

§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_connecting: Option<u32>

The maximum number of new connections that can be created concurrently.

If specified, this value must be greater than 0. The default is 2.

§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>>

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.

§uuid_representation: Option<UuidRepresentation>

The UuidRepresentation to use when decoding Binary values with the UuidOld subtype. This is not used by the driver; client code can use this when deserializing relevant values with Binary::to_uuid_with_representation.

§srv_max_hosts: Option<u32>

Limit on the number of mongos connections that may be created for sharded topologies.

Implementations§

source§

impl ConnectionString

source

pub fn parse(s: impl AsRef<str>) -> Result<Self>

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.

source

pub fn wait_queue_timeout(&self) -> Option<Duration>

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.

source

pub fn tls_insecure(&self) -> Option<bool>

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

Trait Implementations§

source§

impl Debug for ConnectionString

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ConnectionString

source§

fn default() -> ConnectionString

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ConnectionString

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FromStr for ConnectionString

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for ConnectionString

source§

fn eq(&self, other: &ConnectionString) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for ConnectionString

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Conv for T

source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
source§

impl<T> FmtForward for T

source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Pipe for T
where T: ?Sized,

source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> Tap for T

source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
source§

impl<T> TryConv for T

source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,