Trait libipld_core::codec::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.

Object Safety§

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>,