Skip to main content

Value

Trait Value 

Source
pub trait Value: Sized + Display {
    const EXPECTED: &'static str;

    // Required method
    fn parse(text: &str) -> Option<Self>;

    // Provided method
    fn is_auto(&self) -> bool { ... }
}
Expand description

A setting’s value type: parsed from and shown as the same text.

Required Associated Constants§

Source

const EXPECTED: &'static str

What the text may be, for error messages.

Required Methods§

Source

fn parse(text: &str) -> Option<Self>

The value text spells, or None when it is not one.

Provided Methods§

Source

fn is_auto(&self) -> bool

Computed from the machine rather than given.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Value for bool

Source§

const EXPECTED: &'static str = "on or off"

Source§

fn parse(text: &str) -> Option<bool>

Implementors§

Source§

impl Value for Amount

Source§

const EXPECTED: &'static str = "auto, a size (512M, 4G; a bare number is MiB) or a percentage (25%)"

Source§

impl Value for Bytes

Source§

const EXPECTED: &'static str = "a size (512M, 4G; a bare number is MiB)"

Source§

impl Value for CacheDir

Source§

const EXPECTED: &'static str = "a directory, or default"

Source§

impl Value for Count

Source§

const EXPECTED: &'static str = "auto or a number (0 counts as 1)"

Source§

impl Value for MaybePath

Source§

const EXPECTED: &'static str = "a file, or none"

Source§

impl Value for Millis

Source§

const EXPECTED: &'static str = "a duration (300, 2s; a bare number is milliseconds)"

Source§

impl Value for Name

Source§

const EXPECTED: &'static str = "a name"

Source§

impl Value for Names

Source§

const EXPECTED: &'static str = "names separated by `,` (or none)"

Source§

impl Value for Seconds

Source§

const EXPECTED: &'static str = "a duration (900, 15m; a bare number is seconds)"

Source§

impl Value for Tiers

Source§

const EXPECTED: &'static str = "a list of dex, derived, rendered (or all, none)"