Encoder

Struct Encoder 

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

An encoder for encoding lilliput values.

Implementations§

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_bool(&mut self, value: bool) -> Result<()>

Encodes a boolean value.

Source

pub fn encode_bool_value(&mut self, value: &BoolValue) -> Result<()>

Encodes a boolean value, from a BoolValue.

Source

pub fn encode_bool_header(&mut self, header: &BoolHeader) -> Result<()>

Encodes a boolean value’s header.

Source

pub fn header_for_bool(&self, value: bool) -> BoolHeader

Creates a header for value.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_bytes(&mut self, value: &[u8]) -> Result<()>

Encodes a byte array value, from a slice reference.

Source

pub fn encode_bytes_value(&mut self, value: &BytesValue) -> Result<()>

Encodes a byte array value, from a BytesValue.

Source

pub fn encode_bytes_header(&mut self, header: &BytesHeader) -> Result<()>

Encodes a byte array value’s header.

Source

pub fn header_for_bytes_len(&self, len: usize) -> BytesHeader

Creates a header for a byte array value, from its length.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_f32(&mut self, value: f32) -> Result<()>

Encodes a 32-bit floating-point value.

Source

pub fn encode_f64(&mut self, value: f64) -> Result<()>

Encodes a 64-bit floating-point value.

Source

pub fn encode_float_value(&mut self, value: &FloatValue) -> Result<()>

Encodes a floating-point value, from a FloatValue.

Source

pub fn encode_float_header(&mut self, header: &FloatHeader) -> Result<()>

Encodes a floating-point value’s header.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_i8(&mut self, value: i8) -> Result<()>

Encodes a 8-bit signed integer value.

Source

pub fn encode_i16(&mut self, value: i16) -> Result<()>

Encodes a 16-bit signed integer value.

Source

pub fn encode_i32(&mut self, value: i32) -> Result<()>

Encodes a 32-bit signed integer value.

Source

pub fn encode_i64(&mut self, value: i64) -> Result<()>

Encodes a 64-bit signed integer value.

Source

pub fn encode_u8(&mut self, value: u8) -> Result<()>

Encodes a 8-bit unsigned integer value.

Source

pub fn encode_u16(&mut self, value: u16) -> Result<()>

Encodes a 16-bit unsigned integer value.

Source

pub fn encode_u32(&mut self, value: u32) -> Result<()>

Encodes a 32-bit unsigned integer value.

Source

pub fn encode_u64(&mut self, value: u64) -> Result<()>

Encodes a 64-bit unsigned integer value.

Source

pub fn encode_signed_int_value(&mut self, value: &SignedIntValue) -> Result<()>

Encodes a signed integer value, from a SignedIntValue.

Source

pub fn encode_unsigned_int_value( &mut self, value: &UnsignedIntValue, ) -> Result<()>

Encodes an unsigned integer value, from a UnsignedIntValue.

Source

pub fn encode_int_value(&mut self, value: &IntValue) -> Result<()>

Encodes an integer value, from a IntValue.

Source

pub fn encode_int_header(&mut self, header: &IntHeader) -> Result<()>

Encodes a integer value’s header.

Source

pub fn header_for_signed_int<T>(&self, value: T) -> IntHeader
where T: Signed + WithPackedBeBytes,

Creates a header for a signed integer value.

Source

pub fn header_for_unsigned_int<T>(&self, value: T) -> IntHeader
where T: Unsigned + WithPackedBeBytes,

Creates a header for an unsigned integer value.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_map(&mut self, value: &Map) -> Result<()>

Encodes a map value.

Source

pub fn encode_map_value(&mut self, value: &MapValue) -> Result<()>

Encodes a map value, from a MapValue.

Source

pub fn encode_map_header(&mut self, header: &MapHeader) -> Result<()>

Encodes a map value’s header.

Source

pub fn header_for_map_len(&self, len: usize) -> MapHeader

Creates a header for a map value, from its length.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_null(&mut self) -> Result<()>

Encodes a null value.

Source

pub fn encode_null_value(&mut self, value: &NullValue) -> Result<()>

Encodes a null value, as a NullValue.

Source

pub fn encode_null_header(&mut self, header: &NullHeader) -> Result<()>

Encodes a null value’s header.

Source

pub fn header_for_null(&self) -> NullHeader

Creates a header for a null value.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_seq(&mut self, value: &[Value]) -> Result<()>

Encodes a sequence value.

Source

pub fn encode_seq_value(&mut self, value: &SeqValue) -> Result<()>

Encodes a sequence value, from a SeqValue.

Source

pub fn encode_seq_header(&mut self, header: &SeqHeader) -> Result<()>

Encodes a sequence value’s header.

Source

pub fn header_for_seq_len(&self, len: usize) -> SeqHeader

Creates a header for a sequence value, from its length.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_str(&mut self, value: &str) -> Result<()>

Encodes a string value, from a reference.

Source

pub fn encode_string_value(&mut self, value: &StringValue) -> Result<()>

Encodes a string value, from a StringValue.

Source

pub fn encode_string_header(&mut self, header: &StringHeader) -> Result<()>

Enodes a string value’s header.

Source

pub fn header_for_str_len(&self, len: usize) -> StringHeader

Creates a header for a string value, from its length.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_unit(&mut self) -> Result<()>

Encodes a unit value.

Source

pub fn encode_unit_value(&mut self, value: &UnitValue) -> Result<()>

Encodes a unit value, from a UnitValue.

Source

pub fn encode_unit_header(&mut self, header: &UnitHeader) -> Result<()>

Encodes a unit value’s header.

Source

pub fn header_for_unit(&self) -> UnitHeader

Creates a header for a unit value.

Source§

impl<W> Encoder<W>

Source

pub fn from_writer(writer: W) -> Self

Creates a encoder from writer.

Source

pub fn new(writer: W, config: EncoderConfig) -> Self

Creates a encoder from writer, configured by config.

Source

pub fn into_writer(self) -> W

Returns the encoder’s internal writer, consuming self.

Source

pub fn pos(&self) -> usize

Returns the encoder’s current write position.

Source§

impl<W> Encoder<W>
where W: Write,

Source

pub fn encode_header(&mut self, header: &Header) -> Result<()>

Encodes a value’s Header.

Source

pub fn encode_value(&mut self, value: &Value) -> Result<()>

Encodes a Value.

Trait Implementations§

Source§

impl<W: Debug> Debug for Encoder<W>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for Encoder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for Encoder<W>
where W: RefUnwindSafe,

§

impl<W> Send for Encoder<W>
where W: Send,

§

impl<W> Sync for Encoder<W>
where W: Sync,

§

impl<W> Unpin for Encoder<W>
where W: Unpin,

§

impl<W> UnwindSafe for Encoder<W>
where W: UnwindSafe,

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.