pub trait Enum: Copy + Clone + Eq + PartialEq + Display + Debug {
const NAME: &'static str;
const COUNT: u8;
// Required methods
fn display_name(&self) -> &'static str;
fn identifier_name(&self) -> &'static str;
fn from_u8(byte: u8) -> Option<Self>;
fn into_u8(self) -> u8;
// Provided method
fn iter() -> EnumIterator<Self> ⓘ { ... }
}
Expand description
An enum with limited reflection capabilities.
The name of the enum itself and its variants is available. An iterator over the variants is also provided. The three enums that implement this trait are:
Examples
use tfc::{Key, Enum};
assert_eq!(Key::NAME, "Key");
assert_eq!(Key::PlayPause.identifier_name(), "PlayPause");
assert_eq!(Key::PlayPause.display_name(), "Play/Pause");
Required Associated Constants§
Required Methods§
sourcefn display_name(&self) -> &'static str
fn display_name(&self) -> &'static str
The display name of this enum variant.
This is the name that is appropriate for showing to end users. It may
contain spaces or other symbols and is in Title Case. It is used by the
Display
implementation.
sourcefn identifier_name(&self) -> &'static str
fn identifier_name(&self) -> &'static str
The identifier name of this enum variant.
This is the raw identifier name of the enum variant in PascalCase. It is
used by the Debug
implementation.
Provided Methods§
sourcefn iter() -> EnumIterator<Self> ⓘ
fn iter() -> EnumIterator<Self> ⓘ
Get an iterator over the variants of the enum.
Object Safety§
This trait is not object safe.