[−][src]Struct nats::ConnectionOptions
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]
self,
user: &str,
password: &str
) -> ConnectionOptions<Authenticated>
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]
self,
max_reconnects: Option<usize>
) -> ConnectionOptions<TypeState>
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]
self,
reconnect_buffer_size: usize
) -> ConnectionOptions<TypeState>
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]
F: Fn(&ServerInfo) + Send + Sync + 'static,
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]
F: Fn(&ServerInfo) + Send + Sync + 'static,
Set a callback to be executed when connectivity to a server has been established.
Trait Implementations
impl<TypeState: Clone> Clone for ConnectionOptions<TypeState>[src]
fn clone(&self) -> ConnectionOptions<TypeState>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<TypeState: Debug> Debug for ConnectionOptions<TypeState>[src]
impl Default for ConnectionOptions<NoAuth>[src]
fn default() -> ConnectionOptions<NoAuth>[src]
Auto Trait Implementations
impl<TypeState> !RefUnwindSafe for ConnectionOptions<TypeState>
impl<TypeState> Send for ConnectionOptions<TypeState> where
TypeState: Send,
TypeState: Send,
impl<TypeState> Sync for ConnectionOptions<TypeState> where
TypeState: Sync,
TypeState: Sync,
impl<TypeState> Unpin for ConnectionOptions<TypeState> where
TypeState: Unpin,
TypeState: Unpin,
impl<TypeState> !UnwindSafe for ConnectionOptions<TypeState>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,