Expand description
Runtime/VM for executing compiled ink stories.
The runtime takes a StoryData from the compiler,
links it into an immutable Program, and executes it via Story.
ⓘ
let (program, line_tables) = brink_runtime::link(&story_data)?;
let mut story = brink_runtime::Story::new(&program, line_tables);
loop {
match story.continue_single()? {
Line::Text { text, .. } => print!("{text}"),
Line::Choices { text, choices, .. } => {
print!("{text}");
// pick a choice...
story.choose(0)?;
}
Line::End { text, .. } => {
print!("{text}");
break;
}
}
}Re-exports§
Modules§
- rng
- Pluggable PRNG for story randomization.
- transcript
- Transcript binary serialization (
.brktformat).
Structs§
- Choice
- A single choice presented to the player.
- Context
- Shared game state that lives above individual flows.
- Debug
Choice - A pending choice and the knot it targets.
- Debug
Frame - One call frame, resolved to a knot/stitch path.
- Debug
Global - A global variable and its current value.
- Debug
Rng - Story RNG state.
- Debug
Snapshot - A structured, read-only snapshot of the runtime’s current state.
- Debug
Visit - A visit count for a named knot/stitch.
- Fallback
Handler - Default handler that always falls back to the ink function body.
- Flow
Instance - A single independent execution context within a story. The default flow
runs from the root container; named flows can be spawned at arbitrary
entry points via
FlowInstance::new_at. - Fragment
- A finalized fragment — structural output parts plus any associated tags.
- Load
Report - What
Story::load_statecouldn’t apply, so a host can surface it rather than have data silently vanish. Globals whose name no longer exists are dropped (no slot to hold them) and reported here. Visit/turn counts are never dropped — counts for scopes the current program lacks are retained harmlessly (unused until/unless the scope returns), so they aren’t reported. - Observed
Context - A
ContextAccesswrapper that delegates to an innerContextand notifies aWriteObserveron every mutation. - Program
- A linked, ready-to-execute program.
- Save
State - A persistent, name-keyed snapshot of a story’s game state.
- Stats
- Lightweight counters tracking VM activity over a story’s lifetime.
- Story
- Per-instance mutable state for executing stories.
- Story
Snapshot - Owned story state that can be detached from a
Programand reattached later. - Visit
Entry - One visit/turn-count entry: a scope id and its count, plus (when the scope
is a named knot/stitch) an advisory author path for human inspection. The
idis the load key;pathis cosmetic.
Enums§
- External
Result - Result of an external function handler call.
- Function
Eval - Outcome of an engine→ink function evaluation
(
FlowInstance::begin_function_eval/resume_function_eval). - Line
- A single step of story output from
Story::continue_single. - Locale
Mode - Controls how missing scopes are handled when applying a locale overlay.
- Output
Part - A part of accumulated output.
- Runtime
Error - Errors that can occur during story linking or execution.
- Step
Outcome - Outcome of a single
FlowInstance::advancestep. - Story
Status - The current execution status of a story.
Constants§
- SAVE_
FORMAT_ VERSION - Current
SaveStateformat version. Bump when the format changes (independent of the story’s own content);versionlets a loader migrate.
Traits§
- Context
Access - Trait for accessing and mutating story execution state.
- External
FnHandler - Trait for handling external function calls from ink.
- Write
Observer - Observer for state mutations during story execution.
Functions§
- apply_
locale - Apply a locale overlay to a set of base line tables.
- link
- Link a
StoryDatainto an executableProgram.