pub struct GameOptions {
pub speed: Speed,
pub head_symbol: String,
pub body_symbol: String,
pub snake_length: u16,
pub life: u16,
pub nb_of_fruit: u16,
pub uncaps_fps: bool,
pub classic_mode: bool,
pub save: bool,
pub load: bool,
}
Expand description
Structure holding all the configuration parameters for the game
Fields§
§speed: Speed
Speed of the snake (Slow, Normal, Fast, Tremendous)
Derives ValueEnum
on the enum Speed and enforces the type
clap::ValueEnum
, which automatically handles possible values and displays them in the help message.
Now, clap enforces valid inputs without requiring a manual FromStr
implementation.
head_symbol: String
Snake symbol (emoji or character) Defines short value because doublon, as short and long are by default based on the name of the variable
body_symbol: String
Snake trail symbol (emoji or character)
snake_length: u16
Initial length of the snake
life: u16
Number of lives
nb_of_fruit: u16
Number of fruits in the game
uncaps_fps: bool
Caps to 60 FPS or not
classic_mode: bool
Classic game with only growing snake
save: bool
Save game parameters
load: bool
Load game parameters
Implementations§
Source§impl GameOptions
impl GameOptions
Sourcepub fn initial_position() -> Position
pub fn initial_position() -> Position
Returns the initial snake position
Sourcepub fn load_from_toml<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_toml<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn validate_and_adapt(&mut self)
Trait Implementations§
Source§impl Args for GameOptions
impl Args for GameOptions
Source§fn group_id() -> Option<Id>
fn group_id() -> Option<Id>
Report the [
ArgGroup::id
][crate::ArgGroup::id] for this set of argumentsSource§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Append to [
Command
] so it can instantiate self
via
[FromArgMatches::update_from_arg_matches_mut
] Read moreSource§impl Clone for GameOptions
impl Clone for GameOptions
Source§fn clone(&self) -> GameOptions
fn clone(&self) -> GameOptions
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl CommandFactory for GameOptions
impl CommandFactory for GameOptions
Source§impl Debug for GameOptions
impl Debug for GameOptions
Source§impl Default for GameOptions
impl Default for GameOptions
Source§fn default() -> GameOptions
fn default() -> GameOptions
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for GameOptionswhere
GameOptions: Default,
impl<'de> Deserialize<'de> for GameOptionswhere
GameOptions: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromArgMatches for GameOptions
impl FromArgMatches for GameOptions
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Source§impl Parser for GameOptions
impl Parser for GameOptions
§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
Parse from iterator, [exit][Error::exit] on error.
§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
Parse from iterator, return Err on error.
§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
Update from iterator, [exit][Error::exit] on error. Read more
§fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
Update from iterator, return Err on error.
Auto Trait Implementations§
impl Freeze for GameOptions
impl RefUnwindSafe for GameOptions
impl Send for GameOptions
impl Sync for GameOptions
impl Unpin for GameOptions
impl UnwindSafe for GameOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more