Skip to main content

Encoder

Struct Encoder 

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

Writes one message: the msgpack buffer plus out-of-band frames.

Implementations§

Source§

impl Encoder

Source

pub fn new() -> Self

An encoder with the Python side’s inline threshold.

Source

pub fn with_inline_threshold(inline_threshold: usize) -> Self

An encoder that frames out buffers of at least inline_threshold bytes.

Source

pub fn into_frames(self) -> Vec<Bytes>

Finish the message: the msgpack buffer, then the out-of-band frames.

Source

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

Finish a message that has no out-of-band frames.

§Panics

If a buffer was framed out: the caller would drop it from the wire.

Source

pub fn nil(&mut self)

Write nil.

Source

pub fn bool(&mut self, value: bool)

Write a boolean.

Source

pub fn int(&mut self, value: i64)

Write a signed integer: non-negative values use the unsigned formats.

Source

pub fn uint(&mut self, value: u64)

Write an unsigned integer.

Source

pub fn float(&mut self, value: f64)

Write a float, always as float64.

Source

pub fn str(&mut self, value: &str)

Write a string.

Source

pub fn bin(&mut self, value: &[u8])

Write a binary value.

Source

pub fn array_len(&mut self, len: usize)

Write an array header for len elements.

Source

pub fn map_len(&mut self, len: usize)

Write a map header for len entries.

Source

pub fn ext(&mut self, code: i8, data: &[u8])

Write an extension value.

Trait Implementations§

Source§

impl Debug for Encoder

Source§

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

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

impl Default for Encoder

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.