ThriftCompactOutputProtocol

Struct ThriftCompactOutputProtocol 

Source
pub(crate) struct ThriftCompactOutputProtocol<W: Write> {
    writer: W,
}
Expand description

Low-level object used to serialize structs to the Thrift compact output protocol.

This struct serves as a wrapper around a Write object, to which thrift encoded data will written. The implementation provides functions to write Thrift primitive types, as well as functions used in the encoding of lists and structs. This should rarely be used directly, but is instead intended for use by implementers of WriteThrift and WriteThriftField.

Fields§

§writer: W

Implementations§

Source§

impl<W: Write> ThriftCompactOutputProtocol<W>

Source

pub(crate) fn new(writer: W) -> Self

Create a new ThriftCompactOutputProtocol wrapping the byte sink writer.

Source

fn write_byte(&mut self, b: u8) -> Result<()>

Write a single byte to the output stream.

Source

fn write_vlq(&mut self, val: u64) -> Result<()>

Write the given u64 as a ULEB128 encoded varint.

Source

fn write_zig_zag(&mut self, val: i64) -> Result<()>

Write the given i64 as a zig-zag encoded varint.

Source

pub(crate) fn write_field_begin( &mut self, field_type: FieldType, field_id: i16, last_field_id: i16, ) -> Result<()>

Used to mark the start of a Thrift struct field of type field_type. last_field_id is used to compute a delta to the given field_id per the compact protocol spec.

Source

pub(crate) fn write_list_begin( &mut self, element_type: ElementType, len: usize, ) -> Result<()>

Used to indicate the start of a list of element_type elements.

Source

pub(crate) fn write_struct_end(&mut self) -> Result<()>

Used to mark the end of a struct. This must be called after all fields of the struct have been written.

Source

pub(crate) fn write_bytes(&mut self, val: &[u8]) -> Result<()>

Serialize a slice of u8s. This will encode a length, and then write the bytes without further encoding.

Source

pub(crate) fn write_empty_struct( &mut self, field_id: i16, last_field_id: i16, ) -> Result<i16>

Short-cut method used to encode structs that have no fields (often used in Thrift unions). This simply encodes the field id and then immediately writes the end-of-struct marker.

Source

pub(crate) fn write_bool(&mut self, val: bool) -> Result<()>

Write a boolean value.

Source

pub(crate) fn write_i8(&mut self, val: i8) -> Result<()>

Write a zig-zag encoded i8 value.

Source

pub(crate) fn write_i16(&mut self, val: i16) -> Result<()>

Write a zig-zag encoded i16 value.

Source

pub(crate) fn write_i32(&mut self, val: i32) -> Result<()>

Write a zig-zag encoded i32 value.

Source

pub(crate) fn write_i64(&mut self, val: i64) -> Result<()>

Write a zig-zag encoded i64 value.

Source

pub(crate) fn write_double(&mut self, val: f64) -> Result<()>

Write a double value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Ungil for T
where T: Send,