Struct staging_xcm_executor::Assets
source · pub struct Assets {
pub fungible: BTreeMap<AssetId, u128>,
pub non_fungible: BTreeSet<(AssetId, AssetInstance)>,
}Expand description
List of non-wildcard fungible and non-fungible assets.
Fields§
§fungible: BTreeMap<AssetId, u128>The fungible assets.
non_fungible: BTreeSet<(AssetId, AssetInstance)>The non-fungible assets.
Implementations§
source§impl Assets
impl Assets
sourcepub fn fungible_assets_iter(&self) -> impl Iterator<Item = MultiAsset> + '_
pub fn fungible_assets_iter(&self) -> impl Iterator<Item = MultiAsset> + '_
A borrowing iterator over the fungible assets.
sourcepub fn non_fungible_assets_iter(&self) -> impl Iterator<Item = MultiAsset> + '_
pub fn non_fungible_assets_iter(&self) -> impl Iterator<Item = MultiAsset> + '_
A borrowing iterator over the non-fungible assets.
sourcepub fn into_assets_iter(self) -> impl Iterator<Item = MultiAsset>
pub fn into_assets_iter(self) -> impl Iterator<Item = MultiAsset>
A consuming iterator over all assets.
sourcepub fn assets_iter(&self) -> impl Iterator<Item = MultiAsset> + '_
pub fn assets_iter(&self) -> impl Iterator<Item = MultiAsset> + '_
A borrowing iterator over all assets.
sourcepub fn subsume_assets(&mut self, assets: Assets)
pub fn subsume_assets(&mut self, assets: Assets)
Mutate self to contain all given assets, saturating if necessary.
NOTE: Assets are always sorted, allowing us to optimize this function from O(n^2) to
O(n).
sourcepub fn subsume(&mut self, asset: MultiAsset)
pub fn subsume(&mut self, asset: MultiAsset)
Mutate self to contain the given asset, saturating if necessary.
Wildcard values of asset do nothing.
sourcepub fn swapped(&mut self, with: Assets) -> Self
pub fn swapped(&mut self, with: Assets) -> Self
Swaps two mutable Assets, without deinitializing either one.
sourcepub fn prepend_location(&mut self, prepend: &MultiLocation)
pub fn prepend_location(&mut self, prepend: &MultiLocation)
Alter any concretely identified assets by prepending the given MultiLocation.
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: &MultiLocation,
context: InteriorMultiLocation,
maybe_failed_bin: Option<&mut Self>
)
pub fn reanchor( &mut self, target: &MultiLocation, context: InteriorMultiLocation, 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: &MultiAsset) -> bool
pub fn contains_asset(&self, asset: &MultiAsset) -> bool
Returns true if asset is contained within self.
sourcepub fn contains_assets(&self, assets: &MultiAssets) -> bool
pub fn contains_assets(&self, assets: &MultiAssets) -> bool
Returns true if all assets are contained within self.
sourcepub fn contains(&self, assets: &Assets) -> bool
pub fn contains(&self, assets: &Assets) -> bool
Returns true if all assets are contained within self.
sourcepub fn ensure_contains(&self, assets: &MultiAssets) -> Result<(), TakeError>
pub fn ensure_contains(&self, assets: &MultiAssets) -> 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: MultiAssetFilter) -> Assets
pub fn saturating_take(&mut self, asset: MultiAssetFilter) -> Assets
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: MultiAssetFilter) -> Result<Assets, TakeError>
pub fn try_take(&mut self, mask: MultiAssetFilter) -> Result<Assets, 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: MultiAsset) -> Result<Assets, Assets>
pub fn checked_sub(self, asset: MultiAsset) -> Result<Assets, Assets>
Consumes self and returns its original value excluding asset iff it contains at least
asset.
sourcepub fn min(&self, mask: &MultiAssetFilter) -> Assets
pub fn min(&self, mask: &MultiAssetFilter) -> Assets
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::Assets;
use xcm::latest::prelude::*;
let assets_i_have: Assets = vec![ (Here, 100).into(), ([0; 32], 100).into() ].into();
let assets_they_want: MultiAssetFilter = vec![ (Here, 200).into(), ([0; 32], 50).into() ].into();
let assets_we_can_trade: Assets = assets_i_have.min(&assets_they_want);
assert_eq!(assets_we_can_trade.into_assets_iter().collect::<Vec<_>>(), vec![
(Here, 100).into(), ([0; 32], 50).into(),
]);Trait Implementations§
source§impl From<Assets> for MultiAssets
impl From<Assets> for MultiAssets
source§impl From<MultiAsset> for Assets
impl From<MultiAsset> for Assets
source§fn from(asset: MultiAsset) -> Assets
fn from(asset: MultiAsset) -> Assets
source§impl From<MultiAssets> for Assets
impl From<MultiAssets> for Assets
source§fn from(assets: MultiAssets) -> Assets
fn from(assets: MultiAssets) -> Assets
source§impl PartialEq for Assets
impl PartialEq for Assets
impl Eq for Assets
impl StructuralPartialEq for Assets
Auto Trait Implementations§
impl RefUnwindSafe for Assets
impl Send for Assets
impl Sync for Assets
impl Unpin for Assets
impl UnwindSafe for Assets
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<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
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
§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, 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<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.