ReadableShardedVault

Trait ReadableShardedVault 

pub trait ReadableShardedVault: ReadableNativeBalance {
    // Required methods
    fn shard(&self) -> u64;
    fn data(&self) -> Option<&VaultDataType>;
    fn token_balance(&self, token_kind: &TokenKind) -> u64;
    fn nft_holdings(&self, token_kind: &TokenKind) -> BTreeSet<u64>;
    fn tokens(&self) -> impl Iterator<Item = TokenKind>;
}
Expand description

Trait for read-only access to sharded vault data.

Required Methods§

fn shard(&self) -> u64

Returns the shard identifier that the vault belongs to.

fn data(&self) -> Option<&VaultDataType>

Returns the custom data stored in the vault, if any.

fn token_balance(&self, token_kind: &TokenKind) -> u64

Returns the balance of a specific token type in the vault.

This method can be used to query both native and non-native fungible token balances.

§Parameters
  • token_kind - type of token to query the balance for
§Returns

The balance in Planck or 0 if token_kind has no holdings or is an NFT.

fn nft_holdings(&self, token_kind: &TokenKind) -> BTreeSet<u64>

Returns the holdings of a specific non-fungible token type in the vault.

§Parameters
  • token_kind - type of NFT token to query holdings for
§Returns

The NFT holdings or a default empty value if token_kind has no holdings or is fungible.

fn tokens(&self) -> impl Iterator<Item = TokenKind>

Returns an iterator over all token kinds stored in this vault.

Note that the iterator may contain the native kind as well as both fungible and non-fungible kinds.

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§