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§
Sourcefn into_sub_account<S: Encode>(&self, sub: S) -> AccountId
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()
Sourcefn try_from_sub_account<S: Decode>(x: &AccountId) -> Option<(Self, S)>
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§
Sourcefn into_account(&self) -> AccountId
fn into_account(&self) -> AccountId
Convert into an account ID. This is infallible.
Sourcefn try_from_account(a: &AccountId) -> Option<Self>
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.