Trait sc_service::config::Database [−][src]
pub trait Database<H>: Send + Sync where
H: Clone, { pub fn get(&self, col: u32, key: &[u8]) -> Option<Vec<u8, Global>>; pub fn lookup(&self, hash: &H) -> Option<Vec<u8, Global>>; pub fn commit(
&self,
transaction: Transaction<H>
) -> Result<(), DatabaseError> { ... } pub fn commit_ref(
&self,
transaction: &mut dyn Iterator<Item = ChangeRef<'a, H>>
) -> Result<(), DatabaseError> { ... } pub fn contains(&self, col: u32, key: &[u8]) -> bool { ... } pub fn with_get(&self, col: u32, key: &[u8], f: &mut dyn FnMut(&[u8])) { ... } pub fn set(
&self,
col: u32,
key: &[u8],
value: &[u8]
) -> Result<(), DatabaseError> { ... } pub fn remove(&self, col: u32, key: &[u8]) -> Result<(), DatabaseError> { ... } pub fn with_lookup(&self, hash: &H, f: &mut dyn FnMut(&[u8])) { ... } pub fn store(&self, hash: &H, preimage: &[u8]) -> Result<(), DatabaseError> { ... } pub fn release(&self, hash: &H) -> Result<(), DatabaseError> { ... } }
Required methods
pub fn get(&self, col: u32, key: &[u8]) -> Option<Vec<u8, Global>>[src]
Retrieve the value previously stored against key or None if
key is not currently in the database.
pub fn lookup(&self, hash: &H) -> Option<Vec<u8, Global>>[src]
Retrieve the first preimage previously stored for hash or None if no preimage is
currently stored.
Provided methods
pub fn commit(&self, transaction: Transaction<H>) -> Result<(), DatabaseError>[src]
Commit the transaction to the database atomically. Any further calls to get or lookup
will reflect the new state.
pub fn commit_ref(
&self,
transaction: &mut dyn Iterator<Item = ChangeRef<'a, H>>
) -> Result<(), DatabaseError>[src]
&self,
transaction: &mut dyn Iterator<Item = ChangeRef<'a, H>>
) -> Result<(), DatabaseError>
Commit the transaction to the database atomically. Any further calls to get or lookup
will reflect the new state.
pub fn contains(&self, col: u32, key: &[u8]) -> bool[src]
Check if the value exists in the database without retrieving it.
pub fn with_get(&self, col: u32, key: &[u8], f: &mut dyn FnMut(&[u8]))[src]
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
pub fn set(
&self,
col: u32,
key: &[u8],
value: &[u8]
) -> Result<(), DatabaseError>[src]
&self,
col: u32,
key: &[u8],
value: &[u8]
) -> Result<(), DatabaseError>
Set the value of key in col to value, replacing anything that is there currently.
pub fn remove(&self, col: u32, key: &[u8]) -> Result<(), DatabaseError>[src]
Remove the value of key in col.
pub fn with_lookup(&self, hash: &H, f: &mut dyn FnMut(&[u8]))[src]
Call f with the preimage stored for hash and return the result, or None if no preimage
is currently stored.
This may be faster than lookup since it doesn’t allocate.
Use with_lookup helper function if you need f to return a value from f
pub fn store(&self, hash: &H, preimage: &[u8]) -> Result<(), DatabaseError>[src]
Store the preimage of hash into the database, so that it may be looked up later with
Database::lookup. This may be called multiple times, but Database::lookup but subsequent
calls will ignore preimage and simply increase the number of references on hash.
pub fn release(&self, hash: &H) -> Result<(), DatabaseError>[src]
Release the preimage of hash from the database. An equal number of these to the number of
corresponding stores must have been given before it is legal for Database::lookup to
be unable to provide the preimage.
Trait Implementations
Implementations on Foreign Types
impl<H> Database<H> for MemDb<H> where
H: Clone + Send + Sync + Eq + PartialEq<H> + Default + Hash, [src]
impl<H> Database<H> for MemDb<H> where
H: Clone + Send + Sync + Eq + PartialEq<H> + Default + Hash, [src]