Skip to main content

Packer

Struct Packer 

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

Writes a frame.

Implementations§

Source§

impl Packer

Source

pub fn new() -> Self

Source

pub fn put_u(&mut self, n: u64)

An unsigned number (a count, an index).

Source

pub fn put_i(&mut self, n: i64)

Source

pub fn put_bool(&mut self, b: bool)

Source

pub fn put_f64(&mut self, f: f64)

Source

pub fn put_f32(&mut self, f: f32)

Source

pub fn put_f64s(&mut self, items: &[f64])

Floats, raw: a count, whether they’re kept as f32 (when every one is one exactly — half the bytes), then each one’s bytes.

Source

pub fn put_uints( &mut self, len: usize, items: impl Iterator<Item = u64> + Clone, )

Unsigned numbers bit-packed: a count, how many bits each takes (the biggest one’s, one at least), then the bits (lanes).

Source

pub fn put_f32s(&mut self, items: &[f32])

Source

pub fn put_str(&mut self, s: &str)

A string: its index in the table, which gets it the first time.

Source

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

Source

pub fn put_tagged<T: Schema>(&mut self, v: &T)

v in its binary form, as bytes: what a frame holds of a type that doesn’t pack itself.

Source

pub fn begin(&mut self) -> usize

A record starts: where its length goes (Packer::end fills it in).

Source

pub fn begin_list(&mut self, len: usize) -> usize

A list of len items packed one by one: its count, then its length in bytes like a record’s (Packer::end writes it), so a reader can step over it.

Source

pub fn end(&mut self, at: usize)

The record (or list) begun at at ends: its length written.

Source

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

The frame: its body, its strings, their length backwards.

Trait Implementations§

Source§

impl Default for Packer

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.