pub trait LowLevelConnection: HasSchema + HasSession {
Show 27 methods // Required methods fn apply_transaction( &self, transaction: Transaction ) -> Result<Vec<OperationResult>, Error>; fn get_from_collection( &self, id: DocumentId, collection: &CollectionName ) -> Result<Option<OwnedDocument>, Error>; fn get_multiple_from_collection( &self, ids: &[DocumentId], collection: &CollectionName ) -> Result<Vec<OwnedDocument>, Error>; fn list_from_collection( &self, ids: Range<DocumentId>, order: Sort, limit: Option<u32>, collection: &CollectionName ) -> Result<Vec<OwnedDocument>, Error>; fn list_headers_from_collection( &self, ids: Range<DocumentId>, order: Sort, limit: Option<u32>, collection: &CollectionName ) -> Result<Vec<Header>, Error>; fn count_from_collection( &self, ids: Range<DocumentId>, collection: &CollectionName ) -> Result<u64, Error>; fn compact_collection_by_name( &self, collection: CollectionName ) -> Result<(), Error>; fn query_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<Vec<Serialized>, Error>; fn query_by_name_with_docs( &self, view: &ViewName, key: Option<SerializedQueryKey>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<MappedSerializedDocuments, Error>; fn reduce_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, access_policy: AccessPolicy ) -> Result<Vec<u8>, Error>; fn reduce_grouped_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, access_policy: AccessPolicy ) -> Result<Vec<MappedSerializedValue>, Error>; fn delete_docs_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, access_policy: AccessPolicy ) -> Result<u64, Error>; // Provided methods fn insert<C, PrimaryKey, B>( &self, id: Option<&PrimaryKey>, contents: B ) -> Result<CollectionHeader<C::PrimaryKey>, Error> where C: Collection, B: Into<Bytes> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + Send + ?Sized { ... } fn update<C: Collection, D: Document<C> + Send + Sync>( &self, doc: &mut D ) -> Result<(), Error> { ... } fn overwrite<C, PrimaryKey>( &self, id: &PrimaryKey, contents: Vec<u8> ) -> Result<CollectionHeader<C::PrimaryKey>, Error> where C: Collection, PrimaryKey: KeyEncoding<C::PrimaryKey> { ... } fn get<C, PrimaryKey>( &self, id: &PrimaryKey ) -> Result<Option<OwnedDocument>, Error> where C: Collection, PrimaryKey: KeyEncoding<C::PrimaryKey> + ?Sized { ... } fn get_multiple<'id, C, PrimaryKey, DocumentIds, I>( &self, ids: DocumentIds ) -> Result<Vec<OwnedDocument>, Error> where C: Collection, DocumentIds: IntoIterator<Item = &'id PrimaryKey, IntoIter = I> + Send + Sync, I: Iterator<Item = &'id PrimaryKey> + Send + Sync, PrimaryKey: KeyEncoding<C::PrimaryKey> + 'id + ?Sized { ... } fn list<'id, C, R, PrimaryKey>( &self, ids: R, order: Sort, limit: Option<u32> ) -> Result<Vec<OwnedDocument>, Error> where C: Collection, R: Into<RangeRef<'id, C::PrimaryKey, PrimaryKey>> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + PartialEq + 'id + ?Sized, C::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey> { ... } fn list_headers<'id, C, R, PrimaryKey>( &self, ids: R, order: Sort, limit: Option<u32> ) -> Result<Vec<Header>, Error> where C: Collection, R: Into<RangeRef<'id, C::PrimaryKey, PrimaryKey>> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + PartialEq + 'id + ?Sized, C::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey> { ... } fn count<'id, C, R, PrimaryKey>(&self, ids: R) -> Result<u64, Error> where C: Collection, R: Into<RangeRef<'id, C::PrimaryKey, PrimaryKey>> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + PartialEq + 'id + ?Sized, C::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey> { ... } fn delete<C: Collection, H: HasHeader + Send + Sync>( &self, doc: &H ) -> Result<(), Error> { ... } fn query<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<ViewMappings<V>, Error> where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key> { ... } fn query_with_docs<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<MappedDocuments<OwnedDocument, V>, Error> where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key> { ... } fn query_with_collection_docs<V, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<MappedDocuments<CollectionDocument<V::Collection>, V>, Error> where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key>, V: SerializedView, V::Collection: SerializedCollection, <V::Collection as SerializedCollection>::Contents: Debug { ... } fn reduce<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, access_policy: AccessPolicy ) -> Result<V::Value, Error> where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key> { ... } fn reduce_grouped<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, access_policy: AccessPolicy ) -> Result<GroupedReductions<V>, Error> where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key> { ... } fn delete_docs<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, access_policy: AccessPolicy ) -> Result<u64, Error> where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key> { ... }
}
Expand description

