Skip to main content

FromSetting

Trait FromSetting 

Source
pub trait FromSetting<'a>: Sized {
    const EXPECTED: &'static str;

    // Required method
    fn from_setting(value: &'a Document) -> Option<Self>;
}
Expand description

Converts a settings value into a type, optionally borrowing from the document.

Protocols can implement this trait for their own settings types. Return None when the value is invalid; get reports it as a configuration error.

Required Associated Constants§

Source

const EXPECTED: &'static str

The expected type or value, used in configuration error diagnostics.

Required Methods§

Source

fn from_setting(value: &'a Document) -> Option<Self>

Converts a value, returning None if it does not match this type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromSetting<'_> for bool

Source§

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

Source§

fn from_setting(value: &Document) -> Option<Self>

Source§

impl FromSetting<'_> for u64

Source§

const EXPECTED: &'static str = "a non-negative integer"

Source§

fn from_setting(value: &Document) -> Option<Self>

Source§

impl FromSetting<'_> for String

Source§

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

Source§

fn from_setting(value: &Document) -> Option<Self>

Source§

impl<'a> FromSetting<'a> for &'a str

Source§

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

Source§

fn from_setting(value: &'a Document) -> Option<Self>

Implementors§