agner_sup/mixed/
child_spec.rs1use crate::common::{GenChildSpec, ShutdownSequence};
2
3mod flat_mixed_child_spec;
4pub use flat_mixed_child_spec::FlatMixedChildSpec;
5
6pub type MixedChildSpec<ID, B, A, M> = GenChildSpec<B, A, M, Ext<ID>>;
7
8pub type BoxedMixedChildSpec<ID> = Box<dyn FlatMixedChildSpec<ID>>;
9
10#[derive(Debug, Clone)]
11pub struct Ext<ID> {
12 id: ID,
13 child_type: ChildType,
14 shutdown: ShutdownSequence,
15}
16
17#[derive(Debug, Clone, Copy)]
18pub enum ChildType {
19 Permanent,
20 Transient,
21 Temporary,
22}
23
24impl<ID> MixedChildSpec<ID, (), (), ()> {
25 pub fn mixed(id: ID) -> Self {
26 let ext = Ext { id, child_type: ChildType::Permanent, shutdown: Default::default() };
27
28 Self::from_ext(ext)
29 }
30}
31impl<ID, B, A, M> MixedChildSpec<ID, B, A, M> {
32 pub fn child_type(mut self, child_type: ChildType) -> Self {
33 self.ext_mut().child_type = child_type;
34 self
35 }
36 pub fn shutdown(mut self, shutdown: ShutdownSequence) -> Self {
37 self.ext_mut().shutdown = shutdown;
38 self
39 }
40}