Skip to main content

brink_runtime/
lib.rs

1//! Runtime/VM for executing compiled ink stories.
2//!
3//! The runtime takes a [`StoryData`](brink_format::StoryData) from the compiler,
4//! links it into an immutable [`Program`], and executes it via [`Story`].
5//!
6//! ```ignore
7//! let (program, line_tables) = brink_runtime::link(&story_data)?;
8//! let mut story = brink_runtime::Story::new(&program, line_tables);
9//! loop {
10//!     match story.continue_single()? {
11//!         Line::Text { text, .. } => print!("{text}"),
12//!         Line::Choices { text, choices, .. } => {
13//!             print!("{text}");
14//!             // pick a choice...
15//!             story.choose(0)?;
16//!         }
17//!         Line::End { text, .. } => {
18//!             print!("{text}");
19//!             break;
20//!         }
21//!     }
22//! }
23//! ```
24
25mod debug;
26mod error;
27mod linker;
28mod list_ops;
29mod locale;
30mod output;
31mod program;
32mod replay;
33pub mod rng;
34mod save;
35mod state;
36mod story;
37pub mod transcript;
38mod value_ops;
39mod vm;
40
41pub use brink_format::{LoadReport, SAVE_FORMAT_VERSION, SaveState, VisitEntry};
42pub use debug::{DebugChoice, DebugFrame, DebugGlobal, DebugRng, DebugSnapshot, DebugVisit};
43pub use error::RuntimeError;
44pub use linker::link;
45pub use locale::{LocaleMode, apply_locale};
46pub use output::{Fragment, OutputPart};
47pub use program::Program;
48pub use replay::{
49    RECORDING_CAP, RecordedExternal, RecordingHandler, ReplayHandler, ReplayMode, ReplayRecorder,
50};
51pub use rng::{DotNetRng, FastRng, StoryRng};
52pub use state::{ContextAccess, ObservedContext, WriteObserver};
53pub use story::{
54    Choice, Context, ExternalFnHandler, ExternalResult, FallbackHandler, FlowInstance,
55    FunctionEval, Line, Stats, StepOutcome, Story, StorySnapshot, StoryStatus,
56};