pub struct Runtime { /* private fields */ }Expand description
Bound runtime: dense buffers, topo order, intern tables, stateful rune storage.
Sole executable artifact after bind. Sample senses through PortWriter,
settle with Self::loom, then read Self::outbox.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn reseed(&mut self, seed: Seed)
pub fn reseed(&mut self, seed: Seed)
Restore PRNG stream (room retry). Same mix as bind: seed ^ fnv(weave.id) | 1.
Sourcepub fn sense_id(&self, name: &str) -> Option<SenseId>
pub fn sense_id(&self, name: &str) -> Option<SenseId>
Resolve a SignalIn author name to a dense sense id (setup only).
Sourcepub fn required_sense(&self, name: &str) -> Result<SenseId, RecipeResolveError>
pub fn required_sense(&self, name: &str) -> Result<SenseId, RecipeResolveError>
Resolve a required SignalIn knot for a typed recipe port.
Sourcepub fn knot_id(&self, name: &str) -> Option<KnotHandle>
pub fn knot_id(&self, name: &str) -> Option<KnotHandle>
Resolve an author knot name for checked tooling access.
Sourcepub fn required_knot(
&self,
name: &str,
) -> Result<KnotHandle, RecipeResolveError>
pub fn required_knot( &self, name: &str, ) -> Result<KnotHandle, RecipeResolveError>
Resolve a required author knot for a typed recipe port.
Sourcepub fn path_id(&self, path: &str) -> Option<HostPathId>
pub fn path_id(&self, path: &str) -> Option<HostPathId>
Resolve a SignalOut path string interned at bind.
Sourcepub fn required_path(
&self,
path: &str,
) -> Result<HostPathId, RecipeResolveError>
pub fn required_path( &self, path: &str, ) -> Result<HostPathId, RecipeResolveError>
Resolve a required SignalOut path for a typed recipe port.
Sourcepub fn cmd_id(&self, name: &str) -> Option<CmdId>
pub fn cmd_id(&self, name: &str) -> Option<CmdId>
Resolve an EmitCommand name interned at bind.
Sourcepub fn required_command(&self, name: &str) -> Result<CmdId, RecipeResolveError>
pub fn required_command(&self, name: &str) -> Result<CmdId, RecipeResolveError>
Resolve a required EmitCommand name for a typed recipe port.
Sourcepub fn path_name(&self, id: HostPathId) -> Result<&str, HandleError>
pub fn path_name(&self, id: HostPathId) -> Result<&str, HandleError>
Interned path string for a dense host path id.
Sourcepub fn cmd_name(&self, id: CmdId) -> Result<&str, HandleError>
pub fn cmd_name(&self, id: CmdId) -> Result<&str, HandleError>
Interned emit command name for a dense command id.
Sourcepub fn begin_frame(&mut self, time: HostTime)
pub fn begin_frame(&mut self, time: HostTime)
Start a frame: set tick and clear acts and dropped-emit telemetry.
Sourcepub fn port_writer(&mut self) -> PortWriter<'_>
pub fn port_writer(&mut self) -> PortWriter<'_>
Borrow for host sense writes (set_sense with dense ids only).
Sourcepub fn outbox(&self) -> Outbox<'_>
pub fn outbox(&self) -> Outbox<'_>
Read-only view of acts and dropped-emit telemetry for this frame.
Sourcepub fn outbox_signals_capacity(&self) -> usize
pub fn outbox_signals_capacity(&self) -> usize
Capacity of the SignalOut outbox buffer (reserved at bind).
Sourcepub fn delay_buf_len(&self) -> usize
pub fn delay_buf_len(&self) -> usize
Length of the flat delay ring (sized at bind).
Sourcepub fn get_port_checked(
&self,
knot: KnotHandle,
slot: PortSlot,
) -> Result<Signal, HandleError>
pub fn get_port_checked( &self, knot: KnotHandle, slot: PortSlot, ) -> Result<Signal, HandleError>
Safe OOB-tolerant read (returns ZERO past end). Used by tests and host tooling.
Sourcepub fn set_port_checked(
&mut self,
knot: KnotHandle,
slot: PortSlot,
v: Signal,
) -> Result<(), HandleError>
pub fn set_port_checked( &mut self, knot: KnotHandle, slot: PortSlot, v: Signal, ) -> Result<(), HandleError>
Safe OOB-tolerant write (no-op past end). Used by tests and host tooling.
Sourcepub fn kind_tag_count(&self) -> usize
pub fn kind_tag_count(&self) -> usize
Number of bind-time kind tags (equals knot count after successful bind).
Bind-shape introspection for tests and tooling — not used on the settle hot path.
Sourcepub fn clear_port_index_count(&self) -> usize
pub fn clear_port_index_count(&self) -> usize
Flat clear-index count (all In ports across the weave).
Bind-shape introspection for tests and tooling — not used on the settle hot path.
Sourcepub fn inbound_edge_count(&self) -> usize
pub fn inbound_edge_count(&self) -> usize
CSR inbound edge count.
Bind-shape introspection for tests and tooling — not used on the settle hot path.
Source§impl Runtime
impl Runtime
Sourcepub fn bind_with_preset(
weave: Weave,
opts: BindOpts,
preset: &RuntimePreset,
) -> Result<Self, PresetError>
pub fn bind_with_preset( weave: Weave, opts: BindOpts, preset: &RuntimePreset, ) -> Result<Self, PresetError>
Bind a runtime then apply every named preset entry atomically.
Sourcepub fn inspect_state(&self) -> RuntimeStateReport
pub fn inspect_state(&self) -> RuntimeStateReport
Inspect the current runtime through stable authored names.
Sourcepub fn inspect_checkpoint(
&self,
state: &RuntimeState,
) -> Result<RuntimeStateReport, RestoreError>
pub fn inspect_checkpoint( &self, state: &RuntimeState, ) -> Result<RuntimeStateReport, RestoreError>
Validate and inspect a checkpoint without mutating this runtime.
Sourcepub fn bind_restored(
weave: Weave,
opts: BindOpts,
state: &RuntimeState,
) -> Result<Self, BindRestoreError>
pub fn bind_restored( weave: Weave, opts: BindOpts, state: &RuntimeState, ) -> Result<Self, BindRestoreError>
Bind a completely fresh runtime and atomically restore a checkpoint.
This is the recommended disk-load path. The returned runtime has an empty outbox: effects from the checkpoint frame were already applied by the host before it was saved.
Sourcepub fn snapshot(&self) -> RuntimeState
pub fn snapshot(&self) -> RuntimeState
Snapshot every mutable value needed for deterministic continuation.
Capture only after loom and host apply, before the next
Runtime::begin_frame. Outbox effects are deliberately excluded;
restore resumes stateful memory with an empty outbox.
§Examples
use wyrd::{weave, BindOpts, HostTime, KnotKind, Runtime, SignalDomain, ONE, ZERO};
let weave = weave! {
id: "snapshot.docs";
knots {
input = KnotKind::signal_in(SignalDomain::Bool);
output = KnotKind::signal_out("snapshot.output", SignalDomain::Bool);
}
threads { input.out -> output.in; }
}?;
let mut runtime = Runtime::bind(weave.clone(), BindOpts::default())?;
let input = runtime.required_sense("input")?;
runtime.begin_frame(HostTime { tick: 1 });
runtime.port_writer().set_sense(input, ONE)?;
runtime.loom();
let state = runtime.snapshot();
runtime.begin_frame(HostTime { tick: 2 });
runtime.port_writer().set_sense(input, ZERO)?;
runtime.loom();
assert_eq!(runtime.outbox().signals()[0].value, ZERO);
let restored = Runtime::bind_restored(weave, BindOpts::default(), &state)?;
assert!(restored.outbox().signals().is_empty());Sourcepub fn snapshot_into(&self, state: &mut RuntimeState)
pub fn snapshot_into(&self, state: &mut RuntimeState)
Refresh an existing snapshot while reusing its owned buffer capacity.
Every field is overwritten, so state may come from an incompatible
runtime. Reuse is best-effort: buffers allocate when their retained
capacity is too small and may retain a previous high-water capacity.
Sourcepub fn restore(&mut self, state: &RuntimeState) -> Result<(), RestoreError>
pub fn restore(&mut self, state: &RuntimeState) -> Result<(), RestoreError>
Restore a compatible snapshot without changing runtime-local handles.
Every compatibility and shape check runs before any mutable runtime field is assigned, so a rejected restore leaves the runtime unchanged.
§Errors
Returns RestoreError when the format version, executable
fingerprint, buffer shape, or saved outbox handles are incompatible.
Sourcepub const fn state_format_version() -> u32
pub const fn state_format_version() -> u32
Format version emitted by Self::snapshot.
Sourcepub const fn runtime_fingerprint(&self) -> u64
pub const fn runtime_fingerprint(&self) -> u64
Deterministic immutable compatibility fingerprint for this runtime.