pub enum Error {
Success,
BufferTooShort {
required: usize,
had: usize,
},
InvalidFieldNumber {
field_number: u32,
what: String,
},
UnhandledWireType {
wire_type: u32,
},
TagTooLarge {
tag: u64,
},
VarintOverflow {
bytes: usize,
},
UnsignedOverflow {
value: u64,
},
SignedOverflow {
value: i64,
},
WrongLength {
required: usize,
had: usize,
},
StringEncoding,
UnknownDiscriminant {
discriminant: u32,
},
NotAChar {
value: u32,
},
}Expand description
Error captures the possible error conditions for packing and unpacking.
Variants§
Success
The default error is succes.
BufferTooShort
BufferTooShort indicates that there was a need to pack or unpack more bytes than were available in the underlying memory.
Fields
InvalidFieldNumber
InvalidFieldNumber indicates that the field is not a user-assignable field.
Fields
UnhandledWireType
UnhandledWireType indicates that the wire_type is not understood by this process and cannot be skipped.
TagTooLarge
TagTooLarge indicates the tag would overflow a 32-bit number.
VarintOverflow
VarintOverflow indicates that a varint field did not terminate with a number < 128.
UnsignedOverflow
UnsignedOverflow indicates that a value will not fit its intended (unsigned) target.
SignedOverflow
SignedOverflow indicates that a value will not fit its intended (signed) target.
WrongLength
WrongLength indicates that a bytes32 did not have 32 bytes.
Fields
StringEncoding
StringEncoding indicates that a value is not UTF-8 friendly.
UnknownDiscriminant
UnknownDiscriminant indicates a variant that is not understood by this code.
NotAChar
NotAChar indicates that the prescribed value was tried to unpack as a char, but it’s not a char.
Trait Implementations§
Source§impl FieldPackHelper<'_, message<Error>> for Error
impl FieldPackHelper<'_, message<Error>> for Error
Source§fn field_pack_sz(&self, tag: &Tag) -> usize
fn field_pack_sz(&self, tag: &Tag) -> usize
Source§fn field_pack(&self, tag: &Tag, out: &mut [u8])
fn field_pack(&self, tag: &Tag, out: &mut [u8])
Source§impl FieldUnpackHelper<'_, message<Error>> for Error
impl FieldUnpackHelper<'_, message<Error>> for Error
Source§fn merge_field(&mut self, proto: message<Error>)
fn merge_field(&mut self, proto: message<Error>)
Source§impl Packable for Error
impl Packable for Error
Source§fn pack_sz(&self) -> usize
fn pack_sz(&self) -> usize
pack_sz returns the number of bytes required to serialize the Packable object.Source§fn pack(&self, buf: &mut [u8])
fn pack(&self, buf: &mut [u8])
pack fills in the buffer out with the packed binary representation of the Packable
object. The implementor is responsible to ensure that out is exactly pack_sz() bytes
and implementations are encouraged to assert this. Read moreSource§fn stream<W>(&self, writer: &mut W) -> Result<usize, Error>
fn stream<W>(&self, writer: &mut W) -> Result<usize, Error>
stream writes the object to the provided writer using the same representation that would
be used in a call to pack. The implementor is responsible for making sure that the
number of bytes written is exactly equal to the number of required bytes. Read more