Skip to main content

FieldWriter

Struct FieldWriter 

Source
pub struct FieldWriter { /* private fields */ }
Expand description

Builds a tagged-field payload.

Implementations§

Source§

impl FieldWriter

Source

pub fn new() -> Self

Source

pub fn bytes(&self) -> &[u8]

Returns the encoded payload.

Source

pub fn into_vec(self) -> Vec<u8>

Source

pub fn put_u64(&mut self, tag: u16, v: u64)

Writes an 8-byte integer field. Always written, even when zero — decoders rely on the tag being present for bool-ish fields.

Source

pub fn put_u16(&mut self, tag: u16, v: u16)

Source

pub fn put_u32(&mut self, tag: u16, v: u32)

Source

pub fn put_bool(&mut self, tag: u16, v: bool)

Source

pub fn put_bytes(&mut self, tag: u16, p: &[u8])

Writes a length-prefixed blob. Empty blobs are omitted so decoders stay compact on the hot path.

Source

pub fn put_string(&mut self, tag: u16, s: &str)

Source

pub fn put_u16s(&mut self, tag: u16, vs: &[u16])

Writes a packed list as WireBytes: u16 count + values.

Trait Implementations§

Source§

impl Default for FieldWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.