The low-level interface to a database’s schema::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 AsyncLowLevelConnection.

This trait’s methods are not designed for ergonomics. See Connection for a higher-level interface.

Required Methods§

source

fn apply_transaction( &self, transaction: Transaction ) -> Result<Vec<OperationResult>, Error>

Applies a Transaction to the schema::Schema. If any operation in the Transaction fails, none of the operations will be applied to the schema::Schema.

source

fn get_from_collection( &self, id: DocumentId, collection: &CollectionName ) -> Result<Option<OwnedDocument>, Error>

Retrieves the document with id stored within the named collection.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn get_multiple_from_collection( &self, ids: &[DocumentId], collection: &CollectionName ) -> Result<Vec<OwnedDocument>, Error>

Retrieves all documents matching ids from the named collection. Documents that are not found are not returned, but no error will be generated.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn list_from_collection( &self, ids: Range<DocumentId>, order: Sort, limit: Option<u32>, collection: &CollectionName ) -> Result<Vec<OwnedDocument>, Error>

Retrieves all documents within the range of ids from the named collection. To retrieve all documents, pass in .. for ids.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn list_headers_from_collection( &self, ids: Range<DocumentId>, order: Sort, limit: Option<u32>, collection: &CollectionName ) -> Result<Vec<Header>, Error>

Retrieves all headers within the range of ids from the named collection. To retrieve all documents, pass in .. for ids.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn count_from_collection( &self, ids: Range<DocumentId>, collection: &CollectionName ) -> Result<u64, Error>

Counts the number of documents within the range of ids from the named collection.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn compact_collection_by_name( &self, collection: CollectionName ) -> 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
source

fn query_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<Vec<Serialized>, Error>

Queries for view entries from the named view.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).query() instead. The parameters for the query can be customized on the builder returned from Connection::view().

source

fn query_by_name_with_docs( &self, view: &ViewName, key: Option<SerializedQueryKey>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<MappedSerializedDocuments, Error>

Queries for view entries from the named view with their source documents.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).query_with_docs() instead. The parameters for the query can be customized on the builder returned from Connection::view().

source

fn reduce_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, access_policy: AccessPolicy ) -> Result<Vec<u8>, Error>

Reduces the view entries from the named view.

This is a lower-level API. For better ergonomics, consider reducing the view using View::entries(self).reduce() instead. The parameters for the query can be customized on the builder returned from Connection::view().

source

fn reduce_grouped_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, access_policy: AccessPolicy ) -> Result<Vec<MappedSerializedValue>, Error>

Reduces the view entries from the named view, reducing the values by each unique key.

This is a lower-level API. For better ergonomics, consider reducing the view using View::entries(self).reduce_grouped() instead. The parameters for the query can be customized on the builder returned from Connection::view().

source

fn delete_docs_by_name( &self, view: &ViewName, key: Option<SerializedQueryKey>, access_policy: AccessPolicy ) -> Result<u64, Error>

Deletes all source documents for entries that match within the named view.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).delete_docs() instead. The parameters for the query can be customized on the builder returned from Connection::view().

Provided Methods§

source

fn insert<C, PrimaryKey, B>( &self, id: Option<&PrimaryKey>, contents: B ) -> Result<CollectionHeader<C::PrimaryKey>, Error>
where C: Collection, B: Into<Bytes> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + Send + ?Sized,

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.

This is the lower-level API. For better ergonomics, consider using one of:

source

fn update<C: Collection, D: Document<C> + Send + Sync>( &self, doc: &mut D ) -> Result<(), Error>

Updates an existing document in the connected schema::Schema for the Collection C. Upon success, doc.revision will be updated with the new revision.

This is the lower-level API. For better ergonomics, consider using one of:

source

fn overwrite<C, PrimaryKey>( &self, id: &PrimaryKey, contents: Vec<u8> ) -> Result<CollectionHeader<C::PrimaryKey>, Error>
where C: Collection, PrimaryKey: KeyEncoding<C::PrimaryKey>,

Overwrites an existing document, or inserts a new document. Upon success, doc.revision will be updated with the new revision information.

This is the lower-level API. For better ergonomics, consider using one of:

source

fn get<C, PrimaryKey>( &self, id: &PrimaryKey ) -> Result<Option<OwnedDocument>, Error>
where C: Collection, PrimaryKey: KeyEncoding<C::PrimaryKey> + ?Sized,

