pub enum EnumValue<E>where
E: Enumeration,{
Known(E),
Unknown(i32),
}Expand description
A protobuf enum field value that can hold either a known variant or an
unknown i32 value.
Used for open enums (the default in editions). Open enums accept any
i32 value on the wire, even if it doesn’t correspond to a known variant.
Variants§
Implementations§
Source§impl<E> EnumValue<E>where
E: Enumeration,
impl<E> EnumValue<E>where
E: Enumeration,
Sourcepub fn is_known(&self) -> bool
pub fn is_known(&self) -> bool
Returns true if this is a known enum variant.
This is a shorthand for self.as_known().is_some(), mirroring the
MessageField::is_set pattern.
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Returns true if the wire value was not recognized as a known variant.
Trait Implementations§
Source§impl<E> Debug for EnumValue<E>where
E: Enumeration,
impl<E> Debug for EnumValue<E>where
E: Enumeration,
Source§impl<E> Default for EnumValue<E>where
E: Enumeration,
impl<E> Default for EnumValue<E>where
E: Enumeration,
Source§fn default() -> EnumValue<E>
fn default() -> EnumValue<E>
Returns the default value for this enum field.
Per the protobuf specification, the default value for an enum field is
the variant whose wire value is 0. If 0 is not a defined variant of
E, this returns EnumValue::Unknown(0), which is
the correct protobuf default but may be surprising — the field’s default
is technically an unknown variant.
Source§impl<E> Display for EnumValue<E>where
E: Enumeration,
impl<E> Display for EnumValue<E>where
E: Enumeration,
Source§impl<E> From<E> for EnumValue<E>where
E: Enumeration,
impl<E> From<E> for EnumValue<E>where
E: Enumeration,
Source§impl<E> PartialEq<E> for EnumValue<E>where
E: Enumeration,
Compare an EnumValue directly with a known variant: field == MyEnum::Foo.
impl<E> PartialEq<E> for EnumValue<E>where
E: Enumeration,
Compare an EnumValue directly with a known variant: field == MyEnum::Foo.
Returns true only when self is Known(e) and e == *other.
An Unknown value is never equal to any known variant.
§Asymmetry
Only the EnumValue == E direction is available; the reverse E == EnumValue is not implementable due to the orphan rule. If you need to
compare in that order, use field.as_known() == Some(variant) instead.
Source§impl<E> PartialEq for EnumValue<E>where
E: PartialEq + Enumeration,
impl<E> PartialEq for EnumValue<E>where
E: PartialEq + Enumeration,
impl<E> Copy for EnumValue<E>where
E: Copy + Enumeration,
impl<E> Eq for EnumValue<E>where
E: Eq + Enumeration,
impl<E> StructuralPartialEq for EnumValue<E>where
E: Enumeration,
Auto Trait Implementations§
impl<E> Freeze for EnumValue<E>where
E: Freeze,
impl<E> RefUnwindSafe for EnumValue<E>where
E: RefUnwindSafe,
impl<E> Send for EnumValue<E>where
E: Send,
impl<E> Sync for EnumValue<E>where
E: Sync,
impl<E> Unpin for EnumValue<E>where
E: Unpin,
impl<E> UnsafeUnpin for EnumValue<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for EnumValue<E>where
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request