Struct nats::asynk::Connection
source · [−]pub struct Connection { /* private fields */ }
Expand description
A NATS client connection.
Implementations
sourceimpl Connection
impl Connection
sourcepub async fn publish(&self, subject: &str, msg: impl AsRef<[u8]>) -> Result<()>
pub async fn publish(&self, subject: &str, msg: impl AsRef<[u8]>) -> Result<()>
Publishes a message.
sourcepub async fn publish_request(
&self,
subject: &str,
reply: &str,
msg: impl AsRef<[u8]>
) -> Result<()>
pub async fn publish_request(
&self,
subject: &str,
reply: &str,
msg: impl AsRef<[u8]>
) -> Result<()>
Publishes a message with a reply subject.
sourcepub async fn request(
&self,
subject: &str,
msg: impl AsRef<[u8]>
) -> Result<Message>
pub async fn request(
&self,
subject: &str,
msg: impl AsRef<[u8]>
) -> Result<Message>
Publishes a message and waits for the response.
sourcepub async fn request_timeout(
&self,
subject: &str,
msg: impl AsRef<[u8]>,
timeout: Duration
) -> Result<Message>
pub async fn request_timeout(
&self,
subject: &str,
msg: impl AsRef<[u8]>,
timeout: Duration
) -> Result<Message>
Publishes a message and waits for the response or until the timeout duration is reached
sourcepub async fn request_multi(
&self,
subject: &str,
msg: impl AsRef<[u8]>
) -> Result<Subscription>
pub async fn request_multi(
&self,
subject: &str,
msg: impl AsRef<[u8]>
) -> Result<Subscription>
Publishes a message and returns a subscription for awaiting the response.
sourcepub async fn subscribe(&self, subject: &str) -> Result<Subscription>
pub async fn subscribe(&self, subject: &str) -> Result<Subscription>
Creates a subscription.
sourcepub async fn queue_subscribe(
&self,
subject: &str,
queue: &str
) -> Result<Subscription>
pub async fn queue_subscribe(
&self,
subject: &str,
queue: &str
) -> Result<Subscription>
Creates a queue subscription.
sourcepub async fn flush_timeout(&self, timeout: Duration) -> Result<()>
pub async fn flush_timeout(&self, timeout: Duration) -> Result<()>
Flushes by performing a round trip to the server or times out after a duration of time.
sourcepub async fn rtt(&self) -> Result<Duration>
pub async fn rtt(&self) -> Result<Duration>
Calculates the round trip time between this client and the server.
sourcepub fn client_ip(&self) -> Result<IpAddr>
pub fn client_ip(&self) -> Result<IpAddr>
Returns the client IP as known by the most recently connected server.
Supported as of server version 2.1.6.
sourcepub fn client_id(&self) -> u64
pub fn client_id(&self) -> u64
Returns the client ID as known by the most recently connected server.
sourcepub async fn drain(&self) -> Result<()>
pub async fn drain(&self) -> Result<()>
Unsubscribes all subscriptions and flushes the connection.
Remaining messages can still be received by existing Subscription
s.
Trait Implementations
sourceimpl Clone for Connection
impl Clone for Connection
sourcefn clone(&self) -> Connection
fn clone(&self) -> Connection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more