Module matterdb::access[][src]

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 for RawAccesses, that is, types that provide access to the entire database. Snapshot, Fork and ReadonlyFork fall into this category.
  • Prefixed restricts an access to a single namespace.
  • Migrations are used for data created during migrations. Similar to Prefixed, migrations are separated by namespaces.
  • Scratchpads 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, Migrations and Scratchpads) 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, a Prefixed access can never access an index from a Migration or a Scratchpad and vice versa.
  • For all listed Access implementations, different addresses within an Access correspond to different indexes.
  • However, if we consider multiple accesses, indexes can alias. For example, an index with address bar from a Prefixed<&Fork> in namespace foo can also be accessed via address foo.bar from the underlying Fork.

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 Access.

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 Access + Copy.

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.