Document

Trait Document 

Source
pub trait Document<C>: Sized
where 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§

Source

type Bytes

The bytes type used in the interface.

Required Methods§

Source

fn id(&self) -> &DocumentId

Returns the unique key for this document.

Source

fn header(&self) -> AnyHeader<C::PrimaryKey>

Returns the header of this document.

Source

fn set_header(&mut self, header: Header) -> Result<(), Error>

Sets the header to the new header.

Source

fn bytes(&self) -> Result<Vec<u8>, Error>

Returns the contents of this document, serialized.

Source

fn contents(&self) -> Result<C::Contents, Error>

Retrieves contents through deserialization into the type D.

Source

fn set_contents(&mut self, contents: C::Contents) -> Result<(), Error>

Stores contents into this document.

Provided Methods§

Source

fn set_collection_header( &mut self, header: CollectionHeader<C::PrimaryKey>, ) -> Result<(), Error>

Sets the header to the new collection header.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, C> Document<C> for BorrowedDocument<'a>
where C: Collection,

Source§

impl<C> Document<C> for OwnedDocument
where C: Collection,