Trait matterdb::access::Access[][src]

pub trait Access: Clone {
    type Base: RawAccess;
    fn get_index_metadata(
        self,
        addr: IndexAddress
    ) -> Result<Option<IndexMetadata>, AccessError>;
fn get_or_create_view(
        self,
        addr: IndexAddress,
        index_type: IndexType
    ) -> Result<ViewWithMetadata<Self::Base>, AccessError>;
fn group_keys<K: ?Sized>(
        self,
        base_addr: IndexAddress
    ) -> GroupKeys<Self::Base, K>
    where
        K: BinaryKey,
        Self::Base: AsReadonly<Readonly = Self::Base>
; }

High-level access to database data.

This trait is not intended to be implemented by the types outside the crate; indeed, it instantiates several crate-private types. Correspondingly, Access methods rarely need to be used directly; use its extension trait instead.

Examples

Access can be used as a bound on structured database objects and their readonly methods:

use matterdb::{access::Access, ListIndex, MapIndex};

struct Schema<T: Access> {
    list: ListIndex<T::Base, u64>,
    map: MapIndex<T::Base, str, u64>,
}

impl<T: Access> Schema<T> {
    fn get_some_data(&self) -> Option<u64> {
        Some(self.list.get(0)? + self.map.get("foo")?)
    }
}

Associated Types

type Base: RawAccess[src]

Raw access serving as the basis for created indexes.

Loading content...

Required methods

fn get_index_metadata(
    self,
    addr: IndexAddress
) -> Result<Option<IndexMetadata>, AccessError>
[src]

Gets index metadata at the specified address, or None if there is no index.

fn get_or_create_view(
    self,
    addr: IndexAddress,
    index_type: IndexType
) -> Result<ViewWithMetadata<Self::Base>, AccessError>
[src]

Gets or creates a generic view with the specified address.

fn group_keys<K: ?Sized>(
    self,
    base_addr: IndexAddress
) -> GroupKeys<Self::Base, K> where
    K: BinaryKey,
    Self::Base: AsReadonly<Readonly = Self::Base>, 
[src]

Returns an iterator over keys in a group with the specified address.

The iterator buffers keys in memory and may become inconsistent for accesses based on ReadonlyFork.

Loading content...

Implementors

impl<T: RawAccess> Access for GenericAccess<T>[src]

type Base = T

fn get_index_metadata(
    self,
    addr: IndexAddress
) -> Result<Option<IndexMetadata<Vec<u8>>>, AccessError>
[src]

fn get_or_create_view(
    self,
    addr: IndexAddress,
    index_type: IndexType
) -> Result<ViewWithMetadata<Self::Base>, AccessError>
[src]

fn group_keys<K: ?Sized>(
    self,
    base_addr: IndexAddress
) -> GroupKeys<Self::Base, K> where
    K: BinaryKey,
    Self::Base: AsReadonly<Readonly = Self::Base>, 
[src]

impl<T: RawAccess> Access for Migration<T>[src]

type Base = T

fn get_index_metadata(
    self,
    addr: IndexAddress
) -> Result<Option<IndexMetadata>, AccessError>
[src]

fn get_or_create_view(
    self,
    addr: IndexAddress,
    index_type: IndexType
) -> Result<ViewWithMetadata<Self::Base>, AccessError>
[src]

fn group_keys<K: ?Sized>(
    self,
    base_addr: IndexAddress
) -> GroupKeys<Self::Base, K> where
    K: BinaryKey,
    Self::Base: AsReadonly<Readonly = Self::Base>, 
[src]

impl<T: RawAccess> Access for Scratchpad<T>[src]

type Base = T

fn get_index_metadata(
    self,
    addr: IndexAddress
) -> Result<Option<IndexMetadata>, AccessError>
[src]

fn get_or_create_view(
    self,
    addr: IndexAddress,
    index_type: IndexType
) -> Result<ViewWithMetadata<Self::Base>, AccessError>
[src]

fn group_keys<K: ?Sized>(
    self,
    base_addr: IndexAddress
) -> GroupKeys<Self::Base, K> where
    K: BinaryKey,
    Self::Base: AsReadonly<Readonly = Self::Base>, 
[src]

impl<T: RawAccess> Access for Prefixed<T>[src]

type Base = T

fn get_index_metadata(
    self,
    addr: IndexAddress
) -> Result<Option<IndexMetadata>, AccessError>
[src]

fn get_or_create_view(
    self,
    addr: IndexAddress,
    index_type: IndexType
) -> Result<ViewWithMetadata<Self::Base>, AccessError>
[src]

fn group_keys<K: ?Sized>(
    self,
    base_addr: IndexAddress
) -> GroupKeys<Self::Base, K> where
    K: BinaryKey,
    Self::Base: AsReadonly<Readonly = Self::Base>, 
[src]

impl<T: RawAccess> Access for T[src]

type Base = Self

fn get_index_metadata(
    self,
    addr: IndexAddress
) -> Result<Option<IndexMetadata>, AccessError>
[src]

fn get_or_create_view(
    self,
    addr: IndexAddress,
    index_type: IndexType
) -> Result<ViewWithMetadata<Self::Base>, AccessError>
[src]

fn group_keys<K: ?Sized>(
    self,
    base_addr: IndexAddress
) -> GroupKeys<Self::Base, K> where
    K: BinaryKey,
    Self::Base: AsReadonly<Readonly = Self::Base>, 
[src]

Loading content...