Trait bonsaidb_core::document::Document
source · [−]pub trait Document<C>: Sized where
C: Collection, {
type Bytes;
fn key(&self) -> AnyDocumentId<C::PrimaryKey>;
fn header(&self) -> AnyHeader<C::PrimaryKey>;
fn set_header(&mut self, header: Header) -> Result<(), Error>;
fn bytes(&self) -> Result<Vec<u8>, Error>;
fn contents(&self) -> Result<C::Contents, Error>
where
C: SerializedCollection;
fn set_contents(&mut self, contents: C::Contents) -> Result<(), Error>
where
C: SerializedCollection;
fn set_collection_header(
&mut self,
header: CollectionHeader<C::PrimaryKey>
) -> Result<(), Error> { ... }
}Expand description
Common interface of a document in BonsaiDb.
Associated Types
Required methods
fn key(&self) -> AnyDocumentId<C::PrimaryKey>
fn key(&self) -> AnyDocumentId<C::PrimaryKey>
Returns the unique key for this document.
fn header(&self) -> AnyHeader<C::PrimaryKey>
fn header(&self) -> AnyHeader<C::PrimaryKey>
Returns the header of this document.
Sets the header to the new header.
Retrieves contents through deserialization into the type D.
fn set_contents(&mut self, contents: C::Contents) -> Result<(), Error> where
C: SerializedCollection,
fn set_contents(&mut self, contents: C::Contents) -> Result<(), Error> where
C: SerializedCollection,
Stores contents into this document.
Provided methods
fn set_collection_header(
&mut self,
header: CollectionHeader<C::PrimaryKey>
) -> Result<(), Error>
fn set_collection_header(
&mut self,
header: CollectionHeader<C::PrimaryKey>
) -> Result<(), Error>
Sets the header to the new collection header.