Trait bonsaidb::core::connection::AsyncConnection
source · pub trait AsyncConnection: AsyncLowLevelConnection + Sized + Send + Sync {
type Storage: AsyncStorageConnection<Database = Self>;
// Required methods
fn storage(&self) -> Self::Storage;
fn list_executed_transactions<'life0, 'async_trait>(
&'life0 self,
starting_id: Option<u64>,
result_limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<Executed>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn last_transaction_id<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn compact<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn compact_key_value_store<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn collection<C>(&self) -> AsyncCollection<'_, Self, C>
where C: Collection { ... }
fn view<V>(&self) -> AsyncView<'_, Self, V, <V as View>::Key>
where V: SerializedView { ... }
fn compact_collection<'life0, 'async_trait, C>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
C: 'async_trait + Collection,
Self: 'async_trait { ... }
}
Expand description
A connection to a database’s Schema
, giving access to
Collection
s and
Views
s. All functions on this trait are safe to use
in an asynchronous context.
Required Associated Types§
sourcetype Storage: AsyncStorageConnection<Database = Self>
type Storage: AsyncStorageConnection<Database = Self>
The AsyncStorageConnection
type that is paired with this type.
Required Methods§
sourcefn storage(&self) -> Self::Storage
fn storage(&self) -> Self::Storage
Returns the StorageConnection
implementor that this database belongs
to.
sourcefn list_executed_transactions<'life0, 'async_trait>(
&'life0 self,
starting_id: Option<u64>,
result_limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<Executed>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn list_executed_transactions<'life0, 'async_trait>(
&'life0 self,
starting_id: Option<u64>,
result_limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<Executed>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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
.
sourcefn last_transaction_id<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn last_transaction_id<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Fetches the last transaction id that has been committed, if any.
sourcefn compact<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn compact<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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.
sourcefn compact_key_value_store<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn compact_key_value_store<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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§
sourcefn collection<C>(&self) -> AsyncCollection<'_, Self, C>where
C: Collection,
fn collection<C>(&self) -> AsyncCollection<'_, Self, C>where
C: Collection,
Accesses a collection for the connected Schema
.
sourcefn view<V>(&self) -> AsyncView<'_, Self, V, <V as View>::Key>where
V: SerializedView,
fn view<V>(&self) -> AsyncView<'_, Self, V, <V as View>::Key>where
V: SerializedView,
Accesses a schema::View
from this connection.
sourcefn compact_collection<'life0, 'async_trait, C>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
C: 'async_trait + Collection,
Self: 'async_trait,
fn compact_collection<'life0, 'async_trait, C>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
C: 'async_trait + Collection,
Self: 'async_trait,
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
Error::CollectionNotFound
: databasename
does not exist.Error::Other
: an error occurred while compacting the database.
Object Safety§
Implementors§
source§impl AsyncConnection for AsyncRemoteDatabase
impl AsyncConnection for AsyncRemoteDatabase
type Storage = AsyncClient
source§impl AsyncConnection for AsyncDatabase
impl AsyncConnection for AsyncDatabase
type Storage = AsyncStorage
source§impl<B> AsyncConnection for ServerDatabase<B>where
B: Backend,
impl<B> AsyncConnection for ServerDatabase<B>where
B: Backend,
Pass-through implementation