pub enum DecodeError {
BufferUnderflow,
MissingField {
ty: &'static str,
field: &'static str,
},
DuplicateField {
ty: &'static str,
field: &'static str,
tag: u8,
},
UnknownWireType {
ty: &'static str,
value: u8,
tag: u8,
},
UnknownTag {
ty: &'static str,
tag: u8,
},
LengthDelimitedOverflow,
Custom(Cow<'static, str>),
}Expand description
A message decoding error.
DecodeError indicates that the input buffer does not contain a valid
message. The error details should be considered ‘best effort’: in
general it is not possible to exactly pinpoint why data is malformed.
Variants§
BufferUnderflow
Returned when the buffer does not have enough data to decode the message.
MissingField
Returned when the buffer does not contain the required field.
DuplicateField
Returned when the buffer contains duplicate fields for the same tag in a message.
Fields
UnknownWireType
Returned when there is a unknown wire type.
Fields
UnknownTag
Returned when finding a unknown tag.
LengthDelimitedOverflow
Returned when fail to decode the length-delimited
Custom(Cow<'static, str>)
A custom decoding error.
Implementations§
Source§impl DecodeError
impl DecodeError
Sourcepub const fn is_buffer_underflow(&self) -> bool
pub const fn is_buffer_underflow(&self) -> bool
Returns true if this value is of type BufferUnderflow. Returns false otherwise
Sourcepub const fn is_missing_field(&self) -> bool
pub const fn is_missing_field(&self) -> bool
Returns true if this value is of type MissingField. Returns false otherwise
Sourcepub const fn is_duplicate_field(&self) -> bool
pub const fn is_duplicate_field(&self) -> bool
Returns true if this value is of type DuplicateField. Returns false otherwise
Sourcepub const fn is_unknown_wire_type(&self) -> bool
pub const fn is_unknown_wire_type(&self) -> bool
Returns true if this value is of type UnknownWireType. Returns false otherwise
Sourcepub const fn is_unknown_tag(&self) -> bool
pub const fn is_unknown_tag(&self) -> bool
Returns true if this value is of type UnknownTag. Returns false otherwise
Sourcepub const fn is_length_delimited_overflow(&self) -> bool
pub const fn is_length_delimited_overflow(&self) -> bool
Returns true if this value is of type LengthDelimitedOverflow. Returns false otherwise
Source§impl DecodeError
impl DecodeError
Sourcepub const fn buffer_underflow() -> Self
pub const fn buffer_underflow() -> Self
Creates a new buffer underflow decoding error.
Sourcepub const fn missing_field(ty: &'static str, field: &'static str) -> Self
pub const fn missing_field(ty: &'static str, field: &'static str) -> Self
Creates a new missing field decoding error.
Sourcepub const fn duplicate_field(
ty: &'static str,
field: &'static str,
tag: u8,
) -> Self
pub const fn duplicate_field( ty: &'static str, field: &'static str, tag: u8, ) -> Self
Creates a new duplicate field decoding error.
Sourcepub const fn unknown_wire_type(ty: &'static str, value: u8, tag: u8) -> Self
pub const fn unknown_wire_type(ty: &'static str, value: u8, tag: u8) -> Self
Creates a new unknown wire type decoding error.
Sourcepub const fn unknown_tag(ty: &'static str, tag: u8) -> Self
pub const fn unknown_tag(ty: &'static str, tag: u8) -> Self
Creates a new unknown tag decoding error.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§fn clone(&self) -> DecodeError
fn clone(&self) -> DecodeError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ConstDecodeError> for DecodeError
impl From<ConstDecodeError> for DecodeError
Source§fn from(e: ConstDecodeError) -> Self
fn from(e: ConstDecodeError) -> Self
Source§impl From<DecodeError> for DecodeError
impl From<DecodeError> for DecodeError
Source§fn from(e: DecodeError) -> Self
fn from(e: DecodeError) -> Self
Source§impl From<DecodeError> for ProtoDecoderError
impl From<DecodeError> for ProtoDecoderError
Source§fn from(source: DecodeError) -> Self
fn from(source: DecodeError) -> Self
Source§impl PartialEq for DecodeError
impl PartialEq for DecodeError
impl Eq for DecodeError
impl StructuralPartialEq for DecodeError
Auto Trait Implementations§
impl Freeze for DecodeError
impl RefUnwindSafe for DecodeError
impl Send for DecodeError
impl Sync for DecodeError
impl Unpin for DecodeError
impl UnwindSafe for DecodeError
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<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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more