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§
Sourceconst EXTENDED_VARIANTS: Option<&'static [Self]>
const EXTENDED_VARIANTS: Option<&'static [Self]>
Variants contained in the list of extensions.
Sourceconst DISCRIMINANTS: &'static [(Self, isize)]
const DISCRIMINANTS: &'static [(Self, isize)]
Variants contained in the “root component list” mapped to their respective discriminant.
Sourceconst EXTENDED_DISCRIMINANTS: Option<&'static [(Self, isize)]>
const EXTENDED_DISCRIMINANTS: Option<&'static [(Self, isize)]>
Variants contained in the list of extensions mapped to their respective discriminant, if present.
Sourceconst IDENTIFIERS: &'static [&'static str]
const IDENTIFIERS: &'static [&'static str]
Identifiers of enum variants
Provided Methods§
Sourcefn extended_variance() -> usize
fn extended_variance() -> usize
Returns the number of “extended” variants for a given type.
Sourcefn complete_variance() -> usize
fn complete_variance() -> usize
Returns the number of “root” and “extended” variants for a given type.
Sourcefn is_extended_variant(&self) -> bool
fn is_extended_variant(&self) -> bool
Whether self
is a variant contained in Self::EXTENDED_VARIANTS
.
Sourcefn enumeration_index(&self) -> usize
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.
Sourcefn discriminant(&self) -> isize
fn discriminant(&self) -> isize
Returns the discriminant value of self
.
Sourcefn from_discriminant(value: isize) -> Option<Self>
fn from_discriminant(value: isize) -> Option<Self>
Returns a variant, if the provided discriminant matches any variant.
Sourcefn from_enumeration_index(index: usize) -> Option<Self>
fn from_enumeration_index(index: usize) -> Option<Self>
Returns a variant, if the index matches any “root” variant.
Sourcefn from_extended_enumeration_index(index: usize) -> Option<Self>
fn from_extended_enumeration_index(index: usize) -> Option<Self>
Returns a variant, if the index matches any “extended” variant.
Sourcefn identifier(&self) -> &'static str
fn identifier(&self) -> &'static str
Returns the variant identifier
Sourcefn from_identifier(identifier: &str) -> Option<Self>
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.