use core::marker::PhantomData;
use super::addressing::Address;
use crate::verdict::Never;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CreationKind {
Birth,
ReplacementIncarnation,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Create<A: Address, New> {
pub nonce: A::Nonce,
pub child: New,
pub kind: CreationKind,
}
impl<A: Address, New> Create<A, New> {
#[must_use]
pub const fn birth(nonce: A::Nonce, child: New) -> Self {
Self {
nonce,
child,
kind: CreationKind::Birth,
}
}
#[must_use]
pub const fn replacement_incarnation(nonce: A::Nonce, child: New) -> Self {
Self {
nonce,
child,
kind: CreationKind::ReplacementIncarnation,
}
}
}
pub trait BirthMode {
type Child;
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct NoBirths;
impl BirthMode for NoBirths {
type Child = Never;
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Births<C>(PhantomData<fn() -> C>);
impl<C> BirthMode for Births<C> {
type Child = C;
}