pub trait SubstateDatabase {
// Required methods
fn get_raw_substate_by_db_key(
&self,
partition_key: &DbPartitionKey,
sort_key: &DbSortKey,
) -> Option<Vec<u8>>;
fn list_raw_values_from_db_key(
&self,
partition_key: &DbPartitionKey,
from_sort_key: Option<&DbSortKey>,
) -> Box<dyn Iterator<Item = (DbSortKey, Vec<u8>)> + '_>;
}
Expand description
A read interface between Track and a database vendor.
Required Methods§
Sourcefn get_raw_substate_by_db_key(
&self,
partition_key: &DbPartitionKey,
sort_key: &DbSortKey,
) -> Option<Vec<u8>>
fn get_raw_substate_by_db_key( &self, partition_key: &DbPartitionKey, sort_key: &DbSortKey, ) -> Option<Vec<u8>>
Reads a substate value by its db partition and db sort key, or Option::None
if missing.
§Alternatives
It’s likely easier to use the get_substate
or
get_raw_substate
methods instead, which
allow providing logical keys.
These methods should also exist on the database type as long as the
SubstateDatabaseExtensions
trait is in scope.
Sourcefn list_raw_values_from_db_key(
&self,
partition_key: &DbPartitionKey,
from_sort_key: Option<&DbSortKey>,
) -> Box<dyn Iterator<Item = (DbSortKey, Vec<u8>)> + '_>
fn list_raw_values_from_db_key( &self, partition_key: &DbPartitionKey, from_sort_key: Option<&DbSortKey>, ) -> Box<dyn Iterator<Item = (DbSortKey, Vec<u8>)> + '_>
Iterates over all entries of the given partition (starting either from the beginning, or
from the given DbSortKey
), in a lexicographical order (ascending) of the DbSortKey
s.
Note: If the exact given starting key does not exist, the iteration starts with its
immediate successor.
§Alternatives
There are lots of methods starting list_
which allow iterating using more intuitive abstractions.
These methods are present as long as the SubstateDatabaseExtensions
trait is in scope.