pub trait Token<T: Config>:
Copy
+ Clone
+ TestAuxiliaries {
// Required method
fn weight(&self) -> Weight;
// Provided method
fn influence_lowest_gas_limit(&self) -> bool { ... }
}
Expand description
This trait represents a token that can be used for charging GasMeter
.
There is no other way of charging it.
Implementing type is expected to be super lightweight hence Copy
(Clone
is added
for consistency). If inlined there should be no observable difference compared
to a hand-written code.
Required Methods§
Sourcefn weight(&self) -> Weight
fn weight(&self) -> Weight
Return the amount of gas that should be taken by this token.
This function should be really lightweight and must not fail. It is not expected that implementors will query the storage or do any kinds of heavy operations.
That said, implementors of this function still can run into overflows
while calculating the amount. In this case it is ok to use saturating operations
since on overflow they will return max_value
which should consume all gas.
Provided Methods§
Sourcefn influence_lowest_gas_limit(&self) -> bool
fn influence_lowest_gas_limit(&self) -> bool
Returns true if this token is expected to influence the lowest gas limit.
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.