[−][src]Struct natsclient::Client
The main entry point for your application to consume NATS services. This client manages connections, connection retries, adjusts to new servers as they enter the cluster, and much more.
Methods
impl Client
[src]
pub fn from_options(opts: ClientOptions) -> Result<Client>
[src]
Creates a new client from a set of options, which can be created directly
or through a ClientOptionsBuilder
pub fn new(url: &str) -> Result<Client>
[src]
Creates a new client using the default options and the given URL. A client created this way will attempt to establish an anonymous connection with the given NATS server
pub fn subscribe<F>(&self, subject: &str, handler: F) -> Result<()> where
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
[src]
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
Creates a subscription to a new subject. The subject can be a specfic subject or a wildcard. The handler supplied will be given a reference to delivered messages as they arrive, and can return a Result to indicate processing failure
pub fn queue_subscribe<F>(
&self,
subject: &str,
queue_group: &str,
handler: F
) -> Result<()> where
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
[src]
&self,
subject: &str,
queue_group: &str,
handler: F
) -> Result<()> where
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
Creates a subscription for a queue group, allowing message delivery to be spread round-robin style across all clients expressing interest in that subject. For more information on how queue groups work, consult the NATS documentation.
pub fn request<T>(
&self,
subject: T,
payload: &[u8],
timeout: Duration
) -> Result<Message> where
T: AsRef<str>,
[src]
&self,
subject: T,
payload: &[u8],
timeout: Duration
) -> Result<Message> where
T: AsRef<str>,
Perform a synchronous request by publishing a message on the given subject and waiting
an expiration period indicated by the timeout
parameter. If the timeout expires before
a reply arrives on the inbox subject, an Err
result will be returned.
pub fn unsubscribe(&self, subject: impl AsRef<str>) -> Result<()>
[src]
Unsubscribe from a subject or wildcard
pub fn publish(
&self,
subject: &str,
payload: &[u8],
reply_to: Option<&str>
) -> Result<()>
[src]
&self,
subject: &str,
payload: &[u8],
reply_to: Option<&str>
) -> Result<()>
Asynchronously publish a message. This is a fire-and-forget style message and an Ok
result here does not imply that interested parties have received the message, only that
the message was successfully sent to NATS.
pub fn connect(&self) -> Result<()>
[src]
Connect a client to the NATS server(s) indicated by previously supplied configuration
Trait Implementations
impl Clone for Client
[src]
fn clone(&self) -> Client
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Client
[src]
Auto Trait Implementations
Blanket Implementations
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> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same for T
type Output = T
Should always be Self
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
T: InitializableFromZeroed + ?Sized,
fn clear(&mut self)
impl<T> InitializableFromZeroed for T where
T: Default,
T: Default,