Encode

Trait Encode 

Source
pub trait Encode<C: Codec> {
    // Required method
    fn encode<W: Write>(&self, c: C, w: &mut W) -> Result<()>;
}
Expand description

Encode trait.

This trait is generic over a codec, so that different codecs can be implemented for the same type.

Required Methods§

Source

fn encode<W: Write>(&self, c: C, w: &mut W) -> Result<()>

Encodes into a impl Write.

It takes a specific codec as parameter, so that the Encode can be generic over an enum that contains multiple codecs.

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<RawCodec> for Box<[u8]>

Source§

fn encode<W: Write>(&self, _: RawCodec, w: &mut W) -> Result<()>

Source§

impl Encode<RawCodec> for Vec<u8>

Source§

fn encode<W: Write>(&self, _: RawCodec, w: &mut W) -> Result<()>

Source§

impl Encode<RawCodec> for [u8]

Source§

fn encode<W: Write>(&self, _: RawCodec, w: &mut W) -> Result<()>

Source§

impl<C: Codec, T: Encode<C>> Encode<C> for &T

Source§

fn encode<W: Write>(&self, c: C, w: &mut W) -> Result<()>

Implementors§

Source§

impl Encode<RawCodec> for Ipld

Source§

impl<C: Codec> Encode<C> for RawValue<C>

Source§

impl<C: Codec, T> Encode<C> for Link<T>
where Cid: Encode<C>,