pub trait Enumeration:
Clone
+ Copy
+ PartialEq
+ Eq
+ Hash
+ Debug {
// Required methods
fn from_i32(value: i32) -> Option<Self>;
fn to_i32(&self) -> i32;
fn proto_name(&self) -> &'static str;
// Provided method
fn from_proto_name(_name: &str) -> Option<Self> { ... }
}Expand description
Trait implemented by all generated protobuf enum types.
Required Methods§
Sourcefn from_i32(value: i32) -> Option<Self>
fn from_i32(value: i32) -> Option<Self>
Convert from an i32 wire value to the enum.
Returns Some for known variants, None for unknown values.
Sourcefn proto_name(&self) -> &'static str
fn proto_name(&self) -> &'static str
The name of this enum variant as it appears in the .proto file.
Provided Methods§
Sourcefn from_proto_name(_name: &str) -> Option<Self>
fn from_proto_name(_name: &str) -> Option<Self>
Look up a variant by its protobuf name string.
Returns Some for recognized names, None for unrecognized names.
The default implementation always returns None; generated code
overrides this with a match on all known variant names.
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.