Struct plutus_ledger_api::v1::value::Value
source · pub struct Value(pub BTreeMap<CurrencySymbol, BTreeMap<TokenName, BigInt>>);
Expand description
A value that can contain multiple asset classes
Tuple Fields§
§0: BTreeMap<CurrencySymbol, BTreeMap<TokenName, BigInt>>
Implementations§
source§impl Value
impl Value
pub fn new() -> Self
sourcepub fn ada_value(amount: &BigInt) -> Self
pub fn ada_value(amount: &BigInt) -> Self
Create a Value containing only ada tokens, given the quantity in lovelace.
sourcepub fn token_value(cs: &CurrencySymbol, tn: &TokenName, amount: &BigInt) -> Self
pub fn token_value(cs: &CurrencySymbol, tn: &TokenName, amount: &BigInt) -> Self
Create a Value containing only the given quantity of the given token.
sourcepub fn get_token_amount(&self, cs: &CurrencySymbol, tn: &TokenName) -> BigInt
pub fn get_token_amount(&self, cs: &CurrencySymbol, tn: &TokenName) -> BigInt
Lookup the quantity of the given token.
sourcepub fn get_ada_amount(&self) -> BigInt
pub fn get_ada_amount(&self) -> BigInt
Lookup the quantity of ada(unit: lovelace).
sourcepub fn insert_token(
&self,
cs: &CurrencySymbol,
tn: &TokenName,
a: &BigInt,
) -> Self
pub fn insert_token( &self, cs: &CurrencySymbol, tn: &TokenName, a: &BigInt, ) -> Self
Insert a new token into the value, or replace the existing quantity.
sourcepub fn map_amount<F>(self, f: F) -> Self
pub fn map_amount<F>(self, f: F) -> Self
Apply a function to each token of the value, and use its result as the new amount.
sourcepub fn filter_map_amount<F>(self, f: F) -> Self
pub fn filter_map_amount<F>(self, f: F) -> Self
Apply a function to each token of the value. If the result is None, the token entry will be removed.
Note that if the name-quantity map of any given currency symbols is empty, the currency entry will be removed from the top-level map entirely.
Trait Implementations§
source§impl IsPlutusData for Value
impl IsPlutusData for Value
fn to_plutus_data(&self) -> PlutusData
fn from_plutus_data(data: &PlutusData) -> Result<Self, PlutusDataError>
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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