[−][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() -> Result<Client>
[src]
Creates a new client using the default options. A client created this way will attempt to establish an anonymous connection with a local NATS server running at 0.0.0.0:4222
pub fn subscribe<T, F>(&self, subject: T, handler: F) -> Result<()> where
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
T: Into<String> + Clone,
[src]
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
T: Into<String> + Clone,
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<T, F>(
&self,
subject: T,
queue_group: T,
handler: F
) -> Result<()> where
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
T: Into<String> + Clone,
[src]
&self,
subject: T,
queue_group: T,
handler: F
) -> Result<()> where
F: Fn(&Message) -> Result<()> + Sync + Send,
F: 'static,
T: Into<String> + Clone,
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<String>
) -> Result<()>
[src]
&self,
subject: &str,
payload: &[u8],
reply_to: Option<String>
) -> 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
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?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> Same for T
type Output = T
Should always be Self