Struct Vault
pub struct Vault { /* private fields */ }Expand description
Vault structure for domains that can hold native tokens, custom data, and non-native tokens.
Sharded vaults are more complex than base vaults - they support custom data storage and can hold both fungible and non-fungible tokens in addition to native tokens.
Implementations§
§impl Vault
impl Vault
pub const fn new(shard: NonZero<u64>) -> Vault
pub const fn new(shard: NonZero<u64>) -> Vault
Creates a new sharded vault on the specified shard.
The vault is initialized with zero balance and no custom data.
§Parameters
shard- shard identifier for the new vault
§Examples
use std::num::NonZero;
use delta_primitives::vault::sharded::{Vault, ReadableShardedVault};
let vault = Vault::new(NonZero::new(3).unwrap());
assert_eq!(vault.shard(), 3);Trait Implementations§
§impl<'de> Deserialize<'de> for Vault
impl<'de> Deserialize<'de> for Vault
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vault, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vault, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl ReadableNativeBalance for Vault
impl ReadableNativeBalance for Vault
§impl ReadableShardedVault for Vault
impl ReadableShardedVault for Vault
§fn data(&self) -> Option<&VaultDataType>
fn data(&self) -> Option<&VaultDataType>
Returns the custom data stored in the vault, if any.
§fn token_balance(&self, kind: &TokenKind) -> u64
fn token_balance(&self, kind: &TokenKind) -> u64
Returns the balance of a specific token type in the vault. Read more
§impl Serialize for Vault
impl Serialize for Vault
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
§impl WritableNativeBalance for Vault
impl WritableNativeBalance for Vault
§fn set_balance(&mut self, balance: u64)
fn set_balance(&mut self, balance: u64)
Sets the native token balance of the vault. Read more
§fn checked_add_balance(&mut self, balance: u64) -> Result<(), VaultError>
fn checked_add_balance(&mut self, balance: u64) -> Result<(), VaultError>
Adds to the native token balance with overflow checking. Read more
§fn checked_sub_balance(&mut self, balance: u64) -> Result<(), VaultError>
fn checked_sub_balance(&mut self, balance: u64) -> Result<(), VaultError>
Subtracts from the native token balance with underflow checking. Read more
§fn saturating_add_balance(&mut self, balance: u64)
fn saturating_add_balance(&mut self, balance: u64)
Adds to the native token balance with saturation. Read more
§fn saturating_sub_balance(&mut self, balance: u64)
fn saturating_sub_balance(&mut self, balance: u64)
Subtracts from the native token balance with saturation. Read more
§impl WritableShardedVault for Vault
impl WritableShardedVault for Vault
§fn set_data(&mut self, data: Option<VaultDataType>)
fn set_data(&mut self, data: Option<VaultDataType>)
Sets the custom data for the vault. Read more
§fn apply_diff(&mut self, diff: &StateDiffOperation) -> Result<(), VaultError>
fn apply_diff(&mut self, diff: &StateDiffOperation) -> Result<(), VaultError>
Applies a state diff operation to the vault. Read more
§fn set_token_balance(
&mut self,
token_kind: &TokenKind,
balance: u64,
) -> Result<(), VaultError>
fn set_token_balance( &mut self, token_kind: &TokenKind, balance: u64, ) -> Result<(), VaultError>
Sets the balance of a fungible token type in the vault. Read more
§fn set_nft_holdings(
&mut self,
token_kind: &TokenKind,
balance: BTreeSet<u64>,
) -> Result<(), VaultError>
fn set_nft_holdings( &mut self, token_kind: &TokenKind, balance: BTreeSet<u64>, ) -> Result<(), VaultError>
Sets holdings of a specific NFT token in the vault. Read more
§fn checked_add_token_balance(
&mut self,
token_kind: &TokenKind,
balance: u64,
) -> Result<(), VaultError>
fn checked_add_token_balance( &mut self, token_kind: &TokenKind, balance: u64, ) -> Result<(), VaultError>
Adds to a token balance with overflow checking. Read more
§fn checked_sub_token_balance(
&mut self,
token_kind: &TokenKind,
balance: u64,
) -> Result<(), VaultError>
fn checked_sub_token_balance( &mut self, token_kind: &TokenKind, balance: u64, ) -> Result<(), VaultError>
Subtracts from a token balance with underflow checking. Read more
impl Eq for Vault
impl StructuralPartialEq for Vault
Auto Trait Implementations§
impl Freeze for Vault
impl RefUnwindSafe for Vault
impl Send for Vault
impl Sync for Vault
impl Unpin for Vault
impl UnwindSafe for Vault
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
§impl<T, K> Signable<K> for Twhere
T: Serialize,
K: SigningKey,
impl<T, K> Signable<K> for Twhere
T: Serialize,
K: SigningKey,
§impl<T> VaultFormatter for Twhere
T: ReadableShardedVault,
impl<T> VaultFormatter for Twhere
T: ReadableShardedVault,
§fn fmt_full<W>(
&self,
f: &mut W,
address: &Address,
metadata: &HashMap<Address, VaultDataType>,
) -> Result<(), Error>where
W: Write,
fn fmt_full<W>(
&self,
f: &mut W,
address: &Address,
metadata: &HashMap<Address, VaultDataType>,
) -> Result<(), Error>where
W: Write,
Print out complete vault details Read more
§fn fmt_data<W>(
&self,
f: &mut W,
metadata: &HashMap<Address, VaultDataType>,
) -> Result<(), Error>where
W: Write,
fn fmt_data<W>(
&self,
f: &mut W,
metadata: &HashMap<Address, VaultDataType>,
) -> Result<(), Error>where
W: Write,
Prettyprints the vault data information Read more