pub struct Program { /* private fields */ }Expand description
A compiled dialogue program ready to be executed by the runner.
Implementations§
Source§impl Program
impl Program
Sourcepub fn node_exists(&self, title: &str) -> bool
pub fn node_exists(&self, title: &str) -> bool
Returns true if the program contains a node with the given title.
§Example
let prog = bubbles::compile("title: Start\n---\n===\n").unwrap();
assert!(prog.node_exists("Start"));
assert!(!prog.node_exists("Missing"));Sourcepub fn node_titles(&self) -> impl Iterator<Item = &str>
pub fn node_titles(&self) -> impl Iterator<Item = &str>
Iterates over all node titles in insertion order.
Returns the tags of the first node with the given title, if any.
Sourcepub fn variable_declarations(&self) -> &[VariableDecl]
pub fn variable_declarations(&self) -> &[VariableDecl]
Returns all <<declare>> variable declarations found in the program.
This is useful for save systems that need to enumerate every variable a script declares, and for editor tooling.
§Example
let prog = bubbles::compile(
"title: Start\n---\n<<declare $health = 100>>\n===\n"
).unwrap();
let decls = prog.variable_declarations();
assert_eq!(decls.len(), 1);
assert_eq!(decls[0].name, "$health");
assert_eq!(decls[0].default_src, "100");Trait Implementations§
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
impl UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more