pub struct PeekEnum<'mem, 'facet> { /* private fields */ }reflect only.Expand description
Lets you read from an enum (implements read-only enum operations)
Implementations§
Source§impl<'mem, 'facet> PeekEnum<'mem, 'facet>
impl<'mem, 'facet> PeekEnum<'mem, 'facet>
Sourcepub fn variant_count(self) -> usize
pub fn variant_count(self) -> usize
Returns the number of variants in this enum
Sourcepub fn variant_name(self, index: usize) -> Option<&'static str>
pub fn variant_name(self, index: usize) -> Option<&'static str>
Returns the variant name at the given index
Sourcepub fn discriminant(self) -> i64
pub fn discriminant(self) -> i64
Returns the discriminant value for the current enum value
Sourcepub fn variant_index(self) -> Result<usize, VariantError>
pub fn variant_index(self) -> Result<usize, VariantError>
Returns the variant index for this enum value
Sourcepub fn active_variant(self) -> Result<&'static Variant, VariantError>
pub fn active_variant(self) -> Result<&'static Variant, VariantError>
Returns the active variant
Sourcepub fn variant_name_active(self) -> Result<&'static str, VariantError>
pub fn variant_name_active(self) -> Result<&'static str, VariantError>
Returns the name of the active variant for this enum value
Sourcepub fn field(
self,
index: usize,
) -> Result<Option<Peek<'mem, 'facet>>, VariantError>
pub fn field( self, index: usize, ) -> Result<Option<Peek<'mem, 'facet>>, VariantError>
Returns a PeekValue handle to a field of a tuple or struct variant by index
Sourcepub fn field_index(
self,
field_name: &str,
) -> Result<Option<usize>, VariantError>
pub fn field_index( self, field_name: &str, ) -> Result<Option<usize>, VariantError>
Returns the index of a field in the active variant by name
Sourcepub fn field_by_name(
self,
field_name: &str,
) -> Result<Option<Peek<'mem, 'facet>>, VariantError>
pub fn field_by_name( self, field_name: &str, ) -> Result<Option<Peek<'mem, 'facet>>, VariantError>
Returns a PeekValue handle to a field of a tuple or struct variant by name
Methods from Deref<Target = Peek<'mem, 'facet>>§
Sourcepub fn vtable(&self) -> &'static ValueVTable
pub fn vtable(&self) -> &'static ValueVTable
Returns the vtable
Sourcepub fn id(&self) -> ValueId
pub fn id(&self) -> ValueId
Returns a unique identifier for this value, usable for cycle detection
Sourcepub fn ptr_eq(&self, other: &Peek<'_, '_>) -> bool
pub fn ptr_eq(&self, other: &Peek<'_, '_>) -> bool
Returns true if the two values are pointer-equal
Sourcepub fn partial_eq(&self, other: &Peek<'_, '_>) -> Result<bool, ReflectError>
pub fn partial_eq(&self, other: &Peek<'_, '_>) -> Result<bool, ReflectError>
Returns true if this scalar is equal to the other scalar
§Returns
false if equality comparison is not supported for this scalar type
Sourcepub fn partial_cmp(
&self,
other: &Peek<'_, '_>,
) -> Result<Option<Ordering>, ReflectError>
pub fn partial_cmp( &self, other: &Peek<'_, '_>, ) -> Result<Option<Ordering>, ReflectError>
Compares this scalar with another and returns their ordering
§Returns
None if comparison is not supported for this scalar type
Sourcepub fn scalar_type(&self) -> Option<ScalarType>
pub fn scalar_type(&self) -> Option<ScalarType>
Get the scalar type if set.
Sourcepub fn get<T>(&self) -> Result<&T, ReflectError>
pub fn get<T>(&self) -> Result<&T, ReflectError>
Sourcepub fn as_str(&self) -> Option<&'mem str>
pub fn as_str(&self) -> Option<&'mem str>
Try to get the value as a string if it’s a string type Returns None if the value is not a string or couldn’t be extracted
Sourcepub fn as_bytes(&self) -> Option<&'mem [u8]>
pub fn as_bytes(&self) -> Option<&'mem [u8]>
Try to get the value as a byte slice if it’s a &u8 type Returns None if the value is not a byte slice or couldn’t be extracted
Sourcepub fn custom_serialization(
&self,
field: Field,
) -> Result<OwnedPeek<'mem>, ReflectError>
Available on crate feature alloc only.
pub fn custom_serialization( &self, field: Field, ) -> Result<OwnedPeek<'mem>, ReflectError>
alloc only.Performs custom serialization of the current peek using the provided field’s metadata.
Returns an OwnedPeek that points to the final type that should be serialized in place
of the current peek.