Skip to main content

RowValue

Enum RowValue 

Source
#[non_exhaustive]
pub enum RowValue<G: GameData> {
#[non_exhaustive]
Toggle { get: fn(&Ctx<G>) -> bool, set: fn(&mut Ctx<G>, bool) -> bool, },
#[non_exhaustive]
Choice { values: fn(&Ctx<G>) -> Vec<&'static str>, get: fn(&Ctx<G>) -> usize, set: fn(&mut Ctx<G>, usize) -> bool, shown: Option<fn(&Ctx<G>) -> String>, },
#[non_exhaustive]
Volume { get: fn(&Ctx<G>) -> u8, set: fn(&mut Ctx<G>, u8) -> bool, },
#[non_exhaustive]
Action { value: fn(&Ctx<G>) -> Option<String>, confirm: fn(&mut Ctx<G>) -> RowAction<G>, help: fn(&Ctx<G>) -> &'static str, }, }
Expand description

What a row shows beside its label, and what changes it. Build it with RowValue::toggle, choice, volume or action: kinds of row and their fields may come, and never break a game (ADR-0039).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
Toggle

On or off: the cursor’s left key turns it off, the right key on, Confirm the other way.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§get: fn(&Ctx<G>) -> bool

Whether it is on.

§set: fn(&mut Ctx<G>, bool) -> bool

Turns it on or off; whether anything changed.

§

#[non_exhaustive]
Choice

One of several values: the cursor’s keys step through them, stopping at the ends, and Confirm goes round.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§values: fn(&Ctx<G>) -> Vec<&'static str>

The text keys of the values offered, in the order they step.

§get: fn(&Ctx<G>) -> usize

Which of them the row shows.

§set: fn(&mut Ctx<G>, usize) -> bool

Puts value i in; whether anything changed.

§shown: Option<fn(&Ctx<G>) -> String>

What the row shows, if not the text of its value’s key: a value with a number in it (the frame cap’s “60 FPS”).

§

#[non_exhaustive]
Volume

A volume, 0 to MAX_VOLUME: the keys move its slider by VOLUME_STEP, Confirm opens a box to type the number.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§get: fn(&Ctx<G>) -> u8

The volume.

§set: fn(&mut Ctx<G>, u8) -> bool

Sets it; whether anything changed.

§

#[non_exhaustive]
Action

Something Confirm does.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§value: fn(&Ctx<G>) -> Option<String>

What the row shows beside its label, if anything (the layout in use, say).

§confirm: fn(&mut Ctx<G>) -> RowAction<G>

What Confirm on it does.

§help: fn(&Ctx<G>) -> &'static str

The text key of the help line while it has the focus.

Implementations§

Source§

impl<G: GameData> RowValue<G>

Source

pub const fn toggle( get: fn(&Ctx<G>) -> bool, set: fn(&mut Ctx<G>, bool) -> bool, ) -> Self

An on-or-off row: get says whether it is on, set turns it on or off.

Source

pub const fn choice( values: fn(&Ctx<G>) -> Vec<&'static str>, get: fn(&Ctx<G>) -> usize, set: fn(&mut Ctx<G>, usize) -> bool, ) -> Self

A row of one of values: get says which it shows, set puts one in.

Source

pub const fn choice_shown( values: fn(&Ctx<G>) -> Vec<&'static str>, get: fn(&Ctx<G>) -> usize, set: fn(&mut Ctx<G>, usize) -> bool, shown: fn(&Ctx<G>) -> String, ) -> Self

A row of one of values, as choice is, that shows what shown says rather than the text of its value’s key: a value with a number in it.

Source

pub const fn volume( get: fn(&Ctx<G>) -> u8, set: fn(&mut Ctx<G>, u8) -> bool, ) -> Self

A volume row: get reads the volume, set sets it.

Source

pub const fn action( value: fn(&Ctx<G>) -> Option<String>, confirm: fn(&mut Ctx<G>) -> RowAction<G>, help: fn(&Ctx<G>) -> &'static str, ) -> Self

A row Confirm does confirm on, showing value beside its label and help while it has the focus.

Auto Trait Implementations§

§

impl<G> Freeze for RowValue<G>

§

impl<G> RefUnwindSafe for RowValue<G>

§

impl<G> Send for RowValue<G>

§

impl<G> Sync for RowValue<G>

§

impl<G> Unpin for RowValue<G>

§

impl<G> UnsafeUnpin for RowValue<G>

§

impl<G> UnwindSafe for RowValue<G>

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.