mm1_sup/
mixed.rs

1pub mod decider;
2pub mod strategy;
3
4mod spec_builder;
5mod sup_actor;
6mod sup_child;
7
8use std::pin::Pin;
9use std::sync::Arc;
10
11use mm1_core::context::{Fork, InitDone, Linking, Messaging, Now, Quit, Start, Stop, Watching};
12pub use sup_actor::{MixedSupError, mixed_sup};
13
14use crate::common::factory::ActorFactory;
15
16pub trait MixedSupContext<Runnable>:
17    Fork
18    + InitDone
19    + Linking
20    + Messaging
21    + Now<Instant = tokio::time::Instant>
22    + Quit
23    + Start<Runnable>
24    + Stop
25    + Watching
26{
27}
28impl<Ctx, Runnable> MixedSupContext<Runnable> for Ctx where
29    Ctx: Fork
30        + InitDone
31        + Linking
32        + Messaging
33        + Now<Instant = tokio::time::Instant>
34        + Quit
35        + Start<Runnable>
36        + Stop
37        + Watching
38{
39}
40
41#[derive(Debug, Clone, Copy)]
42pub enum ChildType {
43    Permanent,
44    Transient,
45    Temporary,
46}
47
48pub struct MixedSup<RS, C> {
49    restart_strategy: RS,
50    children:         C,
51}
52
53pub type ErasedActorFactory<R> = Pin<Arc<dyn ActorFactory<Args = (), Runnable = R>>>;
54
55impl<RS> MixedSup<RS, ()> {
56    pub fn new(restart_strategy: RS) -> Self {
57        Self {
58            restart_strategy,
59            children: (),
60        }
61    }
62}