Trait bonsaidb_core::document::Document
source · pub trait Document<C>: Sizedwhere
C: Collection,{
type Bytes;
// Required methods
fn id(&self) -> &DocumentId;
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;
// Provided method
fn set_collection_header(
&mut self,
header: CollectionHeader<C::PrimaryKey>
) -> Result<(), Error> { ... }
}
Expand description
Common interface of a document in BonsaiDb.
Required Associated Types§
Required Methods§
sourcefn id(&self) -> &DocumentId
fn id(&self) -> &DocumentId
Returns the unique key for this document.
sourcefn header(&self) -> AnyHeader<C::PrimaryKey>
fn header(&self) -> AnyHeader<C::PrimaryKey>
Returns the header of this document.
sourcefn set_header(&mut self, header: Header) -> Result<(), Error>
fn set_header(&mut self, header: Header) -> Result<(), Error>
Sets the header to the new header.
sourcefn contents(&self) -> Result<C::Contents, Error>where
C: SerializedCollection,
fn contents(&self) -> Result<C::Contents, Error>where
C: SerializedCollection,
Retrieves contents
through deserialization into the type D
.
sourcefn 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§
sourcefn 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.
Object Safety§
This trait is not object safe.