scale_encode

Trait EncodeAsType

source
pub trait EncodeAsType {
    // Required method
    fn encode_as_type_to<R: TypeResolver>(
        &self,
        type_id: R::TypeId,
        types: &R,
        out: &mut Vec<u8>,
    ) -> Result<(), Error>;

    // Provided method
    fn encode_as_type<R: TypeResolver>(
        &self,
        type_id: R::TypeId,
        types: &R,
    ) -> Result<Vec<u8>, Error> { ... }
}
Expand description

This trait signals that some static type can possibly be SCALE encoded given some type_id and a corresponding TypeResolver which tells us about the expected encoding.

Required Methods§

source

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.

Provided Methods§

source

fn encode_as_type<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, ) -> Result<Vec<u8>, Error>

This is a helper function which internally calls EncodeAsType::encode_as_type_to. Prefer to implement that instead.

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 EncodeAsType for bool

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for char

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for i8

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for i16

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for i32

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for i64

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for i128

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for isize

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for str

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for u8

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for u16

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for u32

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for u64

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for u128

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for ()

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for usize

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for String

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for Duration

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for H128

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for H160

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for H256

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for H384

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for H512

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for H768

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for Bits

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroI8

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroI16

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroI32

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroI64

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroI128

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroU8

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroU16

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroU32

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroU64

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl EncodeAsType for NonZeroU128

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<'a, T> EncodeAsType for Cow<'a, T>
where T: 'a + EncodeAsType + ToOwned + ?Sized,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<'a, T> EncodeAsType for &'a T
where T: EncodeAsType + ?Sized,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A> EncodeAsType for (A,)
where A: EncodeAsType,

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B> EncodeAsType for (A, B)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C> EncodeAsType for (A, B, C)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D> EncodeAsType for (A, B, C, D)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E> EncodeAsType for (A, B, C, D, E)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F> EncodeAsType for (A, B, C, D, E, F)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G> EncodeAsType for (A, B, C, D, E, F, G)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H> EncodeAsType for (A, B, C, D, E, F, G, H)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I> EncodeAsType for (A, B, C, D, E, F, G, H, I)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J> EncodeAsType for (A, B, C, D, E, F, G, H, I, J)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S> EncodeAsType for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)

source§

fn encode_as_type_to<Resolver: TypeResolver>( &self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<K> EncodeAsType for BTreeSet<K>
where K: EncodeAsType,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<K: AsRef<str>, V: EncodeAsType> EncodeAsType for BTreeMap<K, V>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T> EncodeAsType for [T]
where T: EncodeAsType,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T> EncodeAsType for PhantomData<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for Option<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for Box<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for Rc<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for Arc<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for Range<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for RangeInclusive<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType> EncodeAsType for Compact<T>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<T: EncodeAsType, E: EncodeAsType> EncodeAsType for Result<T, E>

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<V> EncodeAsType for BinaryHeap<V>
where V: EncodeAsType,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<V> EncodeAsType for LinkedList<V>
where V: EncodeAsType,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<V> EncodeAsType for VecDeque<V>
where V: EncodeAsType,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<V> EncodeAsType for Vec<V>
where V: EncodeAsType,

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

source§

impl<const N: usize, T: EncodeAsType> EncodeAsType for [T; N]

source§

fn encode_as_type_to<R: TypeResolver>( &self, type_id: R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>

Implementors§