Skip to main content

Subscription

Trait Subscription 

Source
pub trait Subscription<M: Send + 'static>: Send {
    // Required methods
    fn id(&self) -> SubId;
    fn run(&self, sender: Sender<M>, stop: StopSignal);
}
Expand description

A subscription produces messages from an external event source.

Subscriptions run on background threads and send messages through the provided channel. The runtime manages their lifecycle.

Required Methods§

Source

fn id(&self) -> SubId

Unique identifier for deduplication.

Subscriptions with the same ID are considered identical. The runtime uses this to avoid restarting unchanged subscriptions.

Source

fn run(&self, sender: Sender<M>, stop: StopSignal)

Start the subscription, sending messages through the channel.

This is called on a background thread. Implementations should loop and send messages until the channel is disconnected (receiver dropped) or the stop signal is received.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<M: Send + 'static> Subscription<M> for Every<M>

Source§

impl<M: Send + 'static> Subscription<M> for ProcessSubscription<M>