agner_sup/mixed/child_spec/
flat_mixed_child_spec.rs

1use std::fmt;
2
3use crate::common::gen_child_spec::CreateChild;
4use crate::common::ShutdownSequence;
5use crate::mixed::child_spec::MixedChildSpec;
6use crate::mixed::ChildID;
7
8use super::ChildType;
9
10pub trait FlatMixedChildSpec<ID>:
11    CreateChild<Args = ()> + fmt::Debug + Unpin + Send + Sync + 'static
12{
13    fn id(&self) -> ID;
14    fn child_type(&self) -> ChildType;
15    fn shutdown(&self) -> &ShutdownSequence;
16}
17
18impl<ID, B, A, M> FlatMixedChildSpec<ID> for MixedChildSpec<ID, B, A, M>
19where
20    ID: ChildID,
21    Self: CreateChild<Args = ()>,
22    A: fmt::Debug,
23    B: Unpin + Send + Sync + 'static,
24    A: Unpin + Send + Sync + 'static,
25    M: Unpin + Send + Sync + 'static,
26{
27    fn id(&self) -> ID {
28        self.ext().id
29    }
30    fn child_type(&self) -> ChildType {
31        self.ext().child_type
32    }
33    fn shutdown(&self) -> &ShutdownSequence {
34        &self.ext().shutdown
35    }
36}
37
38impl<ID, B, A, M> From<MixedChildSpec<ID, B, A, M>> for Box<dyn FlatMixedChildSpec<ID>>
39where
40    MixedChildSpec<ID, B, A, M>: FlatMixedChildSpec<ID>,
41{
42    fn from(cs: MixedChildSpec<ID, B, A, M>) -> Self {
43        Box::new(cs)
44    }
45}