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§
Sourcefn id(&self) -> SubId
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.
Sourcefn run(&self, sender: Sender<M>, stop: StopSignal)
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".