Struct bonsaidb::local::AsyncDatabase [−][src]
pub struct AsyncDatabase { /* fields omitted */ }
Expand description
A database stored in BonsaiDb. This type is designed for use with
Tokio. For blocking (non-asynchronous) code, see the
Database
type instead.
Converting between Async and Blocking Types
AsyncDatabase
and Database
can be converted to and from each other
using:
AsyncDatabase::into_blocking()
AsyncDatabase::to_blocking()
AsyncDatabase::as_blocking()
Database::into_async()
Database::to_async()
Database::into_async_with_runtime()
Database::to_async_with_runtime()
Using Database
to create a single database
Database
provides an easy mechanism to open and access a single database:
// `bonsaidb_core` is re-exported to `bonsaidb::core` or `bonsaidb_local::core`.
use bonsaidb_core::schema::Collection;
// `bonsaidb_local` is re-exported to `bonsaidb::local` if using the omnibus crate.
use bonsaidb_local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Collection)]
#[collection(name = "blog-posts")]
struct BlogPost {
pub title: String,
pub contents: String,
}
let db = AsyncDatabase::open::<BlogPost>(StorageConfiguration::new("my-db.bonsaidb")).await?;
Under the hood, this initializes a AsyncStorage
instance pointing at
“./my-db.bonsaidb”. It then returns (or creates) a database named “default”
with the schema BlogPost
.
In this example, BlogPost
implements the
Collection
trait, and all collections can be used as
a Schema
.
Implementations
pub async fn open<DB>(
configuration: StorageConfiguration
) -> Result<AsyncDatabase, Error> where
DB: Schema,
pub async fn open<DB>(
configuration: StorageConfiguration
) -> Result<AsyncDatabase, Error> where
DB: Schema,
Creates a Storage
with a single-database named “default” with its data stored at path
.
pub fn with_effective_permissions(
&self,
effective_permissions: Permissions
) -> Option<AsyncDatabase>
pub fn with_effective_permissions(
&self,
effective_permissions: Permissions
) -> Option<AsyncDatabase>
Restricts an unauthenticated instance to having effective_permissions
.
Returns None
if a session has already been established.
Converts this instance into its blocking version, which is able to be used without async.
Converts this instance into its blocking version, which is able to be used without async.
Returns a reference to this instance’s blocking version, which is able to be used without async.
Trait Implementations
type Storage = AsyncStorage
type Storage = AsyncStorage
The AsyncStorageConnection
type that is paired with this type.
Returns the StorageConnection
implementor that this database belongs
to. Read more
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
. Read more
Fetches the last transaction id that has been committed, if any.
Compacts the entire database to reclaim unused disk space. Read more
pub fn compact_collection<'life0, 'async_trait, C>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: 'async_trait + Collection,
AsyncDatabase: 'async_trait,
pub fn compact_collection<'life0, 'async_trait, C>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: 'async_trait + Collection,
AsyncDatabase: 'async_trait,
Compacts the collection to reclaim unused disk space. Read more
Compacts the key value store to reclaim unused disk space. Read more
Accesses a collection for the connected Schema
.
Initializes View
for schema::View
V
.
pub fn execute_key_operation<'life0, 'async_trait>(
&'life0 self,
op: KeyOperation
) -> Pin<Box<dyn Future<Output = Result<Output, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn execute_key_operation<'life0, 'async_trait>(
&'life0 self,
op: KeyOperation
) -> Pin<Box<dyn Future<Output = Result<Output, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
Executes a single KeyOperation
.
fn set_key<S, V>(&'a self, key: S, value: &'a V) -> AsyncBuilder<'a, Self, V>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
where
S: Into<String>,
V: Serialize + Send + Sync,
fn set_key<S, V>(&'a self, key: S, value: &'a V) -> AsyncBuilder<'a, Self, V>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
where
S: Into<String>,
V: Serialize + Send + Sync,
impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
Sets key
to value
. This function returns a builder that is also a
Future. Awaiting the builder will execute Command::Set
with the options
given. Read more
fn set_binary_key<S>(
&'a self,
key: S,
bytes: &'a [u8]
) -> AsyncBuilder<'a, Self, ()>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
where
S: Into<String>,
fn set_binary_key<S>(
&'a self,
key: S,
bytes: &'a [u8]
) -> AsyncBuilder<'a, Self, ()>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
where
S: Into<String>,
impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
Sets key
to bytes
. This function returns a builder that is also
a Future. Awaiting the builder will execute Command::Set
with
the options given. Read more
fn set_numeric_key<S, V>(&self, key: S, value: V) -> AsyncBuilder<'_, Self, ()>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
where
S: Into<String>,
V: Into<Numeric>,
fn set_numeric_key<S, V>(&self, key: S, value: V) -> AsyncBuilder<'_, Self, ()>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
where
S: Into<String>,
V: Into<Numeric>,
impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: Serialize + Send + Sync, type Output = Result<KeyStatus, Error>;
Sets key
to value
. This stores the value as a Numeric
,
enabling atomic math operations to be performed on this key. This
function returns a builder that is also a Future. Awaiting the
builder will execute Command::Set
with the options given. Read more
fn increment_key_by<S, V>(&self, key: S, value: V) -> AsyncBuilder<'_, Self, V>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: TryFrom<Numeric, Error = IncompatibleTypeError>, type Output = Result<V, Error>;
where
S: Into<String> + Send + Sync,
V: Into<Numeric> + TryFrom<Numeric, Error = IncompatibleTypeError> + Send + Sync,
fn increment_key_by<S, V>(&self, key: S, value: V) -> AsyncBuilder<'_, Self, V>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: TryFrom<Numeric, Error = IncompatibleTypeError>, type Output = Result<V, Error>;
where
S: Into<String> + Send + Sync,
V: Into<Numeric> + TryFrom<Numeric, Error = IncompatibleTypeError> + Send + Sync,
impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: TryFrom<Numeric, Error = IncompatibleTypeError>, type Output = Result<V, Error>;
Increments key
by value
. The value stored must be a Numeric
,
otherwise an error will be returned. The result of the increment
will be the value
’s type. For example, if the stored value is
currently a u64
, but value
is a f64
, the current value will be
converted to an f64
, and the stored value will be an f64
. Read more
fn decrement_key_by<S, V>(&self, key: S, value: V) -> AsyncBuilder<'_, Self, V>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: TryFrom<Numeric, Error = IncompatibleTypeError>, type Output = Result<V, Error>;
where
S: Into<String> + Send + Sync,
V: Into<Numeric> + TryFrom<Numeric, Error = IncompatibleTypeError> + Send + Sync,
fn decrement_key_by<S, V>(&self, key: S, value: V) -> AsyncBuilder<'_, Self, V>ⓘNotable traits for AsyncBuilder<'a, K, V>impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: TryFrom<Numeric, Error = IncompatibleTypeError>, type Output = Result<V, Error>;
where
S: Into<String> + Send + Sync,
V: Into<Numeric> + TryFrom<Numeric, Error = IncompatibleTypeError> + Send + Sync,
impl<'a, K, V> Future for AsyncBuilder<'a, K, V> where
K: AsyncKeyValue,
V: TryFrom<Numeric, Error = IncompatibleTypeError>, type Output = Result<V, Error>;
Decrements key
by value
. The value stored must be a Numeric
,
otherwise an error will be returned. The result of the decrement
will be the value
’s type. For example, if the stored value is
currently a u64
, but value
is a f64
, the current value will be
converted to an f64
, and the stored value will be an f64
. Read more
fn get_key<S>(&self, key: S) -> AsyncBuilder<'_, Self>ⓘNotable traits for AsyncBuilder<'a, K>impl<'a, K> Future for AsyncBuilder<'a, K> where
K: AsyncKeyValue, type Output = Result<Option<Value>, Error>;
where
S: Into<String>,
fn get_key<S>(&self, key: S) -> AsyncBuilder<'_, Self>ⓘNotable traits for AsyncBuilder<'a, K>impl<'a, K> Future for AsyncBuilder<'a, K> where
K: AsyncKeyValue, type Output = Result<Option<Value>, Error>;
where
S: Into<String>,
impl<'a, K> Future for AsyncBuilder<'a, K> where
K: AsyncKeyValue, type Output = Result<Option<Value>, Error>;
Gets the value stored at key
. This function returns a builder that is also a
Future. Awaiting the builder will execute Command::Get
with the options
given. Read more
Deletes the value stored at key
.
The current namespace.
Access this Key-Value store within a namespace. When using the returned
Namespaced
instance, all keys specified will be separated into their
own storage designated by namespace
. Read more
pub fn apply_transaction<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction
) -> Pin<Box<dyn Future<Output = Result<Vec<OperationResult, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn apply_transaction<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction
) -> Pin<Box<dyn Future<Output = Result<Vec<OperationResult, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
Applies a Transaction
to the Schema
. If any
operation in the Transaction
fails, none of the operations will be
applied to the Schema
. Read more
pub fn get_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
id: DocumentId,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn get_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
id: DocumentId,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Retrieves the document with id
stored within the named collection
. Read more
pub fn list_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Range<DocumentId>,
order: Sort,
limit: Option<u32>,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn list_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Range<DocumentId>,
order: Sort,
limit: Option<u32>,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Retrieves all documents within the range of ids
from the named
collection
. To retrieve all documents, pass in ..
for ids
. Read more
pub fn list_headers_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Range<DocumentId>,
order: Sort,
limit: Option<u32>,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Vec<Header, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn list_headers_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Range<DocumentId>,
order: Sort,
limit: Option<u32>,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Vec<Header, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Retrieves all headers within the range of ids
from the named
collection
. To retrieve all documents, pass in ..
for ids
. Read more
pub fn count_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Range<DocumentId>,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn count_from_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Range<DocumentId>,
collection: &'life1 CollectionName
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Counts the number of documents within the range of ids
from the named
collection
. Read more
pub fn get_multiple_from_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [DocumentId],
collection: &'life2 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn get_multiple_from_collection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [DocumentId],
collection: &'life2 CollectionName
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
AsyncDatabase: 'async_trait,
Retrieves all documents matching ids
from the named collection
.
Documents that are not found are not returned, but no error will be
generated. Read more
pub fn compact_collection_by_name<'life0, 'async_trait>(
&'life0 self,
collection: CollectionName
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn compact_collection_by_name<'life0, 'async_trait>(
&'life0 self,
collection: CollectionName
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
Compacts the collection to reclaim unused disk space. Read more
pub fn query_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<Serialized, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn query_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<Serialized, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Queries for view entries from the named view
. Read more
pub fn query_by_name_with_docs<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<MappedSerializedDocuments, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn query_by_name_with_docs<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<MappedSerializedDocuments, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Queries for view entries from the named view
with their source
documents. Read more
pub fn reduce_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<u8, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn reduce_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<u8, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Reduces the view entries from the named view
. Read more
pub fn reduce_grouped_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<MappedSerializedValue, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn reduce_grouped_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<MappedSerializedValue, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Reduces the view entries from the named view
, reducing the values by each
unique key. Read more
pub fn delete_docs_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn delete_docs_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
view: &'life1 ViewName,
key: Option<QueryKey<Bytes>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
AsyncDatabase: 'async_trait,
Deletes all source documents for entries that match within the named
view
. Read more
fn insert<'life0, 'async_trait, C, PrimaryKey, B>(
&'life0 self,
id: Option<PrimaryKey>,
contents: B
) -> Pin<Box<dyn Future<Output = Result<CollectionHeader<<C as Collection>::PrimaryKey>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait + Send,
C: 'async_trait + Collection,
B: 'async_trait + Into<Bytes> + Send,
Self: 'async_trait,
fn insert<'life0, 'async_trait, C, PrimaryKey, B>(
&'life0 self,
id: Option<PrimaryKey>,
contents: B
) -> Pin<Box<dyn Future<Output = Result<CollectionHeader<<C as Collection>::PrimaryKey>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait + Send,
C: 'async_trait + Collection,
B: 'async_trait + Into<Bytes> + Send,
Self: 'async_trait,
Inserts a newly created document into the connected schema::Schema
for the Collection
C
. If id
is None
a unique id will be
generated. If an id is provided and a document already exists with that
id, a conflict error will be returned. Read more
fn update<'life0, 'life1, 'async_trait, C, D>(
&'life0 self,
doc: &'life1 mut D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
C: 'async_trait + Collection,
D: 'async_trait + Document<C> + Send + Sync,
Self: 'async_trait,
fn update<'life0, 'life1, 'async_trait, C, D>(
&'life0 self,
doc: &'life1 mut D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
C: 'async_trait + Collection,
D: 'async_trait + Document<C> + Send + Sync,
Self: 'async_trait,
Updates an existing document in the connected schema::Schema
for the
Collection
(schema::Collection) C
. Upon success, doc.revision
will be updated with the new revision. Read more
fn overwrite<'a, 'life0, 'async_trait, C, PrimaryKey>(
&'life0 self,
id: PrimaryKey,
contents: Vec<u8, Global>
) -> Pin<Box<dyn Future<Output = Result<CollectionHeader<<C as Collection>::PrimaryKey>, Error>> + Send + 'async_trait, Global>> where
'a: 'async_trait,
'life0: 'async_trait,
C: Collection + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
fn overwrite<'a, 'life0, 'async_trait, C, PrimaryKey>(
&'life0 self,
id: PrimaryKey,
contents: Vec<u8, Global>
) -> Pin<Box<dyn Future<Output = Result<CollectionHeader<<C as Collection>::PrimaryKey>, Error>> + Send + 'async_trait, Global>> where
'a: 'async_trait,
'life0: 'async_trait,
C: Collection + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
Overwrites an existing document, or inserts a new document. Upon success,
doc.revision
will be updated with the new revision information. Read more
fn get<'life0, 'async_trait, C, PrimaryKey>(
&'life0 self,
id: PrimaryKey
) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
fn get<'life0, 'async_trait, C, PrimaryKey>(
&'life0 self,
id: PrimaryKey
) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
Retrieves a stored document from Collection
C
identified by id
. Read more
fn get_multiple<'life0, 'async_trait, C, PrimaryKey, DocumentIds, I>(
&'life0 self,
ids: DocumentIds
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
DocumentIds: IntoIterator<Item = PrimaryKey, IntoIter = I> + Send + Sync + 'async_trait,
I: Iterator<Item = PrimaryKey> + Send + Sync + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
fn get_multiple<'life0, 'async_trait, C, PrimaryKey, DocumentIds, I>(
&'life0 self,
ids: DocumentIds
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
DocumentIds: IntoIterator<Item = PrimaryKey, IntoIter = I> + Send + Sync + 'async_trait,
I: Iterator<Item = PrimaryKey> + Send + Sync + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
Retrieves all documents matching ids
. Documents that are not found
are not returned, but no error will be generated. Read more
fn list<'life0, 'async_trait, C, R, PrimaryKey>(
&'life0 self,
ids: R,
order: Sort,
limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
R: Into<Range<PrimaryKey>> + Send + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
fn list<'life0, 'async_trait, C, R, PrimaryKey>(
&'life0 self,
ids: R,
order: Sort,
limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnedDocument, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
R: Into<Range<PrimaryKey>> + Send + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
Retrieves all documents within the range of ids
. To retrieve all
documents, pass in ..
for ids
. Read more
fn list_headers<'life0, 'async_trait, C, R, PrimaryKey>(
&'life0 self,
ids: R,
order: Sort,
limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<Header, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
R: Into<Range<PrimaryKey>> + Send + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
fn list_headers<'life0, 'async_trait, C, R, PrimaryKey>(
&'life0 self,
ids: R,
order: Sort,
limit: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<Vec<Header, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
R: Into<Range<PrimaryKey>> + Send + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
Retrieves all documents within the range of ids
. To retrieve all
documents, pass in ..
for ids
. Read more
fn count<'life0, 'async_trait, C, R, PrimaryKey>(
&'life0 self,
ids: R
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
R: Into<Range<PrimaryKey>> + Send + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
fn count<'life0, 'async_trait, C, R, PrimaryKey>(
&'life0 self,
ids: R
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
C: Collection + 'async_trait,
R: Into<Range<PrimaryKey>> + Send + 'async_trait,
PrimaryKey: for<'k> KeyEncoding<'k, <C as Collection>::PrimaryKey> + 'async_trait,
Self: 'async_trait,
Counts the number of documents within the range of ids
. Read more
fn delete<'life0, 'life1, 'async_trait, C, H>(
&'life0 self,
doc: &'life1 H
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
C: 'async_trait + Collection,
H: 'async_trait + HasHeader + Send + Sync,
Self: 'async_trait,
fn delete<'life0, 'life1, 'async_trait, C, H>(
&'life0 self,
doc: &'life1 H
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
C: 'async_trait + Collection,
H: 'async_trait + HasHeader + Send + Sync,
Self: 'async_trait,
Removes a Document
from the database. Read more
fn query<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<Map<<V as View>::Key, <V as View>::Value>, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: 'async_trait + SerializedView,
Self: 'async_trait,
fn query<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<Map<<V as View>::Key, <V as View>::Value>, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: 'async_trait + SerializedView,
Self: 'async_trait,
fn query_with_docs<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<MappedDocuments<OwnedDocument, V>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: 'async_trait + SerializedView,
Self: 'async_trait,
fn query_with_docs<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<MappedDocuments<OwnedDocument, V>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: 'async_trait + SerializedView,
Self: 'async_trait,
fn query_with_collection_docs<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<MappedDocuments<CollectionDocument<<V as View>::Collection>, V>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: SerializedView + 'async_trait,
Self: 'async_trait,
<V as View>::Collection: SerializedCollection,
<<V as View>::Collection as SerializedCollection>::Contents: Debug,
fn query_with_collection_docs<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
order: Sort,
limit: Option<u32>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<MappedDocuments<CollectionDocument<<V as View>::Collection>, V>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: SerializedView + 'async_trait,
Self: 'async_trait,
<V as View>::Collection: SerializedCollection,
<<V as View>::Collection as SerializedCollection>::Contents: Debug,
fn reduce_grouped<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<MappedValue<<V as View>::Key, <V as View>::Value>, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: 'async_trait + SerializedView,
Self: 'async_trait,
fn reduce_grouped<'life0, 'async_trait, V>(
&'life0 self,
key: Option<QueryKey<<V as View>::Key>>,
access_policy: AccessPolicy
) -> Pin<Box<dyn Future<Output = Result<Vec<MappedValue<<V as View>::Key, <V as View>::Value>, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
V: 'async_trait + SerializedView,
Self: 'async_trait,
Deletes all of the documents associated with this view. Read more
type Subscriber = Subscriber
type Subscriber = Subscriber
The Subscriber type for this PubSub
connection.
pub fn create_subscriber<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<<AsyncDatabase as AsyncPubSub>::Subscriber, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn create_subscriber<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<<AsyncDatabase as AsyncPubSub>::Subscriber, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
Create a new Subscriber
for this relay.
Publishes a payload
to all subscribers of topic
.
pub fn publish_bytes_to_all<'life0, 'async_trait>(
&'life0 self,
topics: impl IntoIterator<Item = Vec<u8, Global>> + Send + 'async_trait,
payload: Vec<u8, Global>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
pub fn publish_bytes_to_all<'life0, 'async_trait>(
&'life0 self,
topics: impl IntoIterator<Item = Vec<u8, Global>> + Send + 'async_trait,
payload: Vec<u8, Global>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
AsyncDatabase: 'async_trait,
Publishes a payload
to all subscribers of all topics
.
fn publish<'life0, 'life1, 'life2, 'async_trait, Topic, Payload>(
&'life0 self,
topic: &'life1 Topic,
payload: &'life2 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Topic: 'async_trait + Serialize + Send + Sync,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
fn publish<'life0, 'life1, 'life2, 'async_trait, Topic, Payload>(
&'life0 self,
topic: &'life1 Topic,
payload: &'life2 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Topic: 'async_trait + Serialize + Send + Sync,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
Publishes a payload
to all subscribers of topic
.
fn publish_to_all<'topics, 'life0, 'life1, 'async_trait, Topics, Topic, Payload>(
&'life0 self,
topics: Topics,
payload: &'life1 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'topics: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Topics: 'async_trait + 'topics + IntoIterator<Item = &'topics Topic> + Send,
Topic: 'async_trait + 'topics + Serialize + Send,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
fn publish_to_all<'topics, 'life0, 'life1, 'async_trait, Topics, Topic, Payload>(
&'life0 self,
topics: Topics,
payload: &'life1 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'topics: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Topics: 'async_trait + 'topics + IntoIterator<Item = &'topics Topic> + Send,
Topic: 'async_trait + 'topics + Serialize + Send,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
Publishes a payload
to all subscribers of all topics
.
Performs the conversion.
Performs the conversion.
fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool where
R: AsRef<[Identifier<'a>]>,
P: Action,
fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool where
R: AsRef<[Identifier<'a>]>,
P: Action,
Checks if action
is permitted against resource_name
.
Checks if action
is permitted against resource_name
. If permission
is denied, returns a PermissionDenied
error. Read more
Auto Trait Implementations
impl !RefUnwindSafe for AsyncDatabase
impl Send for AsyncDatabase
impl Sync for AsyncDatabase
impl Unpin for AsyncDatabase
impl !UnwindSafe for AsyncDatabase
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more