ThriftCompactInputProtocol

Trait ThriftCompactInputProtocol 

Source
pub(crate) trait ThriftCompactInputProtocol<'a> {
Show 21 methods // Required methods fn read_byte(&mut self) -> Result<u8>; fn read_bytes(&mut self) -> Result<&'a [u8]>; fn read_bytes_owned(&mut self) -> Result<Vec<u8>>; fn skip_bytes(&mut self, n: usize) -> Result<()>; fn read_double(&mut self) -> Result<f64>; // Provided methods fn read_vlq(&mut self) -> Result<u64> { ... } fn read_zig_zag(&mut self) -> Result<i64> { ... } fn read_list_begin(&mut self) -> Result<ListIdentifier> { ... } fn read_field_begin( &mut self, last_field_id: i16, ) -> Result<FieldIdentifier> { ... } fn read_field_header(&mut self) -> Result<(u8, u8)> { ... } fn read_bool(&mut self) -> Result<bool> { ... } fn read_string(&mut self) -> Result<&'a str> { ... } fn read_i8(&mut self) -> Result<i8> { ... } fn read_i16(&mut self) -> Result<i16> { ... } fn read_i32(&mut self) -> Result<i32> { ... } fn read_i64(&mut self) -> Result<i64> { ... } fn skip_vlq(&mut self) -> Result<()> { ... } fn skip_binary(&mut self) -> Result<()> { ... } fn skip(&mut self, field_type: FieldType) -> Result<()> { ... } fn skip_empty_struct(&mut self) -> Result<()> { ... } fn skip_till_depth( &mut self, field_type: FieldType, depth: i8, ) -> Result<()> { ... }
}
Expand description

Low-level object used to deserialize structs encoded with the Thrift compact protocol.

Implementation of this trait must provide the low-level functions read_byte, read_bytes, skip_bytes, and read_double. These primitives are used by the default functions provided here to perform deserialization.

Required Methods§

Source

fn read_byte(&mut self) -> Result<u8>

Read a single byte from the input.

Source

fn read_bytes(&mut self) -> Result<&'a [u8]>

Read a Thrift encoded binary from the input.

Source

fn read_bytes_owned(&mut self) -> Result<Vec<u8>>

Source

fn skip_bytes(&mut self, n: usize) -> Result<()>

Skip the next n bytes of input.

Source

fn read_double(&mut self) -> Result<f64>

Read a Thrift double as f64.

Provided Methods§

Source

fn read_vlq(&mut self) -> Result<u64>

Read a ULEB128 encoded unsigned varint from the input.

Source

fn read_zig_zag(&mut self) -> Result<i64>

Read a zig-zag encoded signed varint from the input.

Source

fn read_list_begin(&mut self) -> Result<ListIdentifier>

Read the ListIdentifier for a Thrift encoded list.

Source

fn read_field_begin(&mut self, last_field_id: i16) -> Result<FieldIdentifier>

Read the FieldIdentifier for a field in a Thrift encoded struct.

Source

fn read_field_header(&mut self) -> Result<(u8, u8)>

This is a specialized version of Self::read_field_begin, solely for use in parsing simple structs. This function assumes that the delta field will always be less than 0xf, fields will be in order, and no boolean fields will be read. This also skips validation of the field type.

Returns a tuple of (field_type, field_delta).

Source

fn read_bool(&mut self) -> Result<bool>

Read a boolean list element. This should not be used for struct fields. For the latter, use the FieldIdentifier::bool_val field.

Source

fn read_string(&mut self) -> Result<&'a str>

Read a Thrift binary as a UTF-8 encoded string.

Source

fn read_i8(&mut self) -> Result<i8>

Read an i8.

Source

fn read_i16(&mut self) -> Result<i16>

Read an i16.

Source

fn read_i32(&mut self) -> Result<i32>

Read an i32.

Source

fn read_i64(&mut self) -> Result<i64>

Read an i64.

Source

fn skip_vlq(&mut self) -> Result<()>

Skip a ULEB128 encoded varint.

Source

fn skip_binary(&mut self) -> Result<()>

Skip a thrift binary.

Source

fn skip(&mut self, field_type: FieldType) -> Result<()>

Skip a field with type field_type recursively until the default maximum skip depth (currently 64) is reached.

Source

fn skip_empty_struct(&mut self) -> Result<()>

Empty structs in unions consist of a single byte of 0 for the field stop record. This skips that byte without encuring the cost of processing the FieldIdentifier. Will return an error if the struct is not actually empty.

Source

fn skip_till_depth(&mut self, field_type: FieldType, depth: i8) -> Result<()>

Skip a field with type field_type recursively up to depth levels.

Implementors§