#[repr(u8)]pub enum WireType {
Fixed1Byte = 0,
Fixed2Byte = 1,
Fixed4Byte = 2,
Fixed8Byte = 3,
Fixed16Byte = 4,
VarInt = 5,
LengthPrefixed = 6,
List = 7,
}Expand description
A wire type.
The discriminants are the on-wire encoding of the wire type — they appear in the high or low 3 bits of header bytes throughout the format. Do not reorder or change them without breaking wire compatibility.
Variants§
Fixed1Byte = 0
A fixed 1-byte of data.
Fixed2Byte = 1
A fixed 2-bytes of data.
Fixed4Byte = 2
A fixed 4-bytes of data.
Fixed8Byte = 3
A fixed 8-bytes of data.
Fixed16Byte = 4
A fixed 16-bytes of data.
VarInt = 5
A variable-length encoded integer.
LengthPrefixed = 6
A variable-length encoded integer n followed by n bytes.
List = 7
A wire-type w dual-encoded with a var-primitive n, followed by n bytes. The n bytes are
x sequential instances of w where x is unknown (until the list is decoded).
Implementations§
Source§impl WireType
Bits
impl WireType
Bits
Sourcepub fn from_low_3_bits(b: u8) -> Self
pub fn from_low_3_bits(b: u8) -> Self
Gets the wire type from the low 3-bits of b.
Sourcepub fn from_high_3_bits(b: u8) -> Self
pub fn from_high_3_bits(b: u8) -> Self
Gets the wire type from the high 3-bits of b.
Sourcepub fn to_low_3_bits(self) -> u8
pub fn to_low_3_bits(self) -> u8
Converts the wire type to the low 3-bits of a u8.
Sourcepub fn to_high_3_bits(self) -> u8
pub fn to_high_3_bits(self) -> u8
Converts the wire type to the high 3-bits of a u8.
Source§impl WireType
Decode
impl WireType
Decode
Sourcepub fn decode_fixed_2_byte<R>(r: &mut R, first: u8) -> Result<[u8; 2], Error>where
R: Read,
pub fn decode_fixed_2_byte<R>(r: &mut R, first: u8) -> Result<[u8; 2], Error>where
R: Read,
Decodes a Fixed2Byte value from the Read prefix given the first byte.
Sourcepub fn decode_fixed_4_byte<R>(r: &mut R, first: u8) -> Result<[u8; 4], Error>where
R: Read,
pub fn decode_fixed_4_byte<R>(r: &mut R, first: u8) -> Result<[u8; 4], Error>where
R: Read,
Decodes a Fixed4Byte value from the Read prefix given the first byte.
Sourcepub fn decode_fixed_8_byte<R>(r: &mut R, first: u8) -> Result<[u8; 8], Error>where
R: Read,
pub fn decode_fixed_8_byte<R>(r: &mut R, first: u8) -> Result<[u8; 8], Error>where
R: Read,
Decodes a Fixed8Byte value from the Read prefix given the first byte.
Sourcepub fn decode_fixed_16_byte<R>(r: &mut R, first: u8) -> Result<[u8; 16], Error>where
R: Read,
pub fn decode_fixed_16_byte<R>(r: &mut R, first: u8) -> Result<[u8; 16], Error>where
R: Read,
Decodes a Fixed16Byte value from the Read prefix given the first byte.
Sourcepub fn decode_length_prefixed_bytes<R>(
r: &mut R,
first: u8,
) -> Result<Vec<u8>, DecodingError>where
R: Read,
pub fn decode_length_prefixed_bytes<R>(
r: &mut R,
first: u8,
) -> Result<Vec<u8>, DecodingError>where
R: Read,
Decodes a LengthPrefixed []u8 value from the Read prefix given the first byte.
Trait Implementations§
Source§impl Ord for WireType
impl Ord for WireType
Source§impl PartialOrd for WireType
impl PartialOrd for WireType
impl Copy for WireType
impl Eq for WireType
impl StructuralPartialEq for WireType
Auto Trait Implementations§
impl Freeze for WireType
impl RefUnwindSafe for WireType
impl Send for WireType
impl Sync for WireType
impl Unpin for WireType
impl UnsafeUnpin for WireType
impl UnwindSafe for WireType
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> Comparable<K> for Q
impl<Q, K> Comparable<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.