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>
impl<W: Write> ThriftCompactOutputProtocol<W>
Sourcepub(crate) fn new(writer: W) -> Self
pub(crate) fn new(writer: W) -> Self
Create a new ThriftCompactOutputProtocol
wrapping the byte sink writer
.
Sourcefn write_byte(&mut self, b: u8) -> Result<()>
fn write_byte(&mut self, b: u8) -> Result<()>
Write a single byte to the output stream.
Sourcefn write_vlq(&mut self, val: u64) -> Result<()>
fn write_vlq(&mut self, val: u64) -> Result<()>
Write the given u64
as a ULEB128 encoded varint.
Sourcefn write_zig_zag(&mut self, val: i64) -> Result<()>
fn write_zig_zag(&mut self, val: i64) -> Result<()>
Write the given i64
as a zig-zag encoded varint.
Sourcepub(crate) fn write_field_begin(
&mut self,
field_type: FieldType,
field_id: i16,
last_field_id: i16,
) -> Result<()>
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.
Sourcepub(crate) fn write_list_begin(
&mut self,
element_type: ElementType,
len: usize,
) -> Result<()>
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.
Sourcepub(crate) fn write_struct_end(&mut self) -> Result<()>
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.
Sourcepub(crate) fn write_bytes(&mut self, val: &[u8]) -> Result<()>
pub(crate) fn write_bytes(&mut self, val: &[u8]) -> Result<()>
Serialize a slice of u8
s. This will encode a length, and then write the bytes without
further encoding.
Sourcepub(crate) fn write_empty_struct(
&mut self,
field_id: i16,
last_field_id: i16,
) -> Result<i16>
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.
Sourcepub(crate) fn write_bool(&mut self, val: bool) -> Result<()>
pub(crate) fn write_bool(&mut self, val: bool) -> Result<()>
Write a boolean value.
Sourcepub(crate) fn write_double(&mut self, val: f64) -> Result<()>
pub(crate) fn write_double(&mut self, val: f64) -> Result<()>
Write a double value.
Auto Trait Implementations§
impl<W> Freeze for ThriftCompactOutputProtocol<W>where
W: Freeze,
impl<W> RefUnwindSafe for ThriftCompactOutputProtocol<W>where
W: RefUnwindSafe,
impl<W> Send for ThriftCompactOutputProtocol<W>where
W: Send,
impl<W> Sync for ThriftCompactOutputProtocol<W>where
W: Sync,
impl<W> Unpin for ThriftCompactOutputProtocol<W>where
W: Unpin,
impl<W> UnwindSafe for ThriftCompactOutputProtocol<W>where
W: UnwindSafe,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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