Trait EnergyHandler
pub trait EnergyHandler: Send + Sync {
// Required methods
fn amount(&self, host: &mut dyn ServerHost) -> u32;
fn capacity(&self, host: &mut dyn ServerHost) -> u32;
fn insert(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
amount: u32,
) -> u32;
fn extract(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
amount: u32,
) -> u32;
}Expand description
A block’s energy (NeoForge’s EnergyHandler): stateless, given the host, and written only in
a transaction, as a ResourceHandler is.
Required Methods§
fn amount(&self, host: &mut dyn ServerHost) -> u32
fn amount(&self, host: &mut dyn ServerHost) -> u32
How much it holds.
fn capacity(&self, host: &mut dyn ServerHost) -> u32
fn capacity(&self, host: &mut dyn ServerHost) -> u32
How much it holds when full.
fn insert(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
amount: u32,
) -> u32
fn insert( &self, host: &mut dyn ServerHost, tx: &Transaction, amount: u32, ) -> u32
Puts up to amount in, in transaction tx: how much went. Never more than amount.
fn extract(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
amount: u32,
) -> u32
fn extract( &self, host: &mut dyn ServerHost, tx: &Transaction, amount: u32, ) -> u32
Takes up to amount out, in transaction tx: how much came. Never more than amount.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".