Trait Encodable

Source
pub trait Encodable<Enc, Err>: Versioned<Err>
where Err: Error + From<Enc::Error>, Enc: Encoder, Self::Output: Encode<Enc>,
{ // Provided method fn encode(data: &Self::Output, encoder: &mut Enc) -> Result<(), Err> { ... } }
Expand description

This trait is used to mark a versioned type as encodable. Usually this is provided by the versioned! macro.

Provided Methods§

Source

fn encode(data: &Self::Output, encoder: &mut Enc) -> Result<(), Err>

Encodes the data including the version tag.

§Errors
  • Returns an error if the data failes to encode.

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<Latest, Prior, Enc, Err> Encodable<Enc, Err> for Upgrade<Latest, Prior, Err>
where Err: Error + From<<Enc as Encoder>::Error>, Enc: Encoder, Prior: Versioned<Err>, Latest: Versioned<Err>, Latest::Output: Encode<Enc> + TryFrom<Prior::Output>,