Struct RawDocument

Source
pub struct RawDocument(/* private fields */);
Expand description

Raw document with id representation

Implementations§

Source§

impl RawDocument

Source

pub fn new(doc: Value) -> Self

Create document using raw data

Source

pub fn with_id(self, id: Primary) -> Self

Add id to document

Source

pub fn without_id(self) -> Self

Remove id from document

Source

pub fn has_id(&self) -> bool

Checks when document has primary key/identifier

Source

pub fn get_id(&self) -> &Option<Primary>

Get the primary key/identifier of document

Source

pub fn req_id(&self) -> Result<Primary>

Require the primary key/identifier of document

Source

pub fn into_inner(self) -> Value

Unwrap document value

Source

pub fn to_bin(&self) -> Result<Vec<u8>>

Convert document to binary representation

At this moment we use CBOR for effectively store documents into DB backend. Since the internal representation does not contains primary identifier, it adds on reading documents from DB.

Source

pub fn from_bin(raw: &[u8]) -> Result<Self>

Restore document from binary representation

At this moment we use CBOR for effectively store documents into DB backend. Since the internal representation does not contains primary identifier, it adds on reading documents from DB.

Source

pub fn from_doc<T>(doc: &T) -> Result<Self>
where T: Serialize + Document + Sized,

Convert typed document to raw representation

Typically the application deals with typed documents which represented by specific structures. The database backend processes generic document representation which is CBOR Value.

Source

pub fn into_doc<T>(self) -> Result<T>

Restore typed document from raw representation

Typically the application deals with typed documents which represented by specific structures. The database backend processes generic document representation which is CBOR Value.

Trait Implementations§

Source§

impl Clone for RawDocument

Source§

fn clone(&self) -> RawDocument

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RawDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for RawDocument

Source§

type Target = Value

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for RawDocument

Source§

fn deref_mut(&mut self) -> &mut Value

Mutably dereferences the value.
Source§

impl PartialEq for RawDocument

Source§

fn eq(&self, other: &RawDocument) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RawDocument

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'a, T> DefaultFeatures<'a> for T
where T: 'a + Send + Sync + Clone,

Source§

fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
Source§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'a, T> NonSyncFeatures<'a> for T
where T: 'a + Clone,

Source§

fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
Source§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> SafeBorrow<T> for T
where T: ?Sized,

Source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.