Database

Struct Database 

Source
pub struct Database<Storage: KeyValueStorage> { /* private fields */ }
Expand description

A database abstraction for storing and retrieving domain data

This is a thin wrapper around a [KeyValueStorage] implementation that provides a more convenient interface for working with column families and ensures thread-safe access through Arc.

The database can be backed by different storage engines:

  • In-memory storage (with the in_memory feature)
  • RocksDB persistent storage (with the rocksdb feature)

Implementations§

Source§

impl<Storage: KeyValueStorageWithColumnFamilies> Database<Storage>

Source

pub fn new(db: Storage) -> Self

Create a new Database instance with the given storage backend

Trait Implementations§

Source§

impl<Storage: KeyValueStorageWithColumnFamilies> Clone for Database<Storage>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Storage: Debug + KeyValueStorage> Debug for Database<Storage>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Storage: KeyValueStorageWithColumnFamilies> GenericDatabase for Database<Storage>

Source§

type Storage = Storage

Storage implementing KeyValueStorage trait
Source§

fn storage(&self) -> &Self::Storage

Returns the storage reference
Source§

impl<S> DbCommandsPort for Database<S>
where S: KeyValueStorageWithColumnFamilies<ColumnFamilyIdentifier = ColumnFamilies, Error = StorageError> + Send + Sync + 'static,

Source§

impl<S> DbQueriesPort for Database<S>
where S: KeyValueStorageWithColumnFamilies<ColumnFamilyIdentifier = ColumnFamilies, Error = StorageError> + Send + Sync + 'static,

Auto Trait Implementations§

§

impl<Storage> Freeze for Database<Storage>

§

impl<Storage> RefUnwindSafe for Database<Storage>
where Storage: RefUnwindSafe,

§

impl<Storage> Send for Database<Storage>
where Storage: Sync + Send,

§

impl<Storage> Sync for Database<Storage>
where Storage: Sync + Send,

§

impl<Storage> Unpin for Database<Storage>

§

impl<Storage> UnwindSafe for Database<Storage>
where Storage: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Db> DynamicStorageManagement for Db
where Db: GenericDatabase, <Db as GenericDatabase>::Storage: DynamicStorageManagement,

§

fn add_column_family(&self, column_family: &str) -> Result<(), StorageError>

Add new column family to the database.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<Families, ColumnFamily, Db> RawBatchCommandConstructor<ColumnFamily, Families> for Db
where Db: GenericDatabase + 'static, ColumnFamily: StorageColumnFamily + ColumnFamilyResolver<Families>, Families: ColumnFamilies,

§

fn delete_raw_command( key: EncodedValue<'_>, ) -> Result<BatchCommand<'_, Families>, StorageError>

Create a delete command for a key.
§

fn put_raw_command<'a>( key: EncodedValue<'a>, value: EncodedValue<'a>, ) -> Result<BatchCommand<'a, Families>, StorageError>

Create a put command for a key and value.
§

impl<Db> RawDynamicBatchCommandConstructor for Db
where Db: GenericDatabase, <Db as GenericDatabase>::Storage: KeyValueStorage,

§

fn delete_raw_command<'a>( key: EncodedValue<'a>, column_family: &'a str, ) -> Result<BatchCommand<'a, &'a str>, StorageError>

Create a delete command for a given key.
§

fn put_raw_command<'a>( key: EncodedValue<'a>, value: EncodedValue<'a>, column_family: &'a str, ) -> Result<BatchCommand<'a, &'a str>, StorageError>

Create a put command for a key and value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<Db> StorageSnapshot for Db
where Db: GenericDatabase + 'static, <Db as GenericDatabase>::Storage: StorageSnapshot,

§

type Snapshot<'a> = <<Db as GenericDatabase>::Storage as StorageSnapshot>::Snapshot<'a>

The type of snapshots created by this [StorageSnapshot]
§

type Error = StorageError

Error that can occur during snapshotting
§

fn db_name(&self) -> &str

Returns the database name.
§

fn create_snapshot<P>( &self, path: P, ) -> Result<<Db as StorageSnapshot>::Snapshot<'_>, <Db as StorageSnapshot>::Error>
where P: AsRef<Path>,

Create a snapshot of the database at the target path. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more