pub trait GasEncoder<Balance>: Sealed {
// Required methods
fn encode(gas_limit: U256, weight: Weight, deposit: Balance) -> U256;
fn decode(gas: U256) -> Option<(Weight, Balance)>;
// Provided method
fn as_encoded_values(weight: Weight, deposit: Balance) -> (Weight, Balance) { ... }
}
Expand description
Encodes/Decodes EVM gas values.
§Note
This is defined as a trait rather than standalone functions to allow
it to be added as an associated type to crate::Config
. This way,
it can be invoked without requiring the implementation bounds to be
explicitly specified.
This trait is sealed and cannot be implemented by downstream crates.
Required Methods§
Provided Methods§
Sourcefn as_encoded_values(weight: Weight, deposit: Balance) -> (Weight, Balance)
fn as_encoded_values(weight: Weight, deposit: Balance) -> (Weight, Balance)
Returns the encoded values of the specified weight and deposit.
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.
Implementations on Foreign Types§
Source§impl<Balance> GasEncoder<Balance> for ()
impl<Balance> GasEncoder<Balance> for ()
Source§fn encode(gas_limit: U256, weight: Weight, deposit: Balance) -> U256
fn encode(gas_limit: U256, weight: Weight, deposit: Balance) -> U256
The encoding follows the pattern g...grrppdd
, where:
dd
: log2 Deposit value, encoded in the lowest 2 digits.pp
: log2 Proof size, encoded in the next 2 digits.rr
: log2 Reference time, encoded in the next 2 digits.g...g
: Gas limit, encoded in the highest digits.
§Note
- The deposit value is maxed by 2^99 for u128 balance, and 2^63 for u64 balance.