AccountIdConversion

Trait AccountIdConversion 

Source
pub trait AccountIdConversion<AccountId>: Sized {
    // Required methods
    fn into_sub_account<S: Encode>(&self, sub: S) -> AccountId;
    fn try_from_sub_account<S: Decode>(x: &AccountId) -> Option<(Self, S)>;

    // Provided methods
    fn into_account(&self) -> AccountId { ... }
    fn try_from_account(a: &AccountId) -> Option<Self> { ... }
}
Expand description

This type can be converted into and possibly from an AccountId (which itself is generic).

Required Methods§

Source

fn into_sub_account<S: Encode>(&self, sub: S) -> AccountId

Convert this value amalgamated with the a secondary “sub” value into an account ID. This is infallible.

NOTE: The account IDs from this and from into_account are not guaranteed to be distinct for any given value of self, nor are different invocations to this with different types T. For example, the following will all encode to the same account ID value:

  • self.into_sub_account(0u32)
  • self.into_sub_account(vec![0u8; 0])
  • self.into_account()
Source

fn try_from_sub_account<S: Decode>(x: &AccountId) -> Option<(Self, S)>

Try to convert an account ID into this type. Might not succeed.

Provided Methods§

Source

fn into_account(&self) -> AccountId

Convert into an account ID. This is infallible.

Source

fn try_from_account(a: &AccountId) -> Option<Self>

Try to convert an account ID into this type. Might not succeed.

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: Encode + Decode + Default, Id: Encode + Decode + TypeId> AccountIdConversion<T> for Id

Format is TYPE_ID ++ encode(parachain ID) ++ 00…. where 00… is indefinite trailing zeroes to fill AccountId.