pub trait Encode {
// Provided methods
fn size_hint(&self) -> usize { ... }
fn encode_to<T>(&self, dest: &mut T)
where T: Output + ?Sized { ... }
fn encode(&self) -> Vec<u8, Global> ⓘ { ... }
fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R { ... }
fn encoded_size(&self) -> usize { ... }
}
Expand description
Trait that allows zero-copy write of value-references to slices in LE format.
Implementations should override using_encoded
for value types and encode_to
and size_hint
for allocating types.
Wrapper types should override all methods.
Provided Methods§
sourcefn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding.
This method is used inside default implementation of encode
to avoid re-allocations.
sourcefn encode_to<T>(&self, dest: &mut T)where
T: Output + ?Sized,
fn encode_to<T>(&self, dest: &mut T)where T: Output + ?Sized,
Convert self to a slice and append it to the destination.
sourcefn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
Convert self to a slice and then invoke the given closure with it.
sourcefn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Implementations on Foreign Types§
source§impl Encode for ModuleError
impl Encode for ModuleError
source§impl Encode for TestSignature
impl Encode for TestSignature
source§impl<Info> Encode for DispatchErrorWithPostInfo<Info>where
Info: Eq + PartialEq<Info> + Clone + Copy + Encode + Decode + Printable,
impl<Info> Encode for DispatchErrorWithPostInfo<Info>where Info: Eq + PartialEq<Info> + Clone + Copy + Encode + Decode + Printable,
source§impl Encode for UintAuthorityId
impl Encode for UintAuthorityId
source§impl<Number, Hash> Encode for Header<Number, Hash>where
Number: Copy + Into<U256> + TryFrom<U256> + Encode + HasCompact,
Hash: Hash,
<Hash as Hash>::Output: Encode,
impl<Number, Hash> Encode for Header<Number, Hash>where Number: Copy + Into<U256> + TryFrom<U256> + Encode + HasCompact, Hash: Hash, <Hash as Hash>::Output: Encode,
source§impl Encode for DispatchError
impl Encode for DispatchError
source§impl Encode for MultiSigner
impl Encode for MultiSigner
source§impl Encode for TransactionSource
impl Encode for TransactionSource
source§impl Encode for ValidTransaction
impl Encode for ValidTransaction
source§impl<HeaderType, Xt> Encode for BlockGeneric<HeaderType, Xt>where
HeaderType: Encode,
Vec<Xt, Global>: Encode,
impl<HeaderType, Xt> Encode for BlockGeneric<HeaderType, Xt>where HeaderType: Encode, Vec<Xt, Global>: Encode,
source§impl Encode for ModuleError
impl Encode for ModuleError
source§impl Encode for TransactionValidityError
impl Encode for TransactionValidityError
source§impl Encode for TokenError
impl Encode for TokenError
source§impl<Block> Encode for SignedBlock<Block>where
Block: Encode,
impl<Block> Encode for SignedBlock<Block>where Block: Encode,
source§impl<B> Encode for BlockAndTimeDeadline<B>where
B: BlockNumberProvider,
<B as BlockNumberProvider>::BlockNumber: Encode,
impl<B> Encode for BlockAndTimeDeadline<B>where B: BlockNumberProvider, <B as BlockNumberProvider>::BlockNumber: Encode,
source§impl Encode for DispatchError
impl Encode for DispatchError
source§impl<AccountId, AccountIndex> Encode for MultiAddress<AccountId, AccountIndex>where
AccountId: Encode,
AccountIndex: HasCompact,
impl<AccountId, AccountIndex> Encode for MultiAddress<AccountId, AccountIndex>where AccountId: Encode, AccountIndex: HasCompact,
source§impl Encode for AnySignature
impl Encode for AnySignature
source§impl Encode for MultiSignature
impl Encode for MultiSignature
source§impl<Number, Hash> Encode for Header<Number, Hash>where
Number: Copy + Into<U256> + TryFrom<U256> + HasCompact,
Hash: Hash,
<Hash as Hash>::Output: Encode,
impl<Number, Hash> Encode for Header<Number, Hash>where Number: Copy + Into<U256> + TryFrom<U256> + HasCompact, Hash: Hash, <Hash as Hash>::Output: Encode,
source§impl<Call, Extra> Encode for TestXt<Call, Extra>where
Option<(u64, Extra)>: Encode,
Call: Encode,
impl<Call, Extra> Encode for TestXt<Call, Extra>where Option<(u64, Extra)>: Encode, Call: Encode,
source§impl<Header, Extrinsic> Encode for Block<Header, Extrinsic>where
Header: Encode,
Vec<Extrinsic, Global>: Encode,
impl<Header, Extrinsic> Encode for Block<Header, Extrinsic>where Header: Encode, Vec<Extrinsic, Global>: Encode,
source§impl Encode for LookupError
impl Encode for LookupError
source§impl<Call, Extra> Encode for SignedPayload<Call, Extra>where
Call: Encode,
Extra: SignedExtension,
impl<Call, Extra> Encode for SignedPayload<Call, Extra>where Call: Encode, Extra: SignedExtension,
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
Get an encoded version of this payload.
Payloads longer than 256 bytes are going to be blake2_256
-hashed.