Skip to main content

Encode

Trait Encode 

Source
pub trait Encode {
    // Required method
    fn encode<W: Write>(&self, writer: &mut W) -> Result<()>;

    // Provided method
    fn encode_to_vec(&self) -> Result<Vec<u8>> { ... }
}
Expand description

Hardware and language independent encoding. Uses the Writer pattern for more efficient encoding without intermediate buffers.

Required Methods§

Source

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Writes the encoded representation of self to the given writer.

Provided Methods§

Source

fn encode_to_vec(&self) -> Result<Vec<u8>>

Convenience method to encode into a Vec<u8>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Encode for String

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl Encode for bool

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl Encode for u8

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl Encode for u32

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl Encode for usize

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl<S: Encode, T: Encode> Encode for (S, T)

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl<T: Encode, const N: usize> Encode for [T; N]

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl<T: Encode> Encode for Option<T>

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

impl<T: Encode> Encode for Vec<T>

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Implementors§