23 lines
511 B
Rust
23 lines
511 B
Rust
use core::cmp::Eq;
|
|
|
|
pub trait FlowData: Clone + Eq {}
|
|
|
|
impl<T> FlowData for T where T: Clone + Eq {}
|
|
|
|
/// This trait must be implemented for any type which should be used as an event
|
|
pub trait Event {
|
|
type Data: FlowData;
|
|
type Err;
|
|
|
|
fn run(&self, data: &mut Self::Data) -> Result<(), Self::Err>;
|
|
}
|
|
|
|
impl<T: Event> Event for [T] {
|
|
type Data = T::Data;
|
|
type Err = T::Err;
|
|
|
|
fn run(&self, data: &mut T::Data) -> Result<(), T::Err> {
|
|
self.iter().try_for_each(|i| i.run(data))
|
|
}
|
|
}
|