Skip to main content

ChoiceParameter

Trait ChoiceParameter 

Source
pub trait ChoiceParameter: Sized {
    // Required methods
    fn list() -> Vec<CommandParameterChoice>;
    fn from_index(index: usize) -> Option<Self>;
    fn from_name(name: &str) -> Option<Self>;
    fn name(&self) -> &'static str;
    fn localized_name(&self, locale: &str) -> Option<&'static str>;
}
Expand description

This trait is implemented by crate::macros::ChoiceParameter. See its docs for more information

Required Methods§

Source

fn list() -> Vec<CommandParameterChoice>

Returns all possible choices for this parameter, in the order they will appear in Discord.

Source

fn from_index(index: usize) -> Option<Self>

Returns an instance of Self corresponding to the given index into Self::list()

Source

fn from_name(name: &str) -> Option<Self>

Parses the name as returned by Self::name() into an instance of Self

Source

fn name(&self) -> &'static str

Returns the non-localized name of this choice

Source

fn localized_name(&self, locale: &str) -> Option<&'static str>

Returns the localized name for the given locale, if one is set

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.

Implementors§