Trait DatabaseCommit
pub trait DatabaseCommit {
// Required method
fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>);
// Provided method
fn commit_iter(
&mut self,
changes: &mut dyn Iterator<Item = (Address, Account)>,
) { ... }
}Expand description
EVM database commit interface.
§Dyn Compatibility
This trait is dyn-compatible. The commit_iter method uses &mut dyn Iterator
which allows it to be called on trait objects while remaining in the vtable.
Required Methods§
fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>)
fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>)
Commit changes to the database.
Provided Methods§
fn commit_iter(&mut self, changes: &mut dyn Iterator<Item = (Address, Account)>)
fn commit_iter(&mut self, changes: &mut dyn Iterator<Item = (Address, Account)>)
Commit changes to the database with an iterator.
Implementors of DatabaseCommit should override this method when possible for efficiency.
Callers should prefer using DatabaseCommit::commit when they already have a HashMap.
§Dyn Compatibility
This method uses &mut dyn Iterator to remain object-safe and callable on trait objects.
For ergonomic usage with impl IntoIterator, use the inherent method
commit_from_iter on dyn DatabaseCommit.
Implementations§
§impl dyn DatabaseCommit
Inherent implementation for dyn DatabaseCommit trait objects.
impl dyn DatabaseCommit
Inherent implementation for dyn DatabaseCommit trait objects.
This provides commit_from_iter as an ergonomic wrapper around the trait’s
commit_iter method, accepting impl IntoIterator for convenience.
pub fn commit_from_iter(
&mut self,
changes: impl IntoIterator<Item = (Address, Account)>,
)
pub fn commit_from_iter( &mut self, changes: impl IntoIterator<Item = (Address, Account)>, )
Commit changes to the database with an iterator.
This is an ergonomic wrapper that accepts impl IntoIterator and delegates
to the trait’s commit_iter method.