Struct ledb::RawDocument
source · pub struct RawDocument(_, _);
Expand description
Raw document with id representation
Implementations§
source§impl RawDocument
impl RawDocument
sourcepub fn without_id(self) -> Self
pub fn without_id(self) -> Self
Remove id from document
sourcepub fn into_inner(self) -> Value
pub fn into_inner(self) -> Value
Unwrap document value
sourcepub fn into_bin(&self) -> Result<Vec<u8>>
pub fn into_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.
sourcepub fn from_bin(raw: &[u8]) -> Result<Self>
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.
sourcepub fn from_doc<T>(doc: &T) -> Result<Self>where
T: Serialize + Document + Sized,
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.
sourcepub fn into_doc<T>(self) -> Result<T>where
T: DeserializeOwned + Document,
pub fn into_doc<T>(self) -> Result<T>where
T: DeserializeOwned + Document,
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.
Methods from Deref<Target = Value>§
sourcepub fn as_object(&self) -> Option<&BTreeMap<ObjectKey, Value, Global>>
pub fn as_object(&self) -> Option<&BTreeMap<ObjectKey, Value, Global>>
If the value is an object, returns the associated BTreeMap. Returns None otherwise.
sourcepub fn as_object_mut(
&mut self
) -> Option<&mut BTreeMap<ObjectKey, Value, Global>>
pub fn as_object_mut(
&mut self
) -> Option<&mut BTreeMap<ObjectKey, Value, Global>>
If the value is an object, returns the associated mutable BTreeMap. Returns None otherwise.
sourcepub fn as_array(&self) -> Option<&Vec<Value, Global>>
pub fn as_array(&self) -> Option<&Vec<Value, Global>>
If the value is an array, returns the associated Vec. Returns None otherwise.
sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value, Global>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value, Global>>
If the value is an array, returns the associated mutable Vec. Returns None otherwise.
sourcepub fn as_bytes(&self) -> Option<&Vec<u8, Global>>
pub fn as_bytes(&self) -> Option<&Vec<u8, Global>>
Returns the associated byte string or None
if the value has a different type.
sourcepub fn as_bytes_mut(&mut self) -> Option<&mut Vec<u8, Global>>
pub fn as_bytes_mut(&mut self) -> Option<&mut Vec<u8, Global>>
Returns the associated mutable byte string or None
if the value has a different type.
sourcepub fn as_string(&self) -> Option<&String>
pub fn as_string(&self) -> Option<&String>
Returns the associated string or None
if the value has a different type.
sourcepub fn as_string_mut(&mut self) -> Option<&mut String>
pub fn as_string_mut(&mut self) -> Option<&mut String>
Returns the associated mutable string or None
if the value has a different type.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
If the Value
is a number, return or cast it to a i64. Returns None otherwise.
sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
If the Value
is a number, return or cast it to a u64. Returns None otherwise.
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
If the Value
is a number, return or cast it to a f64. Returns None otherwise.
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if the value is a boolean.
sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
If the value is a Boolean, returns the associated bool. Returns None otherwise.
Trait Implementations§
source§impl Clone for RawDocument
impl Clone for RawDocument
source§fn clone(&self) -> RawDocument
fn clone(&self) -> RawDocument
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RawDocument
impl Debug for RawDocument
source§impl Deref for RawDocument
impl Deref for RawDocument
source§impl DerefMut for RawDocument
impl DerefMut for RawDocument
source§impl PartialEq<RawDocument> for RawDocument
impl PartialEq<RawDocument> for RawDocument
source§fn eq(&self, other: &RawDocument) -> bool
fn eq(&self, other: &RawDocument) -> bool
impl StructuralPartialEq for RawDocument
Auto Trait Implementations§
impl RefUnwindSafe for RawDocument
impl Send for RawDocument
impl Sync for RawDocument
impl Unpin for RawDocument
impl UnwindSafe for RawDocument
Blanket Implementations§
source§impl<'a, T> DefaultFeatures<'a> for Twhere
T: 'a + Send + Sync + Clone,
impl<'a, T> DefaultFeatures<'a> for Twhere
T: 'a + Send + Sync + Clone,
source§fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a, Global>
fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a, Global>
Box
behind a trait object of this trait. Read moresource§impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
source§fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a, Global>
fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a, Global>
Box
behind a trait object of this trait. Read more