[−][src]Trait lifeline::prelude::Message
Attaches a channel to the Bus, carrying Self
as a message.
The Channel associated type should be the Sender of the channel which will carry this message.
Once implemented, the bus.rx::<Self>(), bus.tx::<Self>(), and bus.capacity::<Self>() methods can be called.
Example:
use lifeline::prelude::*; use tokio::sync::mpsc; lifeline_bus!(pub struct ExampleBus); #[derive(Debug)] pub struct ExampleMessage; impl Message<ExampleBus> for ExampleMessage { type Channel = mpsc::Sender<Self>; } fn main() -> anyhow::Result<()> { let bus = ExampleBus::default(); let mut tx = bus.tx::<ExampleMessage>()?; Ok(()) }