bubbles-dialogue 1.0.0

Lightweight engine-agnostic dialogue runtime for Rust games.
Documentation
//! Lightweight, engine-agnostic dialogue runtime for Rust games.
//!
//! On [crates.io](https://crates.io/crates/bubbles-dialogue) the package is **bubbles-dialogue**
//! because the crate name **bubbles** was already taken there. This library is still named
//! **bubbles**: depend on `bubbles-dialogue` in `Cargo.toml` and `use bubbles::…` in code.
//!
//! Write branching dialogue in `.bub` scripts, compile them once, then drive
//! the dialogue from any game loop via a pull-based event API.
//!
//! # Quick start
//!
//! ```rust
//! use bubbles::{compile, DialogueEvent, HashMapStorage, Runner};
//!
//! let source = "title: Greet\n---\nHello!\n===\n";
//! let prog = compile(source).unwrap();
//! let mut runner = Runner::new(prog, HashMapStorage::new());
//! runner.start("Greet").unwrap();
//!
//! assert!(matches!(
//!     runner.next_event().unwrap(),
//!     Some(DialogueEvent::NodeStarted(_))
//! ));
//! assert!(matches!(
//!     runner.next_event().unwrap(),
//!     Some(DialogueEvent::Line { .. })
//! ));
//! assert!(matches!(
//!     runner.next_event().unwrap(),
//!     Some(DialogueEvent::NodeComplete(_))
//! ));
//! assert!(matches!(
//!     runner.next_event().unwrap(),
//!     Some(DialogueEvent::DialogueComplete)
//! ));
//! ```
//!
//! # Modules
//!
//! | Module | Contents |
//! |--------|----------|
//! | [`value`] | [`Value`], [`VariableStorage`], [`HashMapStorage`] |
//! | [`compiler`] | [`compile`], [`compile_many`], [`validate`], [`Program`], [`VariableDecl`] |
//! | [`runtime`] | [`Runner`], [`RunnerPhase`], [`DialogueEvent`], [`LineMode`], [`LineProvider`], [`line_id_from_tags`], [`line_mode_from_tags`], [`RunnerSnapshot`] |
//! | [`library`] | [`FunctionLibrary`] and built-in functions |
//! | [`saliency`] | [`SaliencyStrategy`], [`FirstAvailable`], [`BestLeastRecentlyViewed`], `RandomAvailable` (`rand` feature) |
//!
//! Lint policy is defined once in `Cargo.toml` under `[lints.rust]` /
//! `[lints.clippy]`; we deliberately do not duplicate it here.

pub mod compiler;
pub mod error;
pub mod library;
pub mod runtime;
pub mod saliency;
pub mod value;

pub use compiler::{Program, VariableDecl, compile, compile_many, validate};
pub use error::{DialogueError, Result};
pub use library::FunctionLibrary;
pub use runtime::RunnerSnapshot;
pub use runtime::{
    DialogueEvent, DialogueOption, HashMapProvider, LineMode, LineProvider, MarkupSpan,
    PassthroughProvider, Runner, RunnerBuilder, RunnerPhase, line_id_from_tags,
    line_mode_from_tags, option_group_from_tags,
};
#[cfg(feature = "rand")]
pub use saliency::RandomAvailable;
pub use saliency::{BestLeastRecentlyViewed, Candidate, FirstAvailable, SaliencyStrategy};
pub use value::{HashMapStorage, Value, VariableStorage};