Trait FromOptionValue

Source
pub trait FromOptionValue: Sized {
    // Required methods
    fn from_option_value(
        name: &'static str,
        option: &CommandDataOptionValue,
    ) -> Result<Self, ConvertError>;
    fn get_expected_data_type() -> DataType;

    // Provided method
    fn get_missing_default() -> Option<Self> { ... }
}
Expand description

Convert from an option value

Required Methods§

Source

fn from_option_value( name: &'static str, option: &CommandDataOptionValue, ) -> Result<Self, ConvertError>

Parse from an option value

Source

fn get_expected_data_type() -> DataType

The expected data type

Provided Methods§

Source

fn get_missing_default() -> Option<Self>

Kind of a hack to get the default “missing” value if the key was not present.

§Returns

Returns None if this type is not optional.

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 FromOptionValue for bool

Source§

impl FromOptionValue for String

Source§

impl<T> FromOptionValue for Option<T>
where T: FromOptionValue,

Implementors§