[−][src]Struct nats::Connection
A NATS connection.
Methods
impl Connection[src]
pub fn subscribe(&self, subject: &str) -> Result<Subscription>[src]
pub fn queue_subscribe(
&self,
subject: &str,
queue: &str
) -> Result<Subscription>[src]
&self,
subject: &str,
queue: &str
) -> Result<Subscription>
Create a queue subscription for the given NATS connection.
Example
let sub = nc.queue_subscribe("foo", "production")?;
pub fn publish(&self, subject: &str, msg: impl AsRef<[u8]>) -> Result<()>[src]
pub fn publish_request(
&self,
subject: &str,
reply: &str,
msg: impl AsRef<[u8]>
) -> Result<()>[src]
&self,
subject: &str,
reply: &str,
msg: impl AsRef<[u8]>
) -> Result<()>
Publish a message on the given subject with a reply subject for responses.
Example
let reply = nc.new_inbox(); let rsub = nc.subscribe(&reply)?; nc.publish_request("foo", &reply, "Help me!")?;
pub fn new_inbox(&self) -> String[src]
Create a new globally unique inbox which can be used for replies.
Example
let reply = nc.new_inbox(); let rsub = nc.subscribe(&reply)?;
pub fn request(&self, subject: &str, msg: impl AsRef<[u8]>) -> Result<Message>[src]
Publish a message on the given subject as a request and receive the response.
Example
let resp = nc.request("foo", "Help me?")?;
pub fn request_timeout(
&self,
subject: &str,
msg: impl AsRef<[u8]>,
timeout: Duration
) -> Result<Message>[src]
&self,
subject: &str,
msg: impl AsRef<[u8]>,
timeout: Duration
) -> Result<Message>
Publish a message on the given subject as a request and receive the response. This call will return after the timeout duration if no response is received.
Example
let resp = nc.request_timeout("foo", "Help me?", std::time::Duration::from_secs(2))?;
pub fn request_multi(
&self,
subject: &str,
msg: impl AsRef<[u8]>
) -> Result<Subscription>[src]
&self,
subject: &str,
msg: impl AsRef<[u8]>
) -> Result<Subscription>
Publish a message on the given subject as a request and allow multiple responses.
Example
for msg in nc.request_multi("foo", "Help")?.iter().take(1) {}
pub fn flush(&self) -> Result<()>[src]
Flush a NATS connection by sending a PING protocol and waiting for the responding PONG.
Example
nc.flush()?;
pub fn close(self) -> Result<()>[src]
Trait Implementations
impl Clone for Connection[src]
fn clone(&self) -> Connection[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for Connection[src]
Auto Trait Implementations
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
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>,