docs/generated/contracts.mdgenerated from code
Reference · 2 min read
trace
Contracts: trace.
Read as
Source: crates/lvcs-runtime/src/trace.rs.
1/// One sml logger callback (discussion:owner/286). Names are static in a running2/// machine and owned once decoded, so a recorded trace and a replayed one3/// compare equal when their names do.4#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]5pub enum Line {6 /// An event entered processing: its generated variant name.7 #[serde(rename = "e")]8 Event(Cow<'static, str>),9 /// The state changed from the first to the second.10 #[serde(rename = "s")]11 State(Cow<'static, str>, Cow<'static, str>),12 /// A guard returned.13 #[serde(rename = "g")]14 Guard(Cow<'static, str>, bool),15 /// An action succeeded.16 #[serde(rename = "a")]17 Action(Cow<'static, str>),18}1920/// The logger of every journaled machine: it records each callback until21/// the step slot takes the trace after the step. The machine's policy holds22/// one clone and its [`Slot`](super::Slot) another.23#[derive(Debug, Clone, Default)]24pub struct Trace {25 /// The callbacks since the last [`take`](Self::take).26 lines: Arc<Mutex<Vec<Line>>>,27 /// Which machine of its kind this is, for a watchdog sample: a28 /// document's address.29 name: Arc<Mutex<Option<String>>>,30}3132/// Where a machine's actions push its outputs: its context holds one clone33/// and its [`Slot`](super::Slot) drains another34/// ([`drain`](Self::drain)). A kind outside this crate keeps its own35/// shared list and gives the slot a closure that drains it.36#[derive(Debug)]37pub struct Outbox<O> {38 /// The outputs pushed since the last take, in push order.39 outputs: Arc<Mutex<Vec<O>>>,40}4142/// The policy of a machine stepped in its caller's thread: the [`Trace`]43/// logger, the growing defer queue ([`crate::Growing`]), and the44/// [`Inline`] scheduler, which journals each step through its slot45/// (discussion:owner/403).46pub type Inlined<E, O, C = ()> = sml::Policies<47 Trace,48 (),49 sml::JumpTable,50 (),51 (),52 crate::Growing,53 sml::DefaultQueuePolicy,54 Inline<E, O, C>,55>;