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§
Sourcefn from_option_value(
name: &'static str,
option: &CommandDataOptionValue,
) -> Result<Self, ConvertError>
fn from_option_value( name: &'static str, option: &CommandDataOptionValue, ) -> Result<Self, ConvertError>
Parse from an option value
Sourcefn get_expected_data_type() -> DataType
fn get_expected_data_type() -> DataType
The expected data type
Provided Methods§
Sourcefn get_missing_default() -> Option<Self>
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.