Struct nats::asynk::Subscription
source · [−]pub struct Subscription { /* private fields */ }
Expand description
A subscription to a subject.
Implementations
sourceimpl Subscription
impl Subscription
sourcepub async fn next(&self) -> Option<Message>
pub async fn next(&self) -> Option<Message>
Gets the next message, or returns None
if the subscription
has been unsubscribed or the connection is closed.
sourcepub fn try_next(&self) -> Option<Message>
pub fn try_next(&self) -> Option<Message>
Try to get the next message, or None if no messages are present or if the subscription has been unsubscribed or the connection closed.
Example
if let Some(msg) = sub.try_next() {
println!("Received {}", msg);
}
sourcepub async fn drain(&self) -> Result<()>
pub async fn drain(&self) -> Result<()>
Stops listening for new messages, but the remaining queued messages can still be received.
sourcepub async fn unsubscribe(&self) -> Result<()>
pub async fn unsubscribe(&self) -> Result<()>
Stops listening for new messages and discards the remaining queued messages.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl !UnwindSafe for Subscription
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