Struct pliantdb_core::document::Document [−][src]
Contains a serialized document in the database.
Fields
collection: IdThe Id of the Collection this document belongs to.
header: Cow<'a, Header>The header of the document, which contains the id and Revision.
contents: Cow<'a, [u8]>The serialized bytes of the stored item.
Implementations
impl<'a> Document<'a>[src]
#[must_use]pub fn new(id: u64, contents: Cow<'a, [u8]>, collection: Id) -> Self[src]
Creates a new document with contents.
pub fn with_contents<S: Serialize>(
id: u64,
contents: &S,
collection: Id
) -> Result<Self, Error>[src]
id: u64,
contents: &S,
collection: Id
) -> Result<Self, Error>
Creates a new document with serialized bytes from contents.
pub fn contents<D: Deserialize<'a>>(&'a self) -> Result<D, Error>[src]
Retrieves contents through deserialization into the type D.
pub fn set_contents<S: Serialize>(&mut self, contents: &S) -> Result<(), Error>[src]
Serializes and stores contents into this document.
#[must_use]pub fn create_new_revision(&self, contents: Cow<'a, [u8]>) -> Option<Self>[src]
Creates a new revision.
WARNING: This normally should not be used outside of implementing a
backend for PliantDB. To update a document, use set_contents() and
send the document with the existing Revision information.
#[must_use]pub fn emit(&self) -> Map<(), ()>[src]
Creates a Map result with an empty key and value.
#[must_use]pub fn emit_key<Key: Key>(&self, key: Key) -> Map<Key, ()>[src]
Creates a Map result with a key and an empty value.
#[must_use]pub fn emit_value<Value: Serialize>(&self, value: Value) -> Map<(), Value>[src]
Creates a Map result with value and an empty key.
#[must_use]pub fn emit_key_and_value<Key: Key, Value: Serialize>(
&self,
key: Key,
value: Value
) -> Map<Key, Value>[src]
&self,
key: Key,
value: Value
) -> Map<Key, Value>
Creates a Map result with a key and value.
#[must_use]pub fn to_owned(&self) -> Document<'static>[src]
Clone the document’s data so that it’s no longer borrowed in the original lifetime 'a.
Trait Implementations
impl<'a> Debug for Document<'a>[src]
impl<'de: 'a, 'a> Deserialize<'de> for Document<'a>[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl<'a> Serialize for Document<'a>[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Document<'a>
impl<'a> Send for Document<'a>
impl<'a> Sync for Document<'a>
impl<'a> Unpin for Document<'a>
impl<'a> UnwindSafe for Document<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,