Struct pliantdb_local::core::document::Document[][src]

pub struct Document<'a> {
    pub collection: Id,
    pub header: Cow<'a, Header>,
    pub contents: Cow<'a, [u8]>,
}

Contains a serialized document in the database.

Fields

collection: Id

The 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) -> Document<'a>[src]

Creates a new document with contents.

pub fn with_contents<S>(
    id: u64,
    contents: &S,
    collection: Id
) -> Result<Document<'a>, Error> where
    S: Serialize
[src]

Creates a new document with serialized bytes from contents.

pub fn contents<D>(&'a self) -> Result<D, Error> where
    D: Deserialize<'a>, 
[src]

Retrieves contents through deserialization into the type D.

pub fn set_contents<S>(&mut self, contents: &S) -> Result<(), Error> where
    S: Serialize
[src]

Serializes and stores contents into this document.

#[must_use]pub fn create_new_revision(
    &self,
    contents: Cow<'a, [u8]>
) -> Option<Document<'a>>
[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>(&self, key: Key) -> Map<Key, ()> where
    Key: Key
[src]

Creates a Map result with a key and an empty value.

#[must_use]pub fn emit_value<Value>(&self, value: Value) -> Map<(), Value> where
    Value: Serialize
[src]

Creates a Map result with value and an empty key.

#[must_use]pub fn emit_key_and_value<Key, Value>(
    &self,
    key: Key,
    value: Value
) -> Map<Key, Value> where
    Key: Key,
    Value: Serialize
[src]

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> Clone for Document<'a>[src]

impl<'a> Debug for Document<'a>[src]

impl<'de, 'a> Deserialize<'de> for Document<'a>[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,