Enum prost_reflect::MapKey
source · pub enum MapKey {
Bool(bool),
I32(i32),
I64(i64),
U32(u32),
U64(u64),
String(String),
}
Expand description
A dynamically-typed key for a protobuf map.
Variants§
Bool(bool)
A boolean value, encoded as the bool
protobuf type.
I32(i32)
A 32-bit signed integer, encoded as one of the int32
, sint32
or sfixed32
protobuf types.
I64(i64)
A 64-bit signed integer, encoded as one of the int64
, sint64
or sfixed64
protobuf types.
U32(u32)
A 32-bit unsigned integer, encoded as one of the uint32
or ufixed32
protobuf types.
U64(u64)
A 64-bit unsigned integer, encoded as one of the uint64
or ufixed64
protobuf types.
String(String)
A string, encoded as the string
protobuf type.
Implementations§
source§impl MapKey
impl MapKey
sourcepub fn default_value(kind: &Kind) -> Self
pub fn default_value(kind: &Kind) -> Self
Returns the default value for the given protobuf type kind
.
Panics
Panics if kind
is not a valid map key type (an integral type or string).
sourcepub fn is_default(&self, kind: &Kind) -> bool
pub fn is_default(&self, kind: &Kind) -> bool
Returns true
if this is the default value for the given protobuf type kind
.
Panics
Panics if kind
is not a valid map key type (an integral type or string).
sourcepub fn is_valid(&self, kind: &Kind) -> bool
pub fn is_valid(&self, kind: &Kind) -> bool
Returns true
if this map key can be encoded as the given Kind
.
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the value if it is a MapKey::Bool
, or None
if it is any other type.
sourcepub fn as_bool_mut(&mut self) -> Option<&mut bool>
pub fn as_bool_mut(&mut self) -> Option<&mut bool>
Returns a mutable reference to the value if it is a MapKey::Bool
, or None
if it is any other type.
sourcepub fn as_u32(&self) -> Option<u32>
pub fn as_u32(&self) -> Option<u32>
Returns the value if it is a MapKey::U32
, or None
if it is any other type.
sourcepub fn as_u32_mut(&mut self) -> Option<&mut u32>
pub fn as_u32_mut(&mut self) -> Option<&mut u32>
Returns a mutable reference to the value if it is a MapKey::U32
, or None
if it is any other type.
sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns the value if it is a MapKey::U64
, or None
if it is any other type.
sourcepub fn as_u64_mut(&mut self) -> Option<&mut u64>
pub fn as_u64_mut(&mut self) -> Option<&mut u64>
Returns a mutable reference to the value if it is a MapKey::U64
, or None
if it is any other type.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns the value if it is a MapKey::I64
, or None
if it is any other type.
sourcepub fn as_i64_mut(&mut self) -> Option<&mut i64>
pub fn as_i64_mut(&mut self) -> Option<&mut i64>
Returns a mutable reference to the value if it is a MapKey::I64
, or None
if it is any other type.
sourcepub fn as_i32(&self) -> Option<i32>
pub fn as_i32(&self) -> Option<i32>
Returns the value if it is a MapKey::I32
, or None
if it is any other type.
sourcepub fn as_i32_mut(&mut self) -> Option<&mut i32>
pub fn as_i32_mut(&mut self) -> Option<&mut i32>
Returns a mutable reference to the value if it is a MapKey::I32
, or None
if it is any other type.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the value if it is a MapKey::String
, or None
if it is any other type.
sourcepub fn as_string_mut(&mut self) -> Option<&mut String>
pub fn as_string_mut(&mut self) -> Option<&mut String>
Returns a mutable reference to the value if it is a MapKey::String
, or None
if it is any other type.
Trait Implementations§
source§impl Ord for MapKey
impl Ord for MapKey
source§impl PartialEq<MapKey> for MapKey
impl PartialEq<MapKey> for MapKey
source§impl PartialOrd<MapKey> for MapKey
impl PartialOrd<MapKey> for MapKey
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more