Struct redis::aio::PubSub

source ·
pub struct PubSub<C = Pin<Box<dyn AsyncStream + Send + Sync>>>(_);
Available on crate feature aio only.
Expand description

Represents a PubSub connection.

Implementations§

source§

impl<C> PubSub<C>where C: Unpin + AsyncRead + AsyncWrite + Send,

source

pub async fn subscribe<T: ToRedisArgs>(&mut self, channel: T) -> RedisResult<()>

Subscribes to a new channel.

source

pub async fn psubscribe<T: ToRedisArgs>( &mut self, pchannel: T ) -> RedisResult<()>

Subscribes to a new channel with a pattern.

source

pub async fn unsubscribe<T: ToRedisArgs>( &mut self, channel: T ) -> RedisResult<()>

Unsubscribes from a channel.

source

pub async fn punsubscribe<T: ToRedisArgs>( &mut self, pchannel: T ) -> RedisResult<()>

Unsubscribes from a channel with a pattern.

source

pub fn on_message(&mut self) -> impl Stream<Item = Msg> + '_

Returns [Stream] of Msgs from this PubSubs subscriptions.

The message itself is still generic and can be converted into an appropriate type through the helper methods on it.

source

pub fn into_on_message(self) -> impl Stream<Item = Msg>

Returns [Stream] of Msgs from this PubSubs subscriptions consuming it.

The message itself is still generic and can be converted into an appropriate type through the helper methods on it. This can be useful in cases where the stream needs to be returned or held by something other than the PubSub.

source

pub async fn into_connection(self) -> Connection<C>

Exits from PubSub mode and converts PubSub into Connection.

Auto Trait Implementations§

§

impl<C = Pin<Box<dyn AsyncStream + Sync + Send + 'static, Global>>> !RefUnwindSafe for PubSub<C>

§

impl<C> Send for PubSub<C>where C: Send,

§

impl<C> Sync for PubSub<C>where C: Sync,

§

impl<C> Unpin for PubSub<C>where C: Unpin,

§

impl<C = Pin<Box<dyn AsyncStream + Sync + Send + 'static, Global>>> !UnwindSafe for PubSub<C>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more