Codec

Trait Codec 

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

Provided Methods§

Source

fn encode<T: Encode<Self> + ?Sized>( &self, obj: &T, ) -> Result<ByteCursor, String>

§Errors

Will return Err if there was a problem encoding the object into a ByteCursor

Source

fn decode<T: Decode<Self>>(&self, bytes: ByteCursor) -> Result<T, String>

§Errors

Will return Err if there was a problem decoding the ByteCursor into an object

Source

fn references<T: References<Self>, E: Extend<Cid>>( &self, bytes: ByteCursor, set: &mut E, ) -> Result<(), String>

Extends set with any cids the type encoded in the bytecursor refers to.

§Errors

Returns Err if there were any errors decoding the bytecursor.

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§