Module bonsaidb::core::document[][src]

Expand description

Types for interacting with Documents.

A document is a stored value in a Collection. Each document has a Header, which contains a unique ID and information about the currently stored revision. BonsaiDb adds extra protections by requiring update operations to include the document’s current header. If the document header doesn’t match the currently stored information, Error::DocumentConflict will be returned.

The lower-level interface for BonsaiDb uses OwnedDocument and BorrowedDocument. These types contain a buffer of bytes that have been inserted into a collection previously. This interface is useful if you are wanting to do borrowing or zero-copy deserialization, as the handling of the bytes is left up to the user. Views implemented using ViewSchema receive a BorrowedDocument parameter to the map function.

The higher-level interface uses CollectionDocument<T> which automatically serializes and deserialized from OwnedDocument/BorrowedDocument using the SerializedCollection trait. This interface is recommended for most users, as it is significantly more ergonomic. Views implemented using CollectionViewSchema receive a CollectionDocument<T> parameter to the map function.


Contains a serialized document in the database.

A document with serializable contents.

The serialized representation of a document’s unique ID.

The header of a Document.

An invalid hexadecimal character was encountered.

Contains a serialized document in the database.

Information about a Document’s revision history.


A header with either a serialized or deserialized primary key.

The ID of an encryption key.


Common interface of a document in BonsaiDb.

View mapping emit functions. Used when implementing a view’s map() function.

A type that can return a Header.

Helper functions for a slice of OwnedDocuments.