Skip to main content

Crate brink_runtime

Crate brink_runtime 

Source
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§

pub use rng::DotNetRng;
pub use rng::FastRng;
pub use rng::StoryRng;

Modules§

rng
Pluggable PRNG for story randomization.
transcript
Transcript binary serialization (.brkt format).

Structs§

Choice
A single choice presented to the player.
Context
Shared game state that lives above individual flows.
FallbackHandler
Default handler that always falls back to the ink function body.
FlowInstance
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.
ObservedContext
A ContextAccess wrapper that delegates to an inner Context and notifies a WriteObserver on 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.
StorySnapshot
Owned story state that can be detached from a Program and reattached later.

Enums§

ExternalResult
Result of an external function handler call.
FunctionEval
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.
LocaleMode
Controls how missing scopes are handled when applying a locale overlay.
OutputPart
A part of accumulated output.
RuntimeError
Errors that can occur during story linking or execution.
StepOutcome
Outcome of a single FlowInstance::advance step.
StoryStatus
The current execution status of a story.

Traits§

ContextAccess
Trait for accessing and mutating story execution state.
ExternalFnHandler
Trait for handling external function calls from ink.
WriteObserver
Observer for state mutations during story execution.

Functions§

apply_locale
Apply a locale overlay to a set of base line tables.
link
Link a StoryData into an executable Program.