[][src]Macro revent::hub

macro_rules! hub {
    ($name:ident {
         $($channel:ident: $channel_type:path),*$(,)?
     }) => { ... };
}

Generate a top-level hub.

A hub is struct where all signals are defined. It is the "root" object for downstream nodes.

The macro invocation

use revent::hub;

trait X {}
trait Y {}
trait Z {}

hub! {
    HubName {
        signal_name_1: X,
        signal_name_2: Y,
        signal_name_3: Z,
    }
}

generates the code

This example is not tested
struct HubName { ... }

impl HubName {
    fn new() -> Self { ... }

    pub fn subscribe<T>(&mut self, input: T::Input)
    where
        T: revent::Nodified + revent::Selfscriber<Self> + revent::Subscriber,
        T::Node: for<'a> From<&'a Self>,
    { ... }

    pub fn signal_name_1(&mut self) -> &mut revent::Signal<dyn X> { ... }
    pub fn signal_name_2(&mut self) -> &mut revent::Signal<dyn Y> { ... }
    pub fn signal_name_3(&mut self) -> &mut revent::Signal<dyn Z> { ... }
}

impl Default for HubName {
    fn default() -> Self { ... }
}