Trait gear_common::gas_provider::LockableTree
source · pub trait LockableTree: Tree {
// Required methods
fn lock(
key: impl Into<Self::NodeId>,
id: LockId,
amount: Self::Balance,
) -> Result<(), Self::Error>;
fn unlock(
key: impl Into<Self::NodeId>,
id: LockId,
amount: Self::Balance,
) -> Result<(), Self::Error>;
fn get_lock(
key: impl Into<Self::NodeId>,
id: LockId,
) -> Result<Self::Balance, Self::Error>;
// Provided method
fn unlock_all(
key: impl Into<Self::NodeId>,
id: LockId,
) -> Result<Self::Balance, Self::Error> { ... }
}
Required Methods§
sourcefn lock(
key: impl Into<Self::NodeId>,
id: LockId,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn lock( key: impl Into<Self::NodeId>, id: LockId, amount: Self::Balance, ) -> Result<(), Self::Error>
Locking some value from underlying node balance.
If key
does not identify any value or the amount
exceeds what’s
locked under that key, an error is returned.
This can’t create imbalance as no value is burned or created.
sourcefn unlock(
key: impl Into<Self::NodeId>,
id: LockId,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn unlock( key: impl Into<Self::NodeId>, id: LockId, amount: Self::Balance, ) -> Result<(), Self::Error>
Unlocking some value from node’s locked balance.
If key
does not identify any value or the amount
exceeds what’s
locked under that key, an error is returned.
This can’t create imbalance as no value is burned or created.
sourcefn get_lock(
key: impl Into<Self::NodeId>,
id: LockId,
) -> Result<Self::Balance, Self::Error>
fn get_lock( key: impl Into<Self::NodeId>, id: LockId, ) -> Result<Self::Balance, Self::Error>
Get locked value associated with given id.
Returns errors in cases of absence associated with given key node,
or if such functionality is forbidden for specific node type:
for example, for GasNode::ReservedLocal
.
Provided Methods§
Object Safety§
This trait is not object safe.