summaryrefslogtreecommitdiff
path: root/mingling/src/asset/dispatcher.rs
blob: 31623d39bd1373a5362b9c65c4cd91d9a91d5e35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::{ChainProcess, Program, asset::node::Node};

pub use mingling_macros::Dispatcher;

pub trait Dispatcher {
    fn node(&self) -> Node;
}

pub trait DispatcherChain {
    fn begin(&self) -> ChainProcess;
}

impl Program {
    /// Adds a dispatcher to the program.
    pub fn with_dispatcher<D: Dispatcher + 'static>(&mut self, dispatcher: D) {
        let dispatcher = Box::new(dispatcher);
        self.dispatcher.push(dispatcher);
    }
}