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
impl AssetsInHolding
sourcepub fn fungible_assets_iter(&self) -> impl Iterator<Item = Asset> + '_
pub fn fungible_assets_iter(&self) -> impl Iterator<Item = Asset> + '_
A borrowing iterator over the fungible assets.
sourcepub fn non_fungible_assets_iter(&self) -> impl Iterator<Item = Asset> + '_
pub fn non_fungible_assets_iter(&self) -> impl Iterator<Item = Asset> + '_
A borrowing iterator over the non-fungible assets.
sourcepub fn into_assets_iter(self) -> impl Iterator<Item = Asset>
pub fn into_assets_iter(self) -> impl Iterator<Item = Asset>
A consuming iterator over all assets.
sourcepub fn assets_iter(&self) -> impl Iterator<Item = Asset> + '_
pub fn assets_iter(&self) -> impl Iterator<Item = Asset> + '_
A borrowing iterator over all assets.
sourcepub fn subsume_assets(&mut self, assets: AssetsInHolding)
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).
sourcepub fn subsume(&mut self, asset: Asset)
pub fn subsume(&mut self, asset: Asset)
Mutate self to contain the given asset, saturating if necessary.
Wildcard values of asset do nothing.
sourcepub fn swapped(&mut self, with: AssetsInHolding) -> Self
pub fn swapped(&mut self, with: AssetsInHolding) -> Self
Swaps two mutable AssetsInHolding, without deinitializing either one.
sourcepub fn prepend_location(&mut self, prepend: &Location)
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.
sourcepub fn reanchor(
&mut self,
target: &Location,
context: &InteriorLocation,
maybe_failed_bin: Option<&mut Self>,
)
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.
sourcepub fn contains_asset(&self, asset: &Asset) -> bool
pub fn contains_asset(&self, asset: &Asset) -> bool
Returns true if asset is contained within self.
sourcepub fn contains_assets(&self, assets: &Assets) -> bool
pub fn contains_assets(&self, assets: &Assets) -> bool
Returns true if all assets are contained within self.
sourcepub fn contains(&self, assets: &AssetsInHolding) -> bool
pub fn contains(&self, assets: &AssetsInHolding) -> bool
Returns true if all assets are contained within self.
sourcepub fn ensure_contains(&self, assets: &Assets) -> Result<(), TakeError>
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.
sourcepub fn saturating_take(&mut self, asset: AssetFilter) -> AssetsInHolding
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.
sourcepub fn try_take(
&mut self,
mask: AssetFilter,
) -> Result<AssetsInHolding, TakeError>
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.
sourcepub fn checked_sub(
self,
asset: Asset,
) -> Result<AssetsInHolding, AssetsInHolding>
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.
sourcepub fn min(&self, mask: &AssetFilter) -> AssetsInHolding
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
impl Clone for AssetsInHolding
source§fn clone(&self) -> AssetsInHolding
fn clone(&self) -> AssetsInHolding
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for AssetsInHolding
impl Debug for AssetsInHolding
source§impl Default for AssetsInHolding
impl Default for AssetsInHolding
source§fn default() -> AssetsInHolding
fn default() -> AssetsInHolding
source§impl From<Asset> for AssetsInHolding
impl From<Asset> for AssetsInHolding
source§fn from(asset: Asset) -> AssetsInHolding
fn from(asset: Asset) -> AssetsInHolding
source§impl From<Assets> for AssetsInHolding
impl From<Assets> for AssetsInHolding
source§fn from(assets: Assets) -> AssetsInHolding
fn from(assets: Assets) -> AssetsInHolding
source§impl From<AssetsInHolding> for Assets
impl From<AssetsInHolding> for Assets
source§fn from(a: AssetsInHolding) -> Self
fn from(a: AssetsInHolding) -> Self
source§impl From<AssetsInHolding> for Vec<Asset>
impl From<AssetsInHolding> for Vec<Asset>
source§fn from(a: AssetsInHolding) -> Self
fn from(a: AssetsInHolding) -> Self
source§impl PartialEq for AssetsInHolding
impl PartialEq for AssetsInHolding
source§fn eq(&self, other: &AssetsInHolding) -> bool
fn eq(&self, other: &AssetsInHolding) -> bool
self and other values to be equal, and is used
by ==.impl Eq for AssetsInHolding
impl StructuralPartialEq for AssetsInHolding
Auto Trait Implementations§
impl Freeze for AssetsInHolding
impl RefUnwindSafe for AssetsInHolding
impl Send for AssetsInHolding
impl Sync for AssetsInHolding
impl Unpin for AssetsInHolding
impl UnwindSafe for AssetsInHolding
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
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moresource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.