Struct bonsaidb::core::document::BorrowedDocument [−][src]
Expand description
Contains a serialized document in the database.
Fields
header: Header
The header of the document, which contains the id and Revision
.
contents: CowBytes<'a>
The serialized bytes of the stored item.
Implementations
pub fn new<Contents>(id: DocumentId, contents: Contents) -> BorrowedDocument<'a> where
Contents: Into<CowBytes<'a>>,
pub fn new<Contents>(id: DocumentId, contents: Contents) -> BorrowedDocument<'a> where
Contents: Into<CowBytes<'a>>,
Returns a new instance with the id and content bytes.
pub fn with_contents<C>(
id: <C as Collection>::PrimaryKey,
contents: &<C as SerializedCollection>::Contents
) -> Result<BorrowedDocument<'a>, Error> where
C: SerializedCollection,
pub fn with_contents<C>(
id: <C as Collection>::PrimaryKey,
contents: &<C as SerializedCollection>::Contents
) -> Result<BorrowedDocument<'a>, Error> where
C: SerializedCollection,
Returns a new instance with contents
, after serializing.
Converts this document to an owned document.
Trait Implementations
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<BorrowedDocument<'a>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<BorrowedDocument<'a>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn contents(&self) -> Result<<C as SerializedCollection>::Contents, Error> where
C: SerializedCollection,
pub fn contents(&self) -> Result<<C as SerializedCollection>::Contents, Error> where
C: SerializedCollection,
Retrieves contents
through deserialization into the type D
.
pub fn set_contents(
&mut self,
contents: <C as SerializedCollection>::Contents
) -> Result<(), Error> where
C: SerializedCollection,
pub fn set_contents(
&mut self,
contents: <C as SerializedCollection>::Contents
) -> Result<(), Error> where
C: SerializedCollection,
Stores contents
into this document.
Returns the header of this document.
Sets the header to the new header.
Returns the contents of this document, serialized.
Returns the unique key for this document.
fn set_collection_header(
&mut self,
header: CollectionHeader<<C as Collection>::PrimaryKey>
) -> Result<(), Error>
fn set_collection_header(
&mut self,
header: CollectionHeader<<C as Collection>::PrimaryKey>
) -> Result<(), Error>
Sets the header to the new collection header.
Performs the conversion.
Returns this name as a NamedReference
.
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'a, C> TryFrom<&'a BorrowedDocument<'a>> for CollectionDocument<C> where
C: SerializedCollection,
impl<'a, C> TryFrom<&'a BorrowedDocument<'a>> for CollectionDocument<C> where
C: SerializedCollection,
pub fn try_from(
value: &'a BorrowedDocument<'a>
) -> Result<CollectionDocument<C>, <CollectionDocument<C> as TryFrom<&'a BorrowedDocument<'a>>>::Error>
pub fn try_from(
value: &'a BorrowedDocument<'a>
) -> Result<CollectionDocument<C>, <CollectionDocument<C> as TryFrom<&'a BorrowedDocument<'a>>>::Error>
Performs the conversion.
impl<'a, 'b, C> TryFrom<&'b CollectionDocument<C>> for BorrowedDocument<'a> where
C: SerializedCollection,
impl<'a, 'b, C> TryFrom<&'b CollectionDocument<C>> for BorrowedDocument<'a> where
C: SerializedCollection,
pub fn try_from(
value: &'b CollectionDocument<C>
) -> Result<BorrowedDocument<'a>, <BorrowedDocument<'a> as TryFrom<&'b CollectionDocument<C>>>::Error>
pub fn try_from(
value: &'b CollectionDocument<C>
) -> Result<BorrowedDocument<'a>, <BorrowedDocument<'a> as TryFrom<&'b CollectionDocument<C>>>::Error>
Performs the conversion.
Auto Trait Implementations
impl<'a> RefUnwindSafe for BorrowedDocument<'a>
impl<'a> Send for BorrowedDocument<'a>
impl<'a> Sync for BorrowedDocument<'a>
impl<'a> Unpin for BorrowedDocument<'a>
impl<'a> UnwindSafe for BorrowedDocument<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more