Skip to main content

Publisher

Trait Publisher 

Source
pub trait Publisher: Send + Sync {
    // Required methods
    fn publish(&self, subject: &str, payload: Bytes) -> Result<(), Error>;
    fn flush(&self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
}
Expand description

Publisher trait for sending messages to subjects.

Publishers are responsible for sending messages to named subjects. Messages are delivered to all subscribers matching the subject pattern.

Required Methods§

Source

fn publish(&self, subject: &str, payload: Bytes) -> Result<(), Error>

Publish a message to a subject.

This queues the message for delivery and returns immediately. Use flush to ensure delivery.

Source

fn flush(&self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>

Flush pending messages to ensure delivery.

Returns when all previously published messages have been acknowledged by the messaging system.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§