Trait sc_service::config::Database
source · [−]pub trait Database<H>: Send + Sync where
H: Clone + AsRef<[u8]>, {
fn commit(&self, transaction: Transaction<H>) -> Result<(), DatabaseError>;
fn get(&self, col: u32, key: &[u8]) -> Option<Vec<u8, Global>>;
fn contains(&self, col: u32, key: &[u8]) -> bool { ... }
fn value_size(&self, col: u32, key: &[u8]) -> Option<usize> { ... }
fn with_get(&self, col: u32, key: &[u8], f: &mut dyn FnMut(&[u8])) { ... }
fn supports_ref_counting(&self) -> bool { ... }
fn sanitize_key(&self, _key: &mut Vec<u8, Global>) { ... }
}
Required Methods
fn commit(&self, transaction: Transaction<H>) -> Result<(), DatabaseError>
fn commit(&self, transaction: Transaction<H>) -> Result<(), DatabaseError>
Commit the transaction
to the database atomically. Any further calls to get
or lookup
will reflect the new state.
Provided Methods
Check if the value exists in the database without retrieving it.
Check value size in the database possibly without retrieving it.
Call f
with the value previously stored against key
.
This may be faster than get
since it doesn’t allocate.
Use with_get
helper function if you need f
to return a value from f
fn supports_ref_counting(&self) -> bool
fn supports_ref_counting(&self) -> bool
Check if database supports internal ref counting for state data.
For backwards compatibility returns false
by default.
fn sanitize_key(&self, _key: &mut Vec<u8, Global>)
fn sanitize_key(&self, _key: &mut Vec<u8, Global>)
Remove a possible path-prefix from the key.
Not all database implementations use a prefix for keys, so this function may be a noop.