Skip to main content

SettingsKey

Struct SettingsKey 

Source
pub struct SettingsKey<T: 'static> {
    pub key: &'static str,
    pub default: fn() -> T,
}
Expand description

A statically-named setting. Centralizes the dotted key, the value type, and the default factory. Construct as a const:

use teksilo_settings::SettingsKey;

const FONT_SIZE: SettingsKey<f32> =
    SettingsKey::new("editor.font_size", || 14.0);

Fields§

§key: &'static str

The dotted TOML path used to look up this setting (e.g. "editor.font_size").

§default: fn() -> T

Factory that produces the default value when the key is absent from disk.

Implementations§

Source§

impl<T: 'static> SettingsKey<T>

Source

pub const fn new(key: &'static str, default: fn() -> T) -> Self

Create a new key descriptor; intended for use in const declarations.

Trait Implementations§

Source§

impl<T: 'static> Debug for SettingsKey<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SettingsKey<T>

§

impl<T> RefUnwindSafe for SettingsKey<T>

§

impl<T> Send for SettingsKey<T>

§

impl<T> Sync for SettingsKey<T>

§

impl<T> Unpin for SettingsKey<T>

§

impl<T> UnsafeUnpin for SettingsKey<T>

§

impl<T> UnwindSafe for SettingsKey<T>

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.