Skip to main content

EnumDescriptor

Struct EnumDescriptor 

Source
pub struct EnumDescriptor { /* private fields */ }
Expand description

Dynamic representation of enum type.

Can be used in reflective operations.

Implementations§

Source§

impl EnumDescriptor

Source

pub fn proto(&self) -> &EnumDescriptorProto

Descriptor objects which defined this enum.

Source

pub fn name(&self) -> &str

Enum name as given in .proto file

Source

pub fn full_name(&self) -> &str

Fully qualified protobuf name of enum

Source

pub fn name_to_package(&self) -> &str

Name relative to the package where the message is declared.

Source

pub fn for_type<E: EnumFull>() -> EnumDescriptor

Get EnumDescriptor object for given enum type

Source

pub fn enclosing_message(&self) -> Option<MessageDescriptor>

Get a message containing this message, or None if this message is declared at file level.

Source

pub fn values<'a>(&'a self) -> impl Iterator<Item = EnumValueDescriptor> + 'a

This enum values

Source

pub fn value_by_name(&self, name: &str) -> Option<EnumValueDescriptor>

Find enum variant by name

Source

pub fn value_by_number(&self, number: i32) -> Option<EnumValueDescriptor>

Find enum variant by number

Source

pub fn value_by_index(&self, index: usize) -> EnumValueDescriptor

Get enum variant by index (as declared in .proto file).

Source

pub fn default_value(&self) -> EnumValueDescriptor

Default enum value (first variant).

Source

pub fn value_by_number_or_default(&self, number: i32) -> EnumValueDescriptor

Find enum variant by number or return default (first) enum value

Source

pub fn is<E: Enum>(&self) -> bool

Check if this enum descriptor corresponds given enum type


let descriptor: EnumDescriptor = Label::enum_descriptor();

assert!(descriptor.is::<Label>())
}

Trait Implementations§

Source§

impl Clone for EnumDescriptor

Source§

fn clone(&self) -> EnumDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EnumDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for EnumDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for EnumDescriptor

Source§

impl Hash for EnumDescriptor

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EnumDescriptor

Source§

fn eq(&self, other: &EnumDescriptor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EnumDescriptor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.