Trait protobuf::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.

Object Safety§

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] = _