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

source

pub fn new() -> Self

source

pub fn ada_value(amount: &BigInt) -> Self

Create a Value containing only ada tokens, given the quantity in lovelace.

source

pub fn token_value(cs: &CurrencySymbol, tn: &TokenName, amount: &BigInt) -> Self

Create a Value containing only the given quantity of the given token.

source

pub fn get_token_amount(&self, cs: &CurrencySymbol, tn: &TokenName) -> BigInt

Lookup the quantity of the given token.

source

pub fn get_ada_amount(&self) -> BigInt

Lookup the quantity of ada(unit: lovelace).

source

pub fn insert_token( &self, cs: &CurrencySymbol, tn: &TokenName, a: &BigInt, ) -> Self

Insert a new token into the value, or replace the existing quantity.

source

pub fn is_empty(&self) -> bool

Return true if the value don’t have any entries.

source

pub fn normalize(self) -> Self

Remove all tokens whose quantity is zero.

source

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.

source

pub fn filter<F>(self, f: F) -> Self

Apply a predicate to tokens.

source

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<'a, 'b> Add<&'a Value> for &'b Value

§

type Output = Value

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Value) -> Self::Output

Performs the + operation. Read more
source§

impl<'a> Add<&'a Value> for Value

§

type Output = Value

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Value) -> Self::Output

Performs the + operation. Read more
source§

impl<'a> Add<Value> for &'a Value

§

type Output = Value

The resulting type after applying the + operator.
source§

fn add(self, rhs: Value) -> Self::Output

Performs the + operation. Read more
source§

impl Add for Value

§

type Output = Value

The resulting type after applying the + operator.
source§

fn add(self, rhs: Value) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Value

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Hash for Value

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IsPlutusData for Value

source§

impl Mul<&BigInt> for &Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &BigInt) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a BigInt> for Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &BigInt) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Value> for &'b BigInt

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for BigInt

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for i16

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for i32

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for i64

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for i8

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for u16

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for u32

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for u64

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Value> for u8

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<BigInt> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: BigInt) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<BigInt> for Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: BigInt) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Value> for &'a BigInt

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Value) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Value> for BigInt

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Value) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<i16> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<i32> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<i64> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<i8> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<u16> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<u32> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<u64> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<u8> for &'a Value

§

type Output = Value

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for &Value

§

type Output = Value

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Neg for Value

§

type Output = Value

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Ord for Value

source§

fn cmp(&self, other: &Value) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Value

source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Value

source§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, 'b> Sub<&'a Value> for &'b Value

§

type Output = Value

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Value) -> Self::Output

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Value> for Value

§

type Output = Value

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Value) -> Self::Output

Performs the - operation. Read more
source§

impl<'a> Sub<Value> for &'a Value

§

type Output = Value

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Value) -> Self::Output

Performs the - operation. Read more
source§

impl Sub for Value

§

type Output = Value

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Value) -> Self::Output

Performs the - operation. Read more
source§

impl<'a> Sum<&'a Value> for Value

source§

fn sum<I: Iterator<Item = &'a Value>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum for Value

source§

fn sum<I: Iterator<Item = Value>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Zero for Value

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl Eq for Value

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V