pub struct Publisher { /* private fields */ }Expand description
Publisher for sending messages to Redis channels
Implementations§
Source§impl Publisher
 
impl Publisher
Sourcepub fn new(connection: Arc<Mutex<dyn PubSubConnection + Send + Sync>>) -> Self
 
pub fn new(connection: Arc<Mutex<dyn PubSubConnection + Send + Sync>>) -> Self
Create a new publisher
Sourcepub async fn publish(
    &self,
    channel: impl Into<String>,
    message: impl Into<String>,
) -> RedisResult<i64>
 
pub async fn publish( &self, channel: impl Into<String>, message: impl Into<String>, ) -> RedisResult<i64>
Publish a message to a channel
Returns the number of subscribers that received the message.
§Examples
let publisher = client.publisher().await?;
let subscribers = publisher.publish("news", "Breaking news!").await?;
println!("Message delivered to {} subscribers", subscribers);Sourcepub async fn publish_multiple(
    &self,
    messages: HashMap<String, String>,
) -> RedisResult<HashMap<String, i64>>
 
pub async fn publish_multiple( &self, messages: HashMap<String, String>, ) -> RedisResult<HashMap<String, i64>>
Publish multiple messages to different channels
§Examples
let publisher = client.publisher().await?;
let mut messages = HashMap::new();
messages.insert("news".to_string(), "Breaking news!".to_string());
messages.insert("updates".to_string(), "System update available".to_string());
let results = publisher.publish_multiple(messages).await?;
for (channel, count) in results {
    println!("Channel {}: {} subscribers", channel, count);
}Auto Trait Implementations§
impl Freeze for Publisher
impl !RefUnwindSafe for Publisher
impl Send for Publisher
impl Sync for Publisher
impl Unpin for Publisher
impl !UnwindSafe for Publisher
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