behavior/actor/
creation.rs1use core::marker::PhantomData;
4
5use super::addressing::Address;
6use crate::verdict::Never;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum CreationKind {
11 Birth,
13 ReplacementIncarnation,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq)]
25pub struct Create<A: Address, New> {
26 pub nonce: A::Nonce,
27 pub child: New,
28 pub kind: CreationKind,
29}
30
31impl<A: Address, New> Create<A, New> {
32 #[must_use]
33 pub const fn birth(nonce: A::Nonce, child: New) -> Self {
34 Self {
35 nonce,
36 child,
37 kind: CreationKind::Birth,
38 }
39 }
40
41 #[must_use]
42 pub const fn replacement_incarnation(nonce: A::Nonce, child: New) -> Self {
43 Self {
44 nonce,
45 child,
46 kind: CreationKind::ReplacementIncarnation,
47 }
48 }
49}
50
51pub trait BirthMode {
53 type Child;
54}
55
56#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
58pub struct NoBirths;
59
60impl BirthMode for NoBirths {
61 type Child = Never;
62}
63
64#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
66pub struct Births<C>(PhantomData<fn() -> C>);
67
68impl<C> BirthMode for Births<C> {
69 type Child = C;
70}