roopes_core/aggregates/executable_observer/
mod.rs

1//! This module enables conversion between [`Observer`] and [`Executable`].
2#[cfg(test)]
3mod tests;
4
5use crate::prelude::*;
6
7/// Wraps an [`Observer`] such that calls to [`Executable::execute`] are
8/// forwarded to [`Observer::notify`].
9pub struct ExecutableObserver<O>
10where
11    O: Observer,
12{
13    delegate: O,
14}
15
16impl<O> Observer for ExecutableObserver<O>
17where
18    O: Observer,
19{
20    fn notify(&self)
21    {
22        self.delegate.notify();
23    }
24}
25
26impl<O> Executable for ExecutableObserver<O>
27where
28    O: Observer,
29{
30    fn execute(&self)
31    {
32        self.delegate.notify();
33    }
34}
35
36/// Provides types which are exposed at the
37/// library level.
38pub mod prelude
39{
40    pub use super::ExecutableObserver;
41}