firefly_types

Trait Encode

Source
pub trait Encode<'a>
where Self: Sized + Deserialize<'a> + Serialize,
{ // Provided methods fn decode(s: &'a [u8]) -> Result<Self, Error> { ... } fn encode<'b>(&self, buf: &'b mut [u8]) -> Result<&'b mut [u8], Error> { ... } fn size(&self) -> usize { ... } }

Provided Methods§

Source

fn decode(s: &'a [u8]) -> Result<Self, Error>

Load object from bytes generated by [Badges::encode].

§Errors

May return an error if the buffer does not contain valid object.

Source

fn encode<'b>(&self, buf: &'b mut [u8]) -> Result<&'b mut [u8], Error>

Encode the object using the buffer.

The buffer is required to avoid allocations on the crate side. Use Encode::size to calculate the required buffer size.

§Errors

May return an error if the buffer is not big enough.

Source

fn size(&self) -> usize

Calculate the buffer size required to encode the badges.

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.

Implementors§

Source§

impl<'a> Encode<'a> for Request

Source§

impl<'a> Encode<'a> for Response

Source§

impl<'a> Encode<'a> for Badges<'a>

Source§

impl<'a> Encode<'a> for Boards<'a>

Source§

impl<'a> Encode<'a> for Meta<'a>

Source§

impl<'a> Encode<'a> for Settings

Source§

impl<'a> Encode<'a> for ShortMeta<'a>

Source§

impl<'a> Encode<'a> for Stats