Skip to main content

Subscription

Struct Subscription 

Source
pub struct Subscription { /* private fields */ }
Expand description

A handle to one subscription — owns the receive end of the bus channel.

Drop unsubscribes from everything automatically. While the handle is alive, recv / recv_timeout / try_recv drain queued PubsubFrames in arrival order.

Implementations§

Source§

impl Subscription

Source

pub fn subscribe(&mut self, channels: &[&[u8]])

SUBSCRIBE channel [channel ...]. Per-channel Subscribe acks are enqueued onto the receive queue in order.

Source

pub fn psubscribe(&mut self, patterns: &[&[u8]])

PSUBSCRIBE pattern [pattern ...]. Patterns use Redis glob syntax (*, ?, [abc]).

Source

pub fn unsubscribe(&mut self, channels: &[&[u8]])

UNSUBSCRIBE [channel ...]. Empty channels removes every channel subscription this handle holds (matching the Redis wire shape: individual ack frames for each channel that was actually removed, or a single Unsubscribe { channel: None } if none were held).

Source

pub fn punsubscribe(&mut self, patterns: &[&[u8]])

PUNSUBSCRIBE [pattern ...]. Empty patterns removes every pattern.

Source

pub fn recv(&self) -> Result<PubsubFrame>

Block until one frame is queued. Err(io::ErrorKind::UnexpectedEof) once the underlying bus tears down (last Store clone dropped).

Source

pub fn recv_timeout(&self, dur: Duration) -> Result<PubsubFrame>

Bounded blocking recv. Err(io::ErrorKind::TimedOut) when dur elapses; Err(io::ErrorKind::UnexpectedEof) when the bus is gone.

Source

pub fn try_recv(&self) -> Result<Option<PubsubFrame>>

Non-blocking recv. Ok(None) if the queue is empty; Err(UnexpectedEof) when the bus is gone.

Trait Implementations§

Source§

impl Debug for Subscription

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Subscription

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.