Skip to main content

Writer

Struct Writer 

Source
pub struct Writer { /* private fields */ }

Implementations§

Source§

impl Writer

Source

pub fn new() -> Self

Source

pub fn with_capacity(cap: usize) -> Self

Source

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

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn raw(&mut self, b: &[u8])

Append raw bytes (no length prefix).

Source

pub fn varint(&mut self, v: u64)

Write an unsigned varint.

Source

pub fn varint_i32(&mut self, v: i32)

Proto3 int32: plain varint, with negative values sign-extended to a 10-byte uint64.

Source

pub fn varint_i64(&mut self, v: i64)

Proto3 int64: plain varint, two’s-complement uint64 form.

Source

pub fn zigzag32(&mut self, v: i32)

Zigzag-encoded signed varint (proto3 sint32).

Source

pub fn zigzag64(&mut self, v: i64)

Zigzag-encoded signed varint (proto3 sint64).

Source

pub fn fixed32(&mut self, v: u32)

Little-endian fixed 32-bit unsigned integer.

Source

pub fn fixed64(&mut self, v: u64)

Little-endian fixed 64-bit unsigned integer.

Source

pub fn float(&mut self, v: f32)

IEEE 754 32-bit float, little-endian.

Source

pub fn double(&mut self, v: f64)

IEEE 754 64-bit double, little-endian.

Source

pub fn string(&mut self, v: &str)

UTF-8 length-prefixed string.

Source

pub fn bytes(&mut self, v: &[u8])

Length-prefixed byte sequence.

Source

pub fn tag(&mut self, field_number: u32, wire_type: WireType)

Tag = (field_number << 3) | wire_type, encoded as a varint.

Panics on out-of-range field numbers — that’s a programmer error, not a wire-format failure.

Trait Implementations§

Source§

impl Debug for Writer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Writer

Source§

fn default() -> Writer

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 = 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.