Macro lifeline::lifeline_bus [−][src]
Defines a lifeline bus: it's struct, Bus
impl, and DynBus
impl.
Examples
use lifeline::prelude::*; use tokio::sync::mpsc; lifeline_bus!(pub struct ExampleBus); // carry ExampleMessage on the bus, using a tokio mpsc sender. #[derive(Debug)] pub struct ExampleMessage {} impl Message<ExampleBus> for ExampleMessage { type Channel = mpsc::Sender<Self>; }
You can also define private structs:
use lifeline::prelude::*; lifeline_bus!(struct PrivateExampleBus);
You can also define generics (which are constrained to Debug):
use lifeline::prelude::*; lifeline_bus!(pub struct ExampleBus<T>);
Prelude, auto-imports, and rust-analyzer
Unfortunately, rust-analyzer doesn't handle auto-imports for structures defined in macros.
There is an ergonomic solution: define a prelude module in your crate root, and pub use
all your bus structs.
If you want, you can pub use lifeline::prelude::*
as well.