aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/any/group.rs
blob: c251286cb2d54564833ab5e19e19d5c6cdd7296c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::{AnyOutput, ChainProcess};

/// Used to mark a type with a unique enum ID, assisting dynamic dispatch
pub trait Groupped<Group> {
    /// Returns the specific enum value representing its ID within that enum
    fn member_id() -> Group;

    /// Converts the grouped item into a `ChainProcess` directed to the chain route.
    ///
    /// This wraps the item into an `AnyOutput` and routes it to the chain processing pipeline.
    fn to_chain(self) -> ChainProcess<Group> {
        AnyOutput::new(self).route_chain()
    }

    /// Converts the grouped item into a `ChainProcess` directed to the render route.
    ///
    /// This wraps the item into an `AnyOutput` and routes it to the render processing pipeline.
    fn to_render(self) -> ChainProcess<Group> {
        AnyOutput::new(self).route_renderer()
    }
}