Codec

Trait Codec 

Source
pub trait Codec:
    Sized
    + Copy
    + Unpin
    + Send
    + Sync
    + 'static
    + TryFrom<u64, Error = UnsupportedCodec>
    + Into<u64> {
    // Provided methods
    fn encode<T>(&self, obj: &T) -> Result<Vec<u8>, Error>
       where T: Encode<Self> + ?Sized { ... }
    fn decode<T>(&self, bytes: &[u8]) -> Result<T, Error>
       where T: Decode<Self> { ... }
    fn references<T, E>(&self, bytes: &[u8], set: &mut E) -> Result<(), Error>
       where T: References<Self>,
             E: Extend<Cid<64>> { ... }
}
Expand description

Codec trait.

Provided Methods§

Source

fn encode<T>(&self, obj: &T) -> Result<Vec<u8>, Error>
where T: Encode<Self> + ?Sized,

Encodes an encodable type.

Source

fn decode<T>(&self, bytes: &[u8]) -> Result<T, Error>
where T: Decode<Self>,

Decodes a decodable type.

Source

fn references<T, E>(&self, bytes: &[u8], set: &mut E) -> Result<(), Error>
where T: References<Self>, E: Extend<Cid<64>>,

Scrapes the references.

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 Codec for IpldCodec

Source§

impl Codec for DagCborCodec

Source§

impl Codec for DagJsonCodec

Source§

impl Codec for DagPbCodec

Implementors§