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.
- 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.
- Observed
Context - A
ContextAccesswrapper that delegates to an innerContextand notifies aWriteObserveron every mutation. - Program
- A linked, ready-to-execute program.
- 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.
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.
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.