pub struct ConnectOptions { /* private fields */ }
Expand description

Connect options.

Implementations

Enables customization of NATS connection.

Examples
let mut options = async_nats::ConnectOptions::new();
let nc = options.connect("demo.nats.io").await?;

Connect to the NATS Server leveraging all passed options.

Examples
let nc = async_nats::ConnectOptions::new().require_tls(true).connect("demo.nats.io").await?;

Loads root certificates by providing the path to them.

Examples
let nc =
async_nats::ConnectOptions::new().add_root_certificates("mycerts.pem".into()).connect("demo.nats.io").await?;

Loads client certificate by providing the path to it.

Examples
let nc =
async_nats::ConnectOptions::new().add_client_certificate("cert.pem".into(), "key.pem".into()).connect("demo.nats.io").await?;

Sets or disables TLS requirement. If TLS connection is impossible while options.require_tls(true) connection will return error.

Examples
let nc =
async_nats::ConnectOptions::new().require_tls(true).connect("demo.nats.io").await?;

Sets the interval for flushing. NATS connection will send buffered data to the NATS Server whenever buffer limit is reached, but it is also necessary to flush once in a while if client is sending rarely and small messages. Flush interval allows to modify that interval.

Examples
async_nats::ConnectOptions::new().flush_interval(Duration::from_millis(100)).connect("demo.nats.io").await?;

Sets how often Client sends PING message to the server.

Examples
async_nats::ConnectOptions::new().flush_interval(Duration::from_millis(100)).connect("demo.nats.io").await?;

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

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.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

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.