pub trait Encode {
    fn size_hint(&self) -> usize { ... }
fn encode_to<T>(&self, dest: &mut T)
    where
        T: Output + ?Sized
, { ... }
fn encode(&self) -> Vec<u8, Global>
Notable traits for Vec<u8, A>
impl<A> Write for Vec<u8, A> where
    A: Allocator
{ ... }
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

If possible give a hint of expected size of the encoding.

This method is used inside default implementation of encode to avoid re-allocations.

Convert self to a slice and append it to the destination.

Convert self to an owned vector.

Convert self to a slice and then invoke the given closure with it.

Calculates the encoded size.

Should be used when the encoded data isn’t required.

Note

This works by using a special Output that only tracks the size. So, there are no allocations inside the output. However, this can not prevent allocations that some types are doing inside their own encoding.

Implementations on Foreign Types

impl Encode for Entry

Get an encoded version of this payload.

Payloads longer than 256 bytes are going to be blake2_256-hashed.

Implementors

impl<T: Form> Encode for ExtrinsicMetadata<T> where
    T::Type: Encode,
    T::Type: Encode,
    Vec<SignedExtensionMetadata<T>>: Encode,
    Vec<SignedExtensionMetadata<T>>: Encode

impl<T: Form> Encode for SignedExtensionMetadata<T> where
    T::String: Encode,
    T::String: Encode,
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for PalletStorageMetadata<T> where
    T::String: Encode,
    T::String: Encode,
    Vec<StorageEntryMetadata<T>>: Encode,
    Vec<StorageEntryMetadata<T>>: Encode

impl<T: Form> Encode for StorageEntryMetadata<T> where
    T::String: Encode,
    T::String: Encode,
    StorageEntryType<T>: Encode,
    StorageEntryType<T>: Encode,
    Vec<T::String>: Encode,
    Vec<T::String>: Encode

impl<T: Form> Encode for StorageEntryType<T> where
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for PalletCallMetadata<T> where
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for PalletEventMetadata<T> where
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for PalletConstantMetadata<T> where
    T::String: Encode,
    T::String: Encode,
    T::Type: Encode,
    T::Type: Encode,
    Vec<T::String>: Encode,
    Vec<T::String>: Encode

impl<T: Form> Encode for PalletErrorMetadata<T> where
    T::Type: Encode,
    T::Type: Encode

impl<T: Config + Send + Sync> Encode for CheckGenesis<T> where
    PhantomData<T>: Encode,
    PhantomData<T>: Encode

impl<T: Config + Send + Sync> Encode for CheckMortality<T> where
    PhantomData<T>: Encode,
    PhantomData<T>: Encode

impl<T: Config> Encode for CheckNonce<T> where
    T::Index: HasCompact

impl<T: Config + Send + Sync> Encode for CheckSpecVersion<T> where
    PhantomData<T>: Encode,
    PhantomData<T>: Encode

impl<T: Config + Send + Sync> Encode for CheckTxVersion<T> where
    PhantomData<T>: Encode,
    PhantomData<T>: Encode

impl<T: Config + Send + Sync> Encode for CheckWeight<T> where
    PhantomData<T>: Encode,
    PhantomData<T>: Encode

impl<T: Config> Encode for Event<T> where
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode

impl<T: Config> Encode for Call<T>

impl Encode for Phase

impl<E: Parameter + Member, T> Encode for EventRecord<E, T> where
    E: Encode,
    E: Encode,
    Vec<T>: Encode,
    Vec<T>: Encode

impl<AccountId> Encode for RawOrigin<AccountId> where
    AccountId: Encode,
    AccountId: Encode

impl<Index, AccountData> Encode for AccountInfo<Index, AccountData> where
    Index: Encode,
    Index: Encode,
    AccountData: Encode,
    AccountData: Encode

impl<T: Config> Encode for Event<T> where
    <T as Config>::AccountId: Encode,
    <T as Config>::AccountId: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T> where
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config<I>, I: 'static> Encode for Event<T, I> where
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode

impl<T: Config<I>, I: 'static> Encode for Call<T, I>

impl Encode for Reasons

impl<Balance> Encode for BalanceLock<Balance> where
    Balance: Encode,
    Balance: Encode

impl<ReserveIdentifier, Balance> Encode for ReserveData<ReserveIdentifier, Balance> where
    ReserveIdentifier: Encode,
    ReserveIdentifier: Encode,
    Balance: Encode,
    Balance: Encode

impl<Balance> Encode for AccountData<Balance> where
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode

impl<T: Config<I>, I: 'static> Encode for Event<T, I> where
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Balance: Encode,
    T::Balance: Encode

impl<T: Config<I>, I: 'static> Encode for Call<T, I>

impl Encode for Reasons

impl<Balance> Encode for BalanceLock<Balance> where
    Balance: Encode,
    Balance: Encode

impl<ReserveIdentifier, Balance> Encode for ReserveData<ReserveIdentifier, Balance> where
    ReserveIdentifier: Encode,
    ReserveIdentifier: Encode,
    Balance: Encode,
    Balance: Encode

impl<Balance> Encode for AccountData<Balance> where
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode

impl<T: Config> Encode for Event<T> where
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T>

impl<Balance, BlockNumber> Encode for EscrowedAmount<Balance, BlockNumber> where
    Balance: Encode,
    Balance: Encode,
    BlockNumber: Encode,
    BlockNumber: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T> where
    T::AccountId: Encode,
    T::AccountId: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T> where
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T> where
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::Hash: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T> where
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T> where
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode,
    T::AccountId: Encode,
    T::AccountId: Encode,
    T::Hash: Encode,
    T::Hash: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Call<T>

impl<Balance> Encode for InclusionFee<Balance> where
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode,
    Balance: Encode

impl<Balance> Encode for FeeDetails<Balance> where
    Option<InclusionFee<Balance>>: Encode,
    Option<InclusionFee<Balance>>: Encode,
    Balance: Encode,
    Balance: Encode

impl<Balance> Encode for RuntimeDispatchInfo<Balance> where
    Balance: Encode,
    Balance: Encode

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Call<T>

impl<T: Config> Encode for Event<T>

impl<T: Config> Encode for Call<T>

impl Encode for U128

impl Encode for U256

impl Encode for U512

impl Encode for H128

impl Encode for H160

impl Encode for H256

impl Encode for H512

impl<T> Encode for UntrackedSymbol<T> where
    PhantomData<fn() -> T>: Encode,
    PhantomData<fn() -> T>: Encode

impl<T: Form> Encode for TypeDefComposite<T> where
    Vec<Field<T>>: Encode,
    Vec<Field<T>>: Encode

impl<T: Form> Encode for Field<T> where
    Option<T::String>: Encode,
    Option<T::String>: Encode,
    T::Type: Encode,
    T::Type: Encode,
    Option<T::String>: Encode,
    Option<T::String>: Encode,
    Vec<T::String>: Encode,
    Vec<T::String>: Encode

impl<T: Form> Encode for Path<T> where
    Vec<T::String>: Encode,
    Vec<T::String>: Encode

impl<T: Form> Encode for TypeDefVariant<T> where
    Vec<Variant<T>>: Encode,
    Vec<Variant<T>>: Encode

impl<T: Form> Encode for Variant<T> where
    T::String: Encode,
    T::String: Encode,
    Vec<Field<T>>: Encode,
    Vec<Field<T>>: Encode,
    Vec<T::String>: Encode,
    Vec<T::String>: Encode

impl<T: Form> Encode for Type<T> where
    Path<T>: Encode,
    Path<T>: Encode,
    Vec<TypeParameter<T>>: Encode,
    Vec<TypeParameter<T>>: Encode,
    TypeDef<T>: Encode,
    TypeDef<T>: Encode,
    Vec<T::String>: Encode,
    Vec<T::String>: Encode

impl<T: Form> Encode for TypeParameter<T> where
    T::String: Encode,
    T::String: Encode,
    Option<T::Type>: Encode,
    Option<T::Type>: Encode

impl<T: Form> Encode for TypeDef<T> where
    TypeDefComposite<T>: Encode,
    TypeDefComposite<T>: Encode,
    TypeDefVariant<T>: Encode,
    TypeDefVariant<T>: Encode,
    TypeDefSequence<T>: Encode,
    TypeDefSequence<T>: Encode,
    TypeDefArray<T>: Encode,
    TypeDefArray<T>: Encode,
    TypeDefTuple<T>: Encode,
    TypeDefTuple<T>: Encode,
    TypeDefCompact<T>: Encode,
    TypeDefCompact<T>: Encode,
    TypeDefBitSequence<T>: Encode,
    TypeDefBitSequence<T>: Encode

impl<T: Form> Encode for TypeDefArray<T> where
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for TypeDefTuple<T> where
    Vec<T::Type>: Encode,
    Vec<T::Type>: Encode

impl<T: Form> Encode for TypeDefSequence<T> where
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for TypeDefCompact<T> where
    T::Type: Encode,
    T::Type: Encode

impl<T: Form> Encode for TypeDefBitSequence<T> where
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode,
    T::Type: Encode

impl Encode for Public

impl Encode for Signature

impl Encode for Public

impl Encode for Signature

impl Encode for Public

impl Encode for Signature

impl Encode for BigUint

impl Encode for FixedI64

impl Encode for FixedI128

impl Encode for FixedU128

impl Encode for Percent

impl Encode for PerU16

impl Encode for Permill

impl Encode for Perbill

impl Encode for KeyTypeId

impl Encode for Public

impl Encode for Signature

impl Encode for Public

impl Encode for Signature

impl Encode for HttpError

impl Encode for Timestamp

impl Encode for Duration

impl Encode for HostError

impl Encode for Entry

impl Encode for Public

impl Encode for Signature

impl Encode for LogLevel

impl Encode for Void

impl<E> Encode for MakeFatalError<E> where
    E: Encode,
    E: Encode

impl<T: Encode + Decode> Encode for Crossing<T> where
    T: Encode,
    T: Encode

impl<Block: BlockT> Encode for BlockId<Block> where
    Block::Hash: Encode,
    Block::Hash: Encode,
    NumberFor<Block>: Encode,
    NumberFor<Block>: Encode

impl<Header, Extrinsic: MaybeSerialize> Encode for Block<Header, Extrinsic> where
    Header: Encode,
    Header: Encode,
    Vec<Extrinsic>: Encode,
    Vec<Extrinsic>: Encode

impl<Block> Encode for SignedBlock<Block> where
    Block: Encode,
    Block: Encode

impl Encode for Digest

impl<'a> Encode for DigestItemRef<'a>

impl Encode for Era

impl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Encode for Header<Number, Hash> where
    Hash::Output: Encode,
    Hash::Output: Encode,
    Hash::Output: Encode,
    Hash::Output: Encode,
    Hash::Output: Encode,
    Hash::Output: Encode,
    Number: HasCompact

impl<Call, Extra> Encode for SignedPayload<Call, Extra> where
    Call: Encode,
    Extra: SignedExtension

impl<Address, Call, Signature, Extra> Encode for UncheckedExtrinsic<Address, Call, Signature, Extra> where
    Address: Encode,
    Signature: Encode,
    Call: Encode,
    Extra: SignedExtension

impl<AccountId, AccountIndex> Encode for MultiAddress<AccountId, AccountIndex> where
    AccountId: Encode,
    AccountId: Encode,
    AccountIndex: HasCompact

impl Encode for Time

impl<Xt> Encode for ExtrinsicWrapper<Xt> where
    Xt: Encode,
    Xt: Encode

impl<Xt> Encode for Block<Xt> where
    Vec<Xt>: Encode,
    Vec<Xt>: Encode

impl<Call, Extra> Encode for TestXt<Call, Extra> where
    Option<(u64, Extra)>: Encode,
    Option<(u64, Extra)>: Encode,
    Call: Encode,
    Call: Encode

impl Encode for BadOrigin

impl<Info> Encode for DispatchErrorWithPostInfo<Info> where
    Info: Eq + PartialEq + Clone + Copy + Encode + Decode + Printable,
    Info: Encode,
    Info: Encode

impl<Reporter, Offender> Encode for OffenceDetails<Reporter, Offender> where
    Offender: Encode,
    Offender: Encode,
    Vec<Reporter>: Encode,
    Vec<Reporter>: Encode

impl Encode for Timestamp

impl Encode for WasmLevel

impl Encode for WasmValue

impl Encode for Value

impl Encode for Cogs

impl Encode for _0002_

impl Encode for _0003_

impl Encode for _0004_

impl Encode for _0005_

impl Encode for _0006_

impl Encode for _0007_

impl Encode for _0008_

impl Encode for _0009_

impl Encode for _0010_

impl Encode for _0011_

impl Encode for _0012_

impl Encode for _0013_

impl Encode for _0014_

impl Encode for _0015_

impl Encode for _0016_

impl Encode for _0017_

impl Encode for _0018_

impl Encode for _0019_

impl Encode for _0020_

impl Encode for _0021_

impl Encode for _0022_

impl Encode for _0023_

impl Encode for _0024_

impl Encode for _0025_

impl Encode for _0026_

impl Encode for _0027_

impl Encode for _0028_

impl Encode for _0029_

impl Encode for _0030_

impl Encode for _0031_

impl Encode for _0032_

impl Encode for _0033_

impl Encode for _0034_

impl Encode for _0035_

impl Encode for _0036_

impl Encode for _0038_

impl Encode for _1001_

impl Encode for _2001_

impl Encode for _2002_

impl Encode for _2003_

impl Encode for _2004_

impl Encode for _2005_

impl Encode for _3001_

impl Encode for Inventory

impl Encode for Coins

impl Encode for Tokens

impl Encode for Parties

impl Encode for _3003_

impl Encode for Sales

impl Encode for _1002_

impl Encode for A

impl Encode for L

impl Encode for E

impl Encode for I

impl Encode for X

impl Encode for P

impl Encode for B

impl Encode for Ledger

impl Encode for Indicator

impl<AccountId, Hash, BlockNumber> Encode for Record<AccountId, Hash, BlockNumber> where
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    Hash: Encode,
    Hash: Encode,
    BlockNumber: Encode,
    BlockNumber: Encode,
    BlockNumber: Encode,
    BlockNumber: Encode

impl Encode for Reason

impl<Hash> Encode for TxKeysT<Hash> where
    Hash: Encode,
    Hash: Encode

impl<AccountId> Encode for OrderHeader<AccountId> where
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode

impl<Hash> Encode for OrderItem<Hash> where
    Hash: Encode,
    Hash: Encode

impl<Hash> Encode for TxKeysL<Hash> where
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode

impl<Hash> Encode for TxKeysM<Hash> where
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode

impl<Hash> Encode for TxKeysS<Hash> where
    Hash: Encode,
    Hash: Encode,
    Hash: Encode,
    Hash: Encode

impl<AccountId, ProjectStatus> Encode for DeletedProject<AccountId, ProjectStatus> where
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    AccountId: Encode,
    ProjectStatus: Encode,
    ProjectStatus: Encode

impl<AccountId, ReferenceHash, NumberOfBlocks, LockStatus, StatusOfTimeRecord, ReasonCodeStruct, PostingPeriod, StartOrEndBlockNumber, NumberOfBreaks> Encode for Timekeeper<AccountId, ReferenceHash, NumberOfBlocks, LockStatus, StatusOfTimeRecord, ReasonCodeStruct, PostingPeriod, StartOrEndBlockNumber, NumberOfBreaks> where
    AccountId: Encode,
    AccountId: Encode,
    ReferenceHash: Encode,
    ReferenceHash: Encode,
    NumberOfBlocks: Encode,
    NumberOfBlocks: Encode,
    LockStatus: Encode,
    LockStatus: Encode,
    ReasonCodeStruct: Encode,
    ReasonCodeStruct: Encode,
    StatusOfTimeRecord: Encode,
    StatusOfTimeRecord: Encode,
    ReasonCodeStruct: Encode,
    ReasonCodeStruct: Encode,
    PostingPeriod: Encode,
    PostingPeriod: Encode,
    StartOrEndBlockNumber: Encode,
    StartOrEndBlockNumber: Encode,
    StartOrEndBlockNumber: Encode,
    StartOrEndBlockNumber: Encode,
    NumberOfBreaks: Encode,
    NumberOfBreaks: Encode

impl<T> Encode for Set<T> where
    Vec<T>: Encode,
    Vec<T>: Encode