pub trait PubSubCommands<'a> {
// Required methods
async fn psubscribe<P, PP>(self, patterns: PP) -> Result<PubSubStream>
where P: SingleArg + Send + 'a,
PP: SingleArgCollection<P>;
async fn ssubscribe<C, CC>(self, shardchannels: CC) -> Result<PubSubStream>
where C: SingleArg + Send + 'a,
CC: SingleArgCollection<C>;
async fn subscribe<C, CC>(self, channels: CC) -> Result<PubSubStream>
where C: SingleArg + Send + 'a,
CC: SingleArgCollection<C>;
// Provided methods
fn publish<C, M>(
self,
channel: C,
message: M,
) -> PreparedCommand<'a, Self, usize>
where Self: Sized,
C: SingleArg,
M: SingleArg { ... }
fn pub_sub_channels<C, CC>(
self,
options: PubSubChannelsOptions,
) -> PreparedCommand<'a, Self, CC>
where Self: Sized,
C: PrimitiveResponse + DeserializeOwned,
CC: CollectionResponse<C> { ... }
fn pub_sub_numpat(self) -> PreparedCommand<'a, Self, usize>
where Self: Sized { ... }
fn pub_sub_numsub<C, CC, R, RR>(
self,
channels: CC,
) -> PreparedCommand<'a, Self, RR>
where Self: Sized,
C: SingleArg,
CC: SingleArgCollection<C>,
R: PrimitiveResponse,
RR: KeyValueCollectionResponse<R, usize> { ... }
fn pub_sub_shardchannels<C, CC>(
self,
options: PubSubChannelsOptions,
) -> PreparedCommand<'a, Self, CC>
where Self: Sized,
C: PrimitiveResponse + DeserializeOwned,
CC: CollectionResponse<C> { ... }
fn pub_sub_shardnumsub<C, CC, R, RR>(
self,
channels: CC,
) -> PreparedCommand<'a, Self, RR>
where Self: Sized,
C: SingleArg,
CC: SingleArgCollection<C>,
R: PrimitiveResponse,
RR: KeyValueCollectionResponse<R, usize> { ... }
fn spublish<C, M>(
self,
shardchannel: C,
message: M,
) -> PreparedCommand<'a, Self, usize>
where Self: Sized,
C: SingleArg,
M: SingleArg { ... }
}
Expand description
Required Methods§
Sourceasync fn psubscribe<P, PP>(self, patterns: PP) -> Result<PubSubStream>
async fn psubscribe<P, PP>(self, patterns: PP) -> Result<PubSubStream>
Subscribes the client to the given patterns.
§Example
use rustis::{
client::{Client, ClientPreparedCommand},
commands::{FlushingMode, PubSubCommands, ServerCommands},
resp::cmd,
Result,
};
use futures_util::StreamExt;
#[cfg_attr(feature = "tokio-runtime", tokio::main)]
#[cfg_attr(feature = "async-std-runtime", async_std::main)]
async fn main() -> Result<()> {
let pub_sub_client = Client::connect("127.0.0.1:6379").await?;
let regular_client = Client::connect("127.0.0.1:6379").await?;
regular_client.flushdb(FlushingMode::Sync).await?;
let mut pub_sub_stream = pub_sub_client.psubscribe("mychannel*").await?;
regular_client.publish("mychannel1", "mymessage").await?;
let message = pub_sub_stream.next().await.unwrap()?;
assert_eq!(b"mychannel*".to_vec(), message.pattern);
assert_eq!(b"mychannel1".to_vec(), message.channel);
assert_eq!(b"mymessage".to_vec(), message.payload);
pub_sub_stream.close().await?;
Ok(())
}
§See Also
Sourceasync fn ssubscribe<C, CC>(self, shardchannels: CC) -> Result<PubSubStream>
async fn ssubscribe<C, CC>(self, shardchannels: CC) -> Result<PubSubStream>
Sourceasync fn subscribe<C, CC>(self, channels: CC) -> Result<PubSubStream>
async fn subscribe<C, CC>(self, channels: CC) -> Result<PubSubStream>
Subscribes the client to the specified channels.
§Example
use rustis::{
client::{Client, ClientPreparedCommand},
commands::{FlushingMode, PubSubCommands, ServerCommands},
resp::cmd,
Result,
};
use futures_util::StreamExt;
#[cfg_attr(feature = "tokio-runtime", tokio::main)]
#[cfg_attr(feature = "async-std-runtime", async_std::main)]
async fn main() -> Result<()> {
let pub_sub_client = Client::connect("127.0.0.1:6379").await?;
let regular_client = Client::connect("127.0.0.1:6379").await?;
regular_client.flushdb(FlushingMode::Sync).await?;
let mut pub_sub_stream = pub_sub_client.subscribe("mychannel").await?;
regular_client.publish("mychannel", "mymessage").await?;
let message = pub_sub_stream.next().await.unwrap()?;
assert_eq!(b"mychannel".to_vec(), message.channel);
assert_eq!(b"mymessage".to_vec(), message.payload);
pub_sub_stream.close().await?;
Ok(())
}
§See Also
Provided Methods§
Sourcefn publish<C, M>(
self,
channel: C,
message: M,
) -> PreparedCommand<'a, Self, usize>
fn publish<C, M>( self, channel: C, message: M, ) -> PreparedCommand<'a, Self, usize>
Sourcefn pub_sub_channels<C, CC>(
self,
options: PubSubChannelsOptions,
) -> PreparedCommand<'a, Self, CC>
fn pub_sub_channels<C, CC>( self, options: PubSubChannelsOptions, ) -> PreparedCommand<'a, Self, CC>
Sourcefn pub_sub_numpat(self) -> PreparedCommand<'a, Self, usize>where
Self: Sized,
fn pub_sub_numpat(self) -> PreparedCommand<'a, Self, usize>where
Self: Sized,
Sourcefn pub_sub_numsub<C, CC, R, RR>(
self,
channels: CC,
) -> PreparedCommand<'a, Self, RR>where
Self: Sized,
C: SingleArg,
CC: SingleArgCollection<C>,
R: PrimitiveResponse,
RR: KeyValueCollectionResponse<R, usize>,
fn pub_sub_numsub<C, CC, R, RR>(
self,
channels: CC,
) -> PreparedCommand<'a, Self, RR>where
Self: Sized,
C: SingleArg,
CC: SingleArgCollection<C>,
R: PrimitiveResponse,
RR: KeyValueCollectionResponse<R, usize>,
Sourcefn pub_sub_shardchannels<C, CC>(
self,
options: PubSubChannelsOptions,
) -> PreparedCommand<'a, Self, CC>
fn pub_sub_shardchannels<C, CC>( self, options: PubSubChannelsOptions, ) -> PreparedCommand<'a, Self, CC>
Sourcefn pub_sub_shardnumsub<C, CC, R, RR>(
self,
channels: CC,
) -> PreparedCommand<'a, Self, RR>where
Self: Sized,
C: SingleArg,
CC: SingleArgCollection<C>,
R: PrimitiveResponse,
RR: KeyValueCollectionResponse<R, usize>,
fn pub_sub_shardnumsub<C, CC, R, RR>(
self,
channels: CC,
) -> PreparedCommand<'a, Self, RR>where
Self: Sized,
C: SingleArg,
CC: SingleArgCollection<C>,
R: PrimitiveResponse,
RR: KeyValueCollectionResponse<R, usize>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.