defuse_core::engine

Trait State

Source
pub trait State: StateView {
    // Required methods
    fn add_public_key(
        &mut self,
        account_id: AccountId,
        public_key: PublicKey,
    ) -> bool;
    fn remove_public_key(
        &mut self,
        account_id: AccountId,
        public_key: PublicKey,
    ) -> bool;
    fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> bool;
    fn internal_add_balance(
        &mut self,
        owner_id: AccountId,
        tokens: impl IntoIterator<Item = (TokenId, u128)>,
    ) -> Result<()>;
    fn internal_sub_balance(
        &mut self,
        owner_id: &AccountIdRef,
        tokens: impl IntoIterator<Item = (TokenId, u128)>,
    ) -> Result<()>;
    fn ft_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: FtWithdraw,
    ) -> Result<()>;
    fn nft_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: NftWithdraw,
    ) -> Result<()>;
    fn mt_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: MtWithdraw,
    ) -> Result<()>;
    fn native_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: NativeWithdraw,
    ) -> Result<()>;
    fn storage_deposit(
        &mut self,
        owner_id: &AccountIdRef,
        storage_deposit: StorageDeposit,
    ) -> Result<()>;

    // Provided method
    fn internal_apply_deltas(
        &mut self,
        owner_id: &AccountIdRef,
        tokens: impl IntoIterator<Item = (TokenId, i128)>,
    ) -> Result<()> { ... }
}

Required Methods§

Source

fn add_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> bool

Source

fn remove_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> bool

Source

fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> bool

Source

fn internal_add_balance( &mut self, owner_id: AccountId, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source

fn internal_sub_balance( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source

fn ft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: FtWithdraw, ) -> Result<()>

Source

fn nft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NftWithdraw, ) -> Result<()>

Source

fn mt_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: MtWithdraw, ) -> Result<()>

Source

fn native_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NativeWithdraw, ) -> Result<()>

Source

fn storage_deposit( &mut self, owner_id: &AccountIdRef, storage_deposit: StorageDeposit, ) -> Result<()>

Provided Methods§

Source

fn internal_apply_deltas( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, i128)>, ) -> Result<()>

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.

Implementations on Foreign Types§

Source§

impl<T: State + ?Sized> State for &mut T

Source§

fn add_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> bool

Source§

fn remove_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> bool

Source§

fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> bool

Source§

fn internal_add_balance( &mut self, owner_id: AccountId, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_sub_balance( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_apply_deltas( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, i128)>, ) -> Result<()>

Source§

fn ft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: FtWithdraw, ) -> Result<()>

Source§

fn nft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NftWithdraw, ) -> Result<()>

Source§

fn mt_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: MtWithdraw, ) -> Result<()>

Source§

fn native_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NativeWithdraw, ) -> Result<()>

Source§

fn storage_deposit( &mut self, owner_id: &AccountIdRef, storage_deposit: StorageDeposit, ) -> Result<()>

Source§

impl<T: State + ?Sized> State for Box<T>

Source§

fn add_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> bool

Source§

fn remove_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> bool

Source§

fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> bool

Source§

fn internal_add_balance( &mut self, owner_id: AccountId, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_sub_balance( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_apply_deltas( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, i128)>, ) -> Result<()>

Source§

fn ft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: FtWithdraw, ) -> Result<()>

Source§

fn nft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NftWithdraw, ) -> Result<()>

Source§

fn mt_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: MtWithdraw, ) -> Result<()>

Source§

fn native_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NativeWithdraw, ) -> Result<()>

Source§

fn storage_deposit( &mut self, owner_id: &AccountIdRef, storage_deposit: StorageDeposit, ) -> Result<()>

Implementors§

Source§

impl<S> State for Deltas<S>
where S: State,

Source§

impl<W> State for CachedState<W>
where W: StateView,