[][src]Struct nats::ConnectionOptions

pub struct ConnectionOptions<TypeState> { /* fields omitted */ }

A configuration object for a NATS connection.

Methods

impl ConnectionOptions<NoAuth>[src]

pub fn new() -> ConnectionOptions<NoAuth>[src]

ConnectionOptions for establishing a new NATS Connection.

Example

let options = nats::ConnectionOptions::new();
let nc = options.connect("demo.nats.io")?;

pub fn with_token(self, token: &str) -> ConnectionOptions<Authenticated>[src]

Authenticate with NATS using a token.

Example

let nc = nats::ConnectionOptions::new()
    .with_token("t0k3n!")
    .connect("demo.nats.io")?;

pub fn with_user_pass(
    self,
    user: &str,
    password: &str
) -> ConnectionOptions<Authenticated>
[src]

Authenticate with NATS using a username and password.

Example

let nc = nats::ConnectionOptions::new()
    .with_user_pass("derek", "s3cr3t!")
    .connect("demo.nats.io")?;

impl<TypeState> ConnectionOptions<TypeState>[src]

pub fn with_name(self, name: &str) -> ConnectionOptions<TypeState>[src]

Add a name option to this configuration.

Example

let nc = nats::ConnectionOptions::new()
    .with_name("My App")
    .connect("demo.nats.io")?;

pub const fn no_echo(self) -> ConnectionOptions<TypeState>[src]

Select option to not deliver messages that we have published.

Example

let nc = nats::ConnectionOptions::new()
    .no_echo()
    .connect("demo.nats.io")?;

pub const fn max_reconnects(
    self,
    max_reconnects: Option<usize>
) -> ConnectionOptions<TypeState>
[src]

Set the maximum number of reconnect attempts. If no servers remain that are under this threshold, all servers will still be attempted.

Example

let nc = nats::ConnectionOptions::new()
    .max_reconnects(Some(3))
    .connect("demo.nats.io")?;

pub const fn reconnect_buffer_size(
    self,
    reconnect_buffer_size: usize
) -> ConnectionOptions<TypeState>
[src]

Set the maximum amount of bytes to buffer when accepting outgoing traffic in disconnected mode.

Example

let nc = nats::ConnectionOptions::new()
    .reconnect_buffer_size(64 * 1024)
    .connect("demo.nats.io")?;

pub fn connect(self, nats_url: &str) -> Result<Connection>[src]

Establish a Connection with a NATS server.

Example

let options = nats::ConnectionOptions::new();
let nc = options.connect("demo.nats.io")?;

pub fn set_disconnect_callback<F>(self, cb: F) -> Self where
    F: Fn(&ServerInfo) + Send + Sync + 'static, 
[src]

Set a callback to be executed when connectivity to a server has been lost.

pub fn set_reconnect_callback<F>(self, cb: F) -> Self where
    F: Fn(&ServerInfo) + Send + Sync + 'static, 
[src]

Set a callback to be executed when connectivity to a server has been established.

Trait Implementations

impl<TypeState: Clone> Clone for ConnectionOptions<TypeState>[src]

impl<TypeState: Debug> Debug for ConnectionOptions<TypeState>[src]

impl Default for ConnectionOptions<NoAuth>[src]

Auto Trait Implementations

impl<TypeState> !RefUnwindSafe for ConnectionOptions<TypeState>

impl<TypeState> Send for ConnectionOptions<TypeState> where
    TypeState: Send

impl<TypeState> Sync for ConnectionOptions<TypeState> where
    TypeState: Sync

impl<TypeState> Unpin for ConnectionOptions<TypeState> where
    TypeState: Unpin

impl<TypeState> !UnwindSafe for ConnectionOptions<TypeState>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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