YarnEngine

Struct YarnEngine 

Source
pub struct YarnEngine { /* private fields */ }
Expand description

The engine that stores all conversation-related state.

Implementations§

Source§

impl YarnEngine

Source

pub fn new(handler: Box<dyn YarnHandler>) -> YarnEngine

Create a new YarnEngine instance associated with the given handler.

Source

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.

Source

pub fn register_function( &mut self, name: String, num_args: usize, callback: Box<FunctionCallback>, )

Register a native function for use in Yarn expressions.

Source

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.

Source

pub fn activate(&mut self, node: NodeName)

Begin evaluating the provided Yarn node.

Source

pub fn choose(&mut self, choice: usize)

Make a choice between a series of options for the current Yarn node’s active step. Execution will resume immediately based on the choice provided.

Source

pub fn proceed(&mut self)

Resume execution of the current Yarn node.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.