pub trait Document<'a>: Deref<Target = Header> + DerefMut + AsRef<Header> + AsRef<[u8]> + Sized {
    type Bytes;
    fn new(id: u64, contents: impl Into<Self::Bytes>) -> Self;
fn with_contents<S: SerializedCollection<Contents = S>>(
        id: u64,
        contents: &S
    ) -> Result<Self, Error>;
fn contents<D>(&self) -> Result<D::Contents, Error>
    where
        D: SerializedCollection<Contents = D>
;
fn set_contents<S: SerializedCollection<Contents = S>>(
        &mut self,
        contents: &S
    ) -> Result<(), Error>;
fn create_new_revision(
        &self,
        contents: impl Into<Self::Bytes>
    ) -> Option<Self>; }
Expand description

Common interface of a document in BonsaiDb.

Associated Types

The bytes type used in the interface.

Required methods

Creates a new document with contents.

Creates a new document with serialized bytes from contents.

Retrieves contents through deserialization into the type D.

Serializes and stores contents into this document.

Creates a new revision.

WARNING: This normally should not be used outside of implementing a backend for BonsaiDb. To update a document, use set_contents() and send the document with the existing Revision information.

Implementors