Trait DecodeAsType

Source
pub trait DecodeAsType: Sized + IntoVisitor {
    // Provided method
    fn decode_as_type<R>(
        input: &mut &[u8],
        type_id: <R as TypeResolver>::TypeId,
        types: &R,
    ) -> Result<Self, Error>
       where R: TypeResolver { ... }
}
Expand description

This trait is implemented for any type T where T implements IntoVisitor and the errors returned from this Visitor can be converted into Error. It’s essentially a convenience wrapper around visitor::decode_with_visitor that mirrors scale-encode’s EncodeAsType.

Provided Methods§

Source

fn decode_as_type<R>( input: &mut &[u8], type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Self, Error>
where R: TypeResolver,

Given some input bytes, a type_id, and type registry, attempt to decode said bytes into Self. Implementations should modify the &mut reference to the bytes such that any bytes not used in the course of decoding are still pointed to after decoding is complete.

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<T> DecodeAsType for T
where T: IntoVisitor,