pub trait Encode: Debug {
    type Error: From<Error> + Debug;

    // Required methods
    fn encode_len(&self) -> Result<usize, Self::Error>;
    fn encode(&self, buff: &mut [u8]) -> Result<usize, Self::Error>;
}
Expand description

Encode trait implemented for binary encodable objects

Required Associated Types§

source

type Error: From<Error> + Debug

Error type returned on parse error

Required Methods§

source

fn encode_len(&self) -> Result<usize, Self::Error>

Calculate expected encoded length for an object

source

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

Encode method writes object data to the provided writer

Implementations on Foreign Types§

source§

impl Encode for u32

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for i8

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for u8

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for f64

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl<T: Encode> Encode for &T

Blanket encode for references to encodable types

§

type Error = <T as Encode>::Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl<T, const N: usize> Encode for [T; N]where T: Encode, <T as Encode>::Error: From<Error> + Debug,

Blanket Encode impl for arrays of encodable types

§

type Error = <T as Encode>::Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for i32

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for &str

Encode implementation for str

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for f32

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for u16

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for i16

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl<T> Encode for &[T]where T: Encode, <T as Encode>::Error: From<Error> + Debug,

Blanket Encode impl for slices of encodable types

§

type Error = <T as Encode>::Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for i64

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl<T> Encode for Vec<T>where T: Encode, <T as Encode>::Error: From<Error> + Debug,

Encode implementation for std/alloc alloc::vec::Vec containing encodable types

§

type Error = <T as Encode>::Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl Encode for u64

§

type Error = Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

source§

impl<T, const N: usize> Encode for Vec<T, N>where T: Encode, <T as Encode>::Error: From<Error> + Debug,

Encode implementation for heapless heapless::Vec containing encodable types

§

type Error = <T as Encode>::Error

source§

fn encode_len(&self) -> Result<usize, Self::Error>

source§

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

Implementors§