[−][src]Module exonum_merkledb::access
High-level access to database.
Overview
The core type in this module is the Access
trait, which provides ability to access
indexes from the database. The Access
trait has several implementations:
Access
is implemented forRawAccess
es, that is, types that provide access to the entire database.Snapshot
,Fork
andReadonlyFork
fall into this category.Prefixed
restricts an access to a single namespace.Migration
s are used for data created during migrations. Similar toPrefixed
, migrations are separated by namespaces.Scratchpad
s can be used for temporary data. They are distinguished by namespaces as well.
CopyAccessExt
extends Access
and provides helper methods to instantiate indexes. This
is useful in quick-and-dirty testing. For more complex applications, consider deriving
data schema via FromAccess
.
Guarantees
- Namespaced accesses (
Prefixed
,Migration
s andScratchpad
s) do not intersect (i.e., do not have common indexes) for different namespaces. They also do not intersect for different access types, even for the same namespace; for example, aPrefixed
access can never access an index from aMigration
or aScratchpad
and vice versa. - For all listed
Access
implementations, different addresses within anAccess
correspond to different indexes. - However, if we consider multiple accesses, indexes can alias. For example, an index
with address
bar
from aPrefixed<&Fork>
in namespacefoo
can also be accessed via addressfoo.bar
from the underlyingFork
.
Structs
AccessError | Access error together with the location information. |
Prefixed | Access that prepends the specified prefix to each created view. The prefix is separated
from user-provided names with a dot char |
Enums
AccessErrorKind | Error that can be emitted during accessing an object from the database. |
Traits
Access | High-level access to database data. |
AccessExt | Extension trait allowing for easy access to indexes from any type implementing
|
AsReadonly | Converts index access to a readonly presentation. The conversion operation is cheap. |
CopyAccessExt | Extension trait allowing for easy access to indexes from any type implementing
|
FromAccess | Constructs an object atop the database. The constructed object provides access to data in the DB, akin to an object-relational mapping. |
RawAccess | Allows to read data from the database. The data consists of a snapshot and changes relative to this snapshot. Depending on the implementation, the changes can be empty, immutable or mutable. |
RawAccessMut | Allows to mutate data in indexes. |