micro_web/decorator/
mod.rs1mod decorator_composer;
2mod decorator_fn;
3mod identity;
4
5pub use decorator_composer::DecoratorComposer;
6pub use identity::IdentityDecorator;
7
8pub trait Decorator<In> {
9 type Out;
10
11 fn decorate(&self, raw: In) -> Self::Out;
12}
13
14pub trait DecoratorExt<In>: Decorator<In> {
15 fn and_then<D>(self, decorator: D) -> DecoratorComposer<Self, D>
16 where
17 Self: Sized,
18 {
19 DecoratorComposer::new(self, decorator)
20 }
21
22 fn compose<D>(self, decorator: D) -> DecoratorComposer<D, Self>
23 where
24 Self: Sized,
25 {
26 DecoratorComposer::new(decorator, self)
27 }
28}
29
30impl<T: Decorator<In> + ?Sized, In> DecoratorExt<In> for T {}