use pipecircuit::{StateMachine, StepInputOf};
use crate::domain_primitives::Activation;
#[derive(Default)]
pub struct Latch {
active: bool,
}
#[cfg_attr(feature = "wire", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
all(feature = "typescript-generation", not(target_arch = "wasm32")),
derive(postcard_bindgen::PostcardBindings)
)]
#[derive(Debug)]
pub struct Activate;
impl StateMachine for Latch {}
impl StepInputOf<Latch> for Activate {
type Outcome = Activation;
fn step(self, latch: &mut Latch) -> Activation {
if latch.active {
Activation::AlreadyActive
} else {
latch.active = true;
Activation::Activated
}
}
}
#[cfg(test)]
mod architecture;
#[cfg(test)]
mod behavior;
#[cfg(test)]
mod tests;