#[non_exhaustive]pub struct Context {
pub core: Core,
pub string_cache: StringCache,
}
Expand description
Stores the State, Rules and Atom mappings for a Throne script.
Create a new Context
using a ContextBuilder.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.core: Core
§string_cache: StringCache
Implementations§
Source§impl Context
impl Context
Sourcepub fn update_with_side_input<F>(&mut self, side_input: F) -> Result<(), Error>where
F: SideInput,
pub fn update_with_side_input<F>(&mut self, side_input: F) -> Result<(), Error>where
F: SideInput,
Equivalent to Context::update(), but accepts a callback to respond to ^
predicates.
Sourcepub fn execute_rule(&mut self, rule: &Rule) -> bool
pub fn execute_rule(&mut self, rule: &Rule) -> bool
Sourcepub fn find_matching_rules<F>(
&self,
side_input: F,
) -> Result<Vec<Rule>, ExcessivePermutationError>where
F: SideInput,
pub fn find_matching_rules<F>(
&self,
side_input: F,
) -> Result<Vec<Rule>, ExcessivePermutationError>where
F: SideInput,
Returns the set of Rules that may be executed in the next update.
Sourcepub fn str_to_atom(&mut self, text: &str) -> Atom
pub fn str_to_atom(&mut self, text: &str) -> Atom
Alias for StringCache::str_to_atom.
Sourcepub fn str_to_existing_atom(&self, text: &str) -> Option<Atom>
pub fn str_to_existing_atom(&self, text: &str) -> Option<Atom>
Alias for StringCache::str_to_existing_atom.
Sourcepub fn atom_to_str(&self, atom: Atom) -> Option<&str>
pub fn atom_to_str(&self, atom: Atom) -> Option<&str>
Alias for StringCache::atom_to_str.
Sourcepub fn atom_to_integer(&self, atom: Atom) -> Option<i32>
pub fn atom_to_integer(&self, atom: Atom) -> Option<i32>
Alias for StringCache::atom_to_integer.
Sourcepub fn push_state(&mut self, phrase_text: &str)
pub fn push_state(&mut self, phrase_text: &str)
Sourcepub fn extend_state_from_context(&mut self, other: &Context)
pub fn extend_state_from_context(&mut self, other: &Context)
Copies the state from another Context
to this one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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