Trait Encode

Source
pub trait Encode {
    type Error;

    // Required method
    fn encode(&self, buff: &mut [u8]) -> Result<usize, Self::Error>;

    // Provided method
    fn encode_iter<'a, V: Iterator<Item = &'a Self>>(
        vals: V,
        buff: &mut [u8],
    ) -> Result<usize, Self::Error>
       where Self: 'static { ... }
}
Expand description

Encode trait for building encodable objects

Required Associated Types§

Source

type Error

Error type returned on parse error

Required Methods§

Source

fn encode(&self, buff: &mut [u8]) -> Result<usize, Self::Error>

Encode method writes object data to the provided writer

Provided Methods§

Source

fn encode_iter<'a, V: Iterator<Item = &'a Self>>( vals: V, buff: &mut [u8], ) -> Result<usize, Self::Error>
where Self: 'static,

Encode a iterator of encodable objects

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Encode for String

Source§

type Error = OptionsError

Source§

fn encode(&self, data: &mut [u8]) -> Result<usize, Self::Error>

Source§

impl Encode for Vec<u8>

Source§

type Error = OptionsError

Source§

fn encode(&self, data: &mut [u8]) -> Result<usize, Self::Error>

Implementors§