Struct staging_xcm_executor::AssetsInHolding

source ·
pub struct AssetsInHolding {
    pub fungible: BTreeMap<AssetId, u128>,
    pub non_fungible: BTreeSet<(AssetId, AssetInstance)>,
}
Expand description

Map of non-wildcard fungible and non-fungible assets held in the holding register.

Fields§

§fungible: BTreeMap<AssetId, u128>

The fungible assets.

§non_fungible: BTreeSet<(AssetId, AssetInstance)>

The non-fungible assets.

Implementations§

source§

impl AssetsInHolding

source

pub fn new() -> Self

New value, containing no assets.

source

pub fn len(&self) -> usize

Total number of distinct assets.

source

pub fn is_empty(&self) -> bool

Returns true if self contains no assets.

source

pub fn fungible_assets_iter(&self) -> impl Iterator<Item = Asset> + '_

A borrowing iterator over the fungible assets.

source

pub fn non_fungible_assets_iter(&self) -> impl Iterator<Item = Asset> + '_

A borrowing iterator over the non-fungible assets.

source

pub fn into_assets_iter(self) -> impl Iterator<Item = Asset>

A consuming iterator over all assets.

source

pub fn assets_iter(&self) -> impl Iterator<Item = Asset> + '_

A borrowing iterator over all assets.

source

pub fn subsume_assets(&mut self, assets: AssetsInHolding)

Mutate self to contain all given assets, saturating if necessary.

NOTE: AssetsInHolding are always sorted, allowing us to optimize this function from O(n^2) to O(n).

source

pub fn subsume(&mut self, asset: Asset)

Mutate self to contain the given asset, saturating if necessary.

Wildcard values of asset do nothing.

source

pub fn swapped(&mut self, with: AssetsInHolding) -> Self

Swaps two mutable AssetsInHolding, without deinitializing either one.

source

pub fn prepend_location(&mut self, prepend: &Location)

Alter any concretely identified assets by prepending the given Location.

WARNING: For now we consider this infallible and swallow any errors. It is thus the caller’s responsibility to ensure that any internal asset IDs are able to be prepended without overflow.

source

pub fn reanchor( &mut self, target: &Location, context: &InteriorLocation, maybe_failed_bin: Option<&mut Self>, )

Mutate the assets to be interpreted as the same assets from the perspective of a target chain. The local chain’s context is provided.

Any assets which were unable to be reanchored are introduced into failed_bin.

source

pub fn contains_asset(&self, asset: &Asset) -> bool

Returns true if asset is contained within self.

source

pub fn contains_assets(&self, assets: &Assets) -> bool

Returns true if all assets are contained within self.

source

pub fn contains(&self, assets: &AssetsInHolding) -> bool

Returns true if all assets are contained within self.

source

pub fn ensure_contains(&self, assets: &Assets) -> Result<(), TakeError>

Returns an error unless all assets are contained in self. In the case of an error, the first asset in assets which is not wholly in self is returned.

source

pub fn saturating_take(&mut self, asset: AssetFilter) -> AssetsInHolding

Mutates self to its original value less mask and returns true iff it contains at least mask.

Returns Ok with the non-wildcard equivalence of mask taken and mutates self to its value minus mask if self contains asset, and return Err otherwise.

source

pub fn try_take( &mut self, mask: AssetFilter, ) -> Result<AssetsInHolding, TakeError>

Mutates self to its original value less mask and returns true iff it contains at least mask.

Returns Ok with the non-wildcard equivalence of asset taken and mutates self to its value minus asset if self contains asset, and return Err otherwise.

source

pub fn checked_sub( self, asset: Asset, ) -> Result<AssetsInHolding, AssetsInHolding>

Consumes self and returns its original value excluding asset iff it contains at least asset.

source

pub fn min(&self, mask: &AssetFilter) -> AssetsInHolding

Return the assets in self, but (asset-wise) of no greater value than mask.

The number of unique assets which are returned will respect the count parameter in the counted wildcard variants of mask.

Example:

use staging_xcm_executor::AssetsInHolding;
use xcm::latest::prelude::*;
let assets_i_have: AssetsInHolding = vec![ (Here, 100).into(), (Junctions::from([GeneralIndex(0)]), 100).into() ].into();
let assets_they_want: AssetFilter = vec![ (Here, 200).into(), (Junctions::from([GeneralIndex(0)]), 50).into() ].into();

let assets_we_can_trade: AssetsInHolding = assets_i_have.min(&assets_they_want);
assert_eq!(assets_we_can_trade.into_assets_iter().collect::<Vec<_>>(), vec![
	(Here, 100).into(), (Junctions::from([GeneralIndex(0)]), 50).into(),
]);

Trait Implementations§

source§

impl Clone for AssetsInHolding

source§

fn clone(&self) -> AssetsInHolding

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 AssetsInHolding

source§

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

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

impl Default for AssetsInHolding

source§

fn default() -> AssetsInHolding

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

impl From<Asset> for AssetsInHolding

source§

fn from(asset: Asset) -> AssetsInHolding

Converts to this type from the input type.
source§

impl From<Assets> for AssetsInHolding

source§

fn from(assets: Assets) -> AssetsInHolding

Converts to this type from the input type.
source§

impl From<AssetsInHolding> for Assets

source§

fn from(a: AssetsInHolding) -> Self

Converts to this type from the input type.
source§

impl From<AssetsInHolding> for Vec<Asset>

source§

fn from(a: AssetsInHolding) -> Self

Converts to this type from the input type.
source§

impl From<Vec<Asset>> for AssetsInHolding

source§

fn from(assets: Vec<Asset>) -> AssetsInHolding

Converts to this type from the input type.
source§

impl PartialEq for AssetsInHolding

source§

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

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

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

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

impl Eq for AssetsInHolding

source§

impl StructuralPartialEq for AssetsInHolding

Auto Trait Implementations§

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> CheckedConversion for T

source§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
source§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> Clear for T
where T: Default + Eq + PartialEq,

source§

fn is_clear(&self) -> bool

True iff no bits are set.
source§

fn clear() -> T

Return the value of Self that is clear.
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> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> IntoKey<U> for T
where U: FromKey<T>,

source§

fn into_key(self) -> U

source§

impl<T> IsType<T> for T

source§

fn from_ref(t: &T) -> &T

Cast reference.
source§

fn into_ref(&self) -> &T

Cast reference.
source§

fn from_mut(t: &mut T) -> &mut T

Cast mutable reference.
source§

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

Cast mutable reference.
source§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatedConversion for T

source§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
source§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
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<T, U> TryIntoKey<U> for T
where U: TryFromKey<T>,

§

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

source§

fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>

source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
source§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T

source§

impl<T> MaybeDebug for T
where T: Debug,

source§

impl<T> MaybeRefUnwindSafe for T
where T: RefUnwindSafe,

source§

impl<T> Member for T
where T: Send + Sync + Debug + Eq + PartialEq + Clone + 'static,