1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// Trait for creating a builder
/// that implements [`BuilderFlow`]
/// for a mediator `M`.
pub trait BuilderInternal<M, Flow>
where
    Flow: BuilderFlow<M>,
    Self: Sized,
{
    fn builder() -> Flow;
}

/// A [`BuilderFlow`] is generic over `M`
/// which is the mediator that will be
/// built by [`BuilderFlow::build()`].
pub trait BuilderFlow<M>
where
    Self: Sized,
{
    fn build(self) -> M;
}

/// Trait for creating a builder
/// that implements [`TryBuilderFlow`]
/// for a mediator `M`.
pub trait TryBuilderInternal<M, Flow>
where
    Flow: TryBuilderFlow<M>,
    Self: Sized,
{
    fn builder() -> Flow;
}

/// A [`TryBuilderFlow`] is generic over `M`
/// which is the mediator that will be tried to be
/// built by [`TryBuilderFlow::build()`].
pub trait TryBuilderFlow<M>
where
    Self: Sized,
{
    type Error;
    fn build(self) -> Result<M, Self::Error>;
}