pub struct PubSubSink { /* private fields */ }
Expand description
The sink part of a split async Pubsub.
The sink is used to subscribe and unsubscribe from channels. The stream part is independent from the sink, and dropping the sink doesn’t cause the stream part to stop working. The sink isn’t independent from the stream - dropping the stream will cause the sink to return errors on requests.
Implementations§
Source§impl PubSubSink
impl PubSubSink
Sourcepub async fn subscribe(
&mut self,
channel_name: impl ToRedisArgs,
) -> RedisResult<()>
pub async fn subscribe( &mut self, channel_name: impl ToRedisArgs, ) -> RedisResult<()>
Subscribes to a new channel(s).
let client = redis::Client::open("redis://127.0.0.1/")?;
let (mut sink, _stream) = client.get_async_pubsub().await?.split();
sink.subscribe("channel_1").await?;
sink.subscribe(&["channel_2", "channel_3"]).await?;
Sourcepub async fn unsubscribe(
&mut self,
channel_name: impl ToRedisArgs,
) -> RedisResult<()>
pub async fn unsubscribe( &mut self, channel_name: impl ToRedisArgs, ) -> RedisResult<()>
Unsubscribes from channel(s).
let client = redis::Client::open("redis://127.0.0.1/")?;
let (mut sink, _stream) = client.get_async_pubsub().await?.split();
sink.subscribe(&["channel_1", "channel_2"]).await?;
sink.unsubscribe(&["channel_1", "channel_2"]).await?;
Sourcepub async fn psubscribe(
&mut self,
channel_pattern: impl ToRedisArgs,
) -> RedisResult<()>
pub async fn psubscribe( &mut self, channel_pattern: impl ToRedisArgs, ) -> RedisResult<()>
Subscribes to new channel(s) with pattern(s).
let client = redis::Client::open("redis://127.0.0.1/")?;
let (mut sink, _stream) = client.get_async_pubsub().await?.split();
sink.psubscribe("channel*_1").await?;
sink.psubscribe(&["channel*_2", "channel*_3"]).await?;
Sourcepub async fn punsubscribe(
&mut self,
channel_pattern: impl ToRedisArgs,
) -> RedisResult<()>
pub async fn punsubscribe( &mut self, channel_pattern: impl ToRedisArgs, ) -> RedisResult<()>
Unsubscribes from channel pattern(s).
let client = redis::Client::open("redis://127.0.0.1/")?;
let (mut sink, _stream) = client.get_async_pubsub().await?.split();
sink.psubscribe(&["channel_1", "channel_2"]).await?;
sink.punsubscribe(&["channel_1", "channel_2"]).await?;
Sourcepub async fn ping_message<T: FromRedisValue>(
&mut self,
message: impl ToRedisArgs,
) -> RedisResult<T>
pub async fn ping_message<T: FromRedisValue>( &mut self, message: impl ToRedisArgs, ) -> RedisResult<T>
Sends a ping with a message to the server
Sourcepub async fn ping<T: FromRedisValue>(&mut self) -> RedisResult<T>
pub async fn ping<T: FromRedisValue>(&mut self) -> RedisResult<T>
Sends a ping to the server
Trait Implementations§
Source§impl Clone for PubSubSink
impl Clone for PubSubSink
Source§fn clone(&self) -> PubSubSink
fn clone(&self) -> PubSubSink
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for PubSubSink
impl RefUnwindSafe for PubSubSink
impl Send for PubSubSink
impl Sync for PubSubSink
impl Unpin for PubSubSink
impl UnwindSafe for PubSubSink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more