protobuf

Trait Enum

Source
pub trait Enum:
    Eq
    + Sized
    + Copy
    + Debug
    + Default
    + Send
    + Sync
    + 'static {
    const NAME: &'static str;
    const VALUES: &'static [Self] = _;

    // Required methods
    fn value(&self) -> i32;
    fn from_i32(v: i32) -> Option<Self>;
    fn from_str(s: &str) -> Option<Self>;
}
Expand description

Trait implemented by all protobuf enum types.

Additionally, generated enums also implement EnumFull trait, which provides access to reflection.

Required Associated Constants§

Source

const NAME: &'static str

Enum name as specified in .proto file.

There’s full reflection when non-lite runtime code generation is used, and enums implement EnumFull trait. This operation is for lite runtime.

Provided Associated Constants§

Source

const VALUES: &'static [Self] = _

All enum values for enum type.

Required Methods§

Source

fn value(&self) -> i32

Get enum i32 value.

Source

fn from_i32(v: i32) -> Option<Self>

Try to create an enum from i32 value. Return None if value is unknown.

Source

fn from_str(s: &str) -> Option<Self>

Try to create an enum from &str value. Return None if str is unknown.

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§

Source§

impl Enum for Label

Source§

const NAME: &'static str = "Label"

Source§

const VALUES: &'static [Label] = _

Source§

impl Enum for Type

Source§

const NAME: &'static str = "Type"

Source§

const VALUES: &'static [Type] = _

Source§

impl Enum for CType

Source§

const NAME: &'static str = "CType"

Source§

const VALUES: &'static [CType] = _

Source§

impl Enum for JSType

Source§

const NAME: &'static str = "JSType"

Source§

const VALUES: &'static [JSType] = _

Source§

impl Enum for OptimizeMode

Source§

const NAME: &'static str = "OptimizeMode"

Source§

const VALUES: &'static [OptimizeMode] = _

Source§

impl Enum for IdempotencyLevel

Source§

const NAME: &'static str = "IdempotencyLevel"

Source§

const VALUES: &'static [IdempotencyLevel] = _

Source§

impl Enum for Feature

Source§

const NAME: &'static str = "Feature"

Source§

const VALUES: &'static [Feature] = _

Source§

impl Enum for NullValue

Source§

const NAME: &'static str = "NullValue"

Source§

const VALUES: &'static [NullValue] = _

Source§

impl Enum for Syntax

Source§

const NAME: &'static str = "Syntax"

Source§

const VALUES: &'static [Syntax] = _

Source§

impl Enum for Cardinality

Source§

const NAME: &'static str = "Cardinality"

Source§

const VALUES: &'static [Cardinality] = _

Source§

impl Enum for Kind

Source§

const NAME: &'static str = "Kind"

Source§

const VALUES: &'static [Kind] = _