Retrieves a stored document from Collection C identified by id.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn get_multiple<'id, C, PrimaryKey, DocumentIds, I>( &self, ids: DocumentIds ) -> Result<Vec<OwnedDocument>, Error>
where C: Collection, DocumentIds: IntoIterator<Item = &'id PrimaryKey, IntoIter = I> + Send + Sync, I: Iterator<Item = &'id PrimaryKey> + Send + Sync, PrimaryKey: KeyEncoding<C::PrimaryKey> + 'id + ?Sized,

Retrieves all documents matching ids. Documents that are not found are not returned, but no error will be generated.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn list<'id, C, R, PrimaryKey>( &self, ids: R, order: Sort, limit: Option<u32> ) -> Result<Vec<OwnedDocument>, Error>
where C: Collection, R: Into<RangeRef<'id, C::PrimaryKey, PrimaryKey>> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + PartialEq + 'id + ?Sized, C::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,

Retrieves all documents within the range of ids. To retrieve all documents, pass in .. for ids.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn list_headers<'id, C, R, PrimaryKey>( &self, ids: R, order: Sort, limit: Option<u32> ) -> Result<Vec<Header>, Error>
where C: Collection, R: Into<RangeRef<'id, C::PrimaryKey, PrimaryKey>> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + PartialEq + 'id + ?Sized, C::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,

Retrieves all documents within the range of ids. To retrieve all documents, pass in .. for ids.

This is the lower-level API. For better ergonomics, consider using one of:

source

fn count<'id, C, R, PrimaryKey>(&self, ids: R) -> Result<u64, Error>
where C: Collection, R: Into<RangeRef<'id, C::PrimaryKey, PrimaryKey>> + Send, PrimaryKey: KeyEncoding<C::PrimaryKey> + PartialEq + 'id + ?Sized, C::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,

Counts the number of documents within the range of ids.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn delete<C: Collection, H: HasHeader + Send + Sync>( &self, doc: &H ) -> Result<(), Error>

Removes a Document from the database.

This is a lower-level API. For better ergonomics, consider using one of:

source

fn query<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<ViewMappings<V>, Error>
where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key>,

Queries for view entries matching View.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).query() instead. The parameters for the query can be customized on the builder returned from SerializedView::entries(), SerializedView::entries_async(), or Connection::view().

source

fn query_with_docs<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<MappedDocuments<OwnedDocument, V>, Error>
where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key>,

Queries for view entries matching View with their source documents.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).query_with_docs() instead. The parameters for the query can be customized on the builder returned from SerializedView::entries(), SerializedView::entries_async(), or Connection::view().

source

fn query_with_collection_docs<V, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, order: Sort, limit: Option<u32>, access_policy: AccessPolicy ) -> Result<MappedDocuments<CollectionDocument<V::Collection>, V>, Error>

Queries for view entries matching View with their source documents, deserialized.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).query_with_collection_docs() instead. The parameters for the query can be customized on the builder returned from SerializedView::entries(), SerializedView::entries_async(), or Connection::view().

source

fn reduce<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, access_policy: AccessPolicy ) -> Result<V::Value, Error>
where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key>,

Reduces the view entries matching View.

This is a lower-level API. For better ergonomics, consider reducing the view using View::entries(self).reduce() instead. The parameters for the query can be customized on the builder returned from SerializedView::entries(), SerializedView::entries_async(), or Connection::view().

source

fn reduce_grouped<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, access_policy: AccessPolicy ) -> Result<GroupedReductions<V>, Error>
where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key>,

Reduces the view entries matching View, reducing the values by each unique key.

This is a lower-level API. For better ergonomics, consider reducing the view using View::entries(self).reduce_grouped() instead. The parameters for the query can be customized on the builder returned from SerializedView::entries(), SerializedView::entries_async(), or Connection::view().

source

fn delete_docs<V: SerializedView, Key>( &self, key: Option<QueryKey<'_, V::Key, Key>>, access_policy: AccessPolicy ) -> Result<u64, Error>
where Key: KeyEncoding<V::Key> + PartialEq + ?Sized, V::Key: Borrow<Key> + PartialEq<Key>,

Deletes all of the documents associated with this view.

This is a lower-level API. For better ergonomics, consider querying the view using View::entries(self).delete_docs() instead. The parameters for the query can be customized on the builder returned from SerializedView::entries(), SerializedView::entries_async(), or Connection::view().

Object Safety§

This trait is not object safe.

Implementors§