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§
Sourcefn read_bytes(&mut self) -> Result<&'a [u8]>
fn read_bytes(&mut self) -> Result<&'a [u8]>
Read a Thrift encoded binary from the input.
fn read_bytes_owned(&mut self) -> Result<Vec<u8>>
Sourcefn skip_bytes(&mut self, n: usize) -> Result<()>
fn skip_bytes(&mut self, n: usize) -> Result<()>
Skip the next n
bytes of input.
Sourcefn read_double(&mut self) -> Result<f64>
fn read_double(&mut self) -> Result<f64>
Read a Thrift double
as f64
.
Provided Methods§
Sourcefn read_zig_zag(&mut self) -> Result<i64>
fn read_zig_zag(&mut self) -> Result<i64>
Read a zig-zag encoded signed varint from the input.
Sourcefn read_list_begin(&mut self) -> Result<ListIdentifier>
fn read_list_begin(&mut self) -> Result<ListIdentifier>
Read the ListIdentifier
for a Thrift encoded list.
Sourcefn read_field_begin(&mut self, last_field_id: i16) -> Result<FieldIdentifier>
fn read_field_begin(&mut self, last_field_id: i16) -> Result<FieldIdentifier>
Read the FieldIdentifier
for a field in a Thrift encoded struct.
Sourcefn read_field_header(&mut self) -> Result<(u8, u8)>
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)
.
Sourcefn read_bool(&mut self) -> Result<bool>
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.
Sourcefn read_string(&mut self) -> Result<&'a str>
fn read_string(&mut self) -> Result<&'a str>
Read a Thrift binary as a UTF-8 encoded string.
Sourcefn skip_binary(&mut self) -> Result<()>
fn skip_binary(&mut self) -> Result<()>
Skip a thrift binary.
Sourcefn skip(&mut self, field_type: FieldType) -> Result<()>
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.
Sourcefn skip_empty_struct(&mut self) -> Result<()>
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.