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 error;
26mod linker;
27mod list_ops;
28mod locale;
29mod output;
30mod program;
31pub mod rng;
32mod state;
33mod story;
34pub mod transcript;
35mod value_ops;
36mod vm;
37
38pub use error::RuntimeError;
39pub use linker::link;
40pub use locale::{LocaleMode, apply_locale};
41pub use output::{Fragment, OutputPart};
42pub use program::Program;
43pub use rng::{DotNetRng, FastRng, StoryRng};
44pub use state::{ContextAccess, ObservedContext, WriteObserver};
45pub use story::{
46    Choice, Context, ExternalFnHandler, ExternalResult, FallbackHandler, FlowInstance,
47    FunctionEval, Line, Stats, StepOutcome, Story, StorySnapshot, StoryStatus,
48};