pub trait WeightTrader: Sized {
// Required methods
fn new() -> Self;
fn buy_weight(
&mut self,
weight: Weight,
payment: AssetsInHolding,
context: &XcmContext,
) -> Result<AssetsInHolding, XcmError>;
// Provided method
fn refund_weight(
&mut self,
_weight: Weight,
_context: &XcmContext,
) -> Option<Asset> { ... }
}Expand description
Charge for weight in order to execute XCM.
A WeightTrader may also be put into a tuple, in which case the default behavior of
buy_weight and refund_weight would be to attempt to call each tuple element’s own
implementation of these two functions, in the order of which they appear in the tuple,
returning early when a successful result is returned.
Required Methods§
Sourcefn buy_weight(
&mut self,
weight: Weight,
payment: AssetsInHolding,
context: &XcmContext,
) -> Result<AssetsInHolding, XcmError>
fn buy_weight( &mut self, weight: Weight, payment: AssetsInHolding, context: &XcmContext, ) -> Result<AssetsInHolding, XcmError>
Purchase execution weight credit in return for up to a given payment. If less of the
payment is required then the surplus is returned. If the payment cannot be used to pay
for the weight, then an error is returned.
Provided Methods§
Sourcefn refund_weight(
&mut self,
_weight: Weight,
_context: &XcmContext,
) -> Option<Asset>
fn refund_weight( &mut self, _weight: Weight, _context: &XcmContext, ) -> Option<Asset>
Attempt a refund of weight into some asset. The caller does not guarantee that the weight
was purchased using buy_weight.
Default implementation refunds nothing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.