pub struct State {
pub game: Option<Game>,
pub functions: Vec<Function>,
pub builtin_types: Vec<(String, String)>,
}Expand description
contains everything needed to run
Fields§
§game: Option<Game>§functions: Vec<Function>§builtin_types: Vec<(String, String)>Implementations§
Source§impl State
impl State
Sourcepub fn new(
functions: Vec<Function>,
builtin_types: Vec<(String, String)>,
) -> Self
pub fn new( functions: Vec<Function>, builtin_types: Vec<(String, String)>, ) -> Self
creates a new state
Sourcepub fn init_random_game(&mut self)
pub fn init_random_game(&mut self)
initializes a new random game from available functions
Sourcepub fn start_game(&self, attempt_url: String) -> StartMessage
pub fn start_game(&self, attempt_url: String) -> StartMessage
starts a new game attempt
Sourcepub fn attempt_game(
&self,
input: &str,
attempts: usize,
) -> Option<AttemptMessage>
pub fn attempt_game( &self, input: &str, attempts: usize, ) -> Option<AttemptMessage>
attempts to guess the function returns None if the guess is invalid (i.e. not a known function)
Sourcepub fn find_function(&self, path: &str) -> Option<&Function>
pub fn find_function(&self, path: &str) -> Option<&Function>
finds a function by its full path (e.g. “lib.mapAttrs”) or name (e.g. “substring” for “builtins.substring” or “flip” for “lib.flip”) returns None if not found
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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