pub struct YarnEngine { /* private fields */ }Expand description
The engine that stores all conversation-related state.
Implementations§
Source§impl YarnEngine
impl YarnEngine
Sourcepub fn new(handler: Box<dyn YarnHandler>) -> YarnEngine
pub fn new(handler: Box<dyn YarnHandler>) -> YarnEngine
Create a new YarnEngine instance associated with the given handler.
Sourcepub fn load_from_string(&mut self, s: &str) -> Result<(), ()>
pub fn load_from_string(&mut self, s: &str) -> Result<(), ()>
Parse the provided string as a series of Yarn nodes, appending the results to the internal node storage. Returns Ok if parsing succeeded, Err otherwise.
Sourcepub fn register_function(
&mut self,
name: String,
num_args: usize,
callback: Box<FunctionCallback>,
)
pub fn register_function( &mut self, name: String, num_args: usize, callback: Box<FunctionCallback>, )
Register a native function for use in Yarn expressions.
Sourcepub fn set_variable(&mut self, name: VariableName, value: Value)
pub fn set_variable(&mut self, name: VariableName, value: Value)
Set a given variable to the provided value. Any Yarn expressions evaluated after this call will observe the new value when using the variable.
Auto Trait Implementations§
impl Freeze for YarnEngine
impl !RefUnwindSafe for YarnEngine
impl !Send for YarnEngine
impl !Sync for YarnEngine
impl Unpin for YarnEngine
impl !UnwindSafe for YarnEngine
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