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;
32pub mod rng;
33mod save;
34mod state;
35mod story;
36pub mod transcript;
37mod value_ops;
38mod vm;
39
40pub use brink_format::{LoadReport, SAVE_FORMAT_VERSION, SaveState, VisitEntry};
41pub use debug::{DebugChoice, DebugFrame, DebugGlobal, DebugRng, DebugSnapshot, DebugVisit};
42pub use error::RuntimeError;
43pub use linker::link;
44pub use locale::{LocaleMode, apply_locale};
45pub use output::{Fragment, OutputPart};
46pub use program::Program;
47pub use rng::{DotNetRng, FastRng, StoryRng};
48pub use state::{ContextAccess, ObservedContext, WriteObserver};
49pub use story::{
50    Choice, Context, ExternalFnHandler, ExternalResult, FallbackHandler, FlowInstance,
51    FunctionEval, Line, Stats, StepOutcome, Story, StorySnapshot, StoryStatus,
52};