Trait Enumerated

Source
pub trait Enumerated:
    Sized
    + 'static
    + PartialEq
    + Copy
    + Debug {
    const VARIANTS: &'static [Self];
    const EXTENDED_VARIANTS: Option<&'static [Self]>;
    const DISCRIMINANTS: &'static [(Self, isize)];
    const EXTENDED_DISCRIMINANTS: Option<&'static [(Self, isize)]>;
    const IDENTIFIERS: &'static [&'static str];

    // Provided methods
    fn variance() -> usize { ... }
    fn extended_variance() -> usize { ... }
    fn complete_variance() -> usize { ... }
    fn is_extended_variant(&self) -> bool { ... }
    fn enumeration_index(&self) -> usize { ... }
    fn discriminant(&self) -> isize { ... }
    fn from_discriminant(value: isize) -> Option<Self> { ... }
    fn from_enumeration_index(index: usize) -> Option<Self> { ... }
    fn from_extended_enumeration_index(index: usize) -> Option<Self> { ... }
    fn identifier(&self) -> &'static str { ... }
    fn from_identifier(identifier: &str) -> Option<Self> { ... }
}
Expand description

A ENUMERATED value.

Required Associated Constants§

Source

const VARIANTS: &'static [Self]

Variants contained in the “root component list”.

Source

const EXTENDED_VARIANTS: Option<&'static [Self]>

Variants contained in the list of extensions.

Source

const DISCRIMINANTS: &'static [(Self, isize)]

Variants contained in the “root component list” mapped to their respective discriminant.

Source

const EXTENDED_DISCRIMINANTS: Option<&'static [(Self, isize)]>

Variants contained in the list of extensions mapped to their respective discriminant, if present.

Source

const IDENTIFIERS: &'static [&'static str]

Identifiers of enum variants

Provided Methods§

Source

fn variance() -> usize

Returns the number of “root” variants for a given type.

Source

fn extended_variance() -> usize

Returns the number of “extended” variants for a given type.

Source

fn complete_variance() -> usize

Returns the number of “root” and “extended” variants for a given type.

Source

fn is_extended_variant(&self) -> bool

Whether self is a variant contained in Self::EXTENDED_VARIANTS.

Source

fn enumeration_index(&self) -> usize

Returns the enumeration for the variant, if it’s an extended variant then it will return it’s extended enumeration index.

Source

fn discriminant(&self) -> isize

Returns the discriminant value of self.

Source

fn from_discriminant(value: isize) -> Option<Self>

Returns a variant, if the provided discriminant matches any variant.

Source

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

Returns a variant, if the index matches any “root” variant.

Source

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

Returns a variant, if the index matches any “extended” variant.

Source

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

Returns the variant identifier

Source

fn from_identifier(identifier: &str) -> Option<Self>

Returns a variant, if the provided identifier matches any variant.

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§