RiveScript

Struct RiveScript 

Source
pub struct RiveScript {
    pub debug: bool,
    pub utf8: bool,
    pub depth: i32,
    /* private fields */
}
Expand description

RiveScript represents a single chatbot personality in memory.

Fields§

§debug: bool§utf8: bool§depth: i32

Implementations§

Source§

impl RiveScript

Source

pub fn new() -> Self

Initialize a new RiveScript chatbot personality.

A single instance of RiveScript is able to have its own set of responses (“brain”) independently of other instances of RiveScript. Also, by default, RiveScript keeps track of temporary user variables (such as recent reply history and any variables the bot has learned about them) at in local memory of this instance, with each instance keeping its own separate data store.

Source

pub fn load_directory(&self, path: &str) -> Result<bool, Box<dyn Error>>

Load a directory of RiveScript documents (.rive or .rs extension) from a folder on disk. Example

    let mut bot = RiveScript::new();
    bot.load_directory("./eg/brain").expect("Couldn't load directory!");
Source

pub fn load_file(&self, path: &str) -> Result<bool, Box<dyn Error>>

Load a RiveScript document by filename on disk. Example

    let mut bot = RiveScript::new();
    bot.load_file("./eg/brain/eliza.rive").expect("Couldn't load file from disk!");
Source

pub fn stream(&self, source: String) -> Result<bool, Box<dyn Error>>

Stream a string containing RiveScript syntax into the bot, rather than read from the filesystem. Example

    let mut bot = RiveScript::new();
    let code = String::from(
        "
        + hello bot
        - Hello, human!
        ",
    );
    bot.stream(code).expect("Couldn't parse code!");
Source

pub fn sort_triggers(&self)

After loading RiveScript source documents, this function will pre-populate sort buffers in memory.

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.