pub trait Connection: LowLevelConnection + Sized + Send + Sync {
    type Storage: StorageConnection<Database = Self>;

    // Required methods
    fn storage(&self) -> Self::Storage;
    fn list_executed_transactions(
        &self,
        starting_id: Option<u64>,
        result_limit: Option<u32>
    ) -> Result<Vec<Executed>, Error>;
    fn last_transaction_id(&self) -> Result<Option<u64>, Error>;
    fn compact(&self) -> Result<(), Error>;
    fn compact_key_value_store(&self) -> Result<(), Error>;

    // Provided methods
    fn collection<C: Collection>(&self) -> Collection<'_, Self, C> { ... }
    fn view<V: SerializedView>(&self) -> View<'_, Self, V, V::Key> { ... }
    fn compact_collection<C: Collection>(&self) -> Result<(), Error> { ... }
}
Expand description

A connection to a database’s Schema, giving access to Collections and Viewss. This trait is not safe to use within async contexts and will block the current thread. For async access, use AsyncConnection.

Required Associated Types§

source

type Storage: StorageConnection<Database = Self>

The StorageConnection type that is paired with this type.

Required Methods§

source

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

Returns the StorageConnection implementor that this database belongs to.

source

fn list_executed_transactions( &self, starting_id: Option<u64>, result_limit: Option<u32> ) -> Result<Vec<Executed>, Error>

Lists executed transactions from this Schema. By default, a maximum of 1000 entries will be returned, but that limit can be overridden by setting result_limit. A hard limit of 100,000 results will be returned. To begin listing after another known transaction_id, pass transaction_id + 1 into starting_id.

source

fn last_transaction_id(&self) -> Result<Option<u64>, Error>

Fetches the last transaction id that has been committed, if any.

source

fn compact(&self) -> Result<(), Error>

Compacts the entire database to reclaim unused disk space.

This process is done by writing data to a new file and swapping the file once the process completes. This ensures that if a hardware failure, power outage, or crash occurs that the original collection data is left untouched.

Errors
  • Error::Other: an error occurred while compacting the database.
source

fn compact_key_value_store(&self) -> Result<(), Error>

Compacts the key value store to reclaim unused disk space.

This process is done by writing data to a new file and swapping the file once the process completes. This ensures that if a hardware failure, power outage, or crash occurs that the original collection data is left untouched.

Errors
  • Error::Other: an error occurred while compacting the database.

Provided Methods§

source

fn collection<C: Collection>(&self) -> Collection<'_, Self, C>

Accesses a collection for the connected Schema.

source

fn view<V: SerializedView>(&self) -> View<'_, Self, V, V::Key>

Accesses a schema::View from this connection.

source

fn compact_collection<C: Collection>(&self) -> Result<(), Error>

Compacts the collection to reclaim unused disk space.

This process is done by writing data to a new file and swapping the file once the process completes. This ensures that if a hardware failure, power outage, or crash occurs that the original collection data is left untouched.

Errors

Object Safety§

This trait is not object safe.

Implementors§