Enum bonsaidb_core::keyvalue::Value
source · [−]Expand description
A value stored in a key.
Variants
Bytes(Bytes)
A value stored as a byte array.
Numeric(Numeric)
A numeric value.
Implementations
sourceimpl Value
impl Value
sourcepub fn validate(self) -> Result<Self, Error>
pub fn validate(self) -> Result<Self, Error>
Validates this value to ensure it is safe to store.
sourcepub fn deserialize<V: for<'de> Deserialize<'de>>(&self) -> Result<V, Error>
pub fn deserialize<V: for<'de> Deserialize<'de>>(&self) -> Result<V, Error>
Deserializes the bytes contained inside of this value. Returns an error if this value doesn’t contain bytes.
sourcepub fn as_i64_lossy(&self, saturating: bool) -> Option<i64>
pub fn as_i64_lossy(&self, saturating: bool) -> Option<i64>
Returns this value as an i64, allowing for precision to be lost if the type was not an i64 originally. If saturating is true, the conversion will not allow overflows. Returns None if the value is bytes.
sourcepub fn as_u64_lossy(&self, saturating: bool) -> Option<u64>
pub fn as_u64_lossy(&self, saturating: bool) -> Option<u64>
Returns this value as an u64, allowing for precision to be lost if the type was not an u64 originally. If saturating is true, the conversion will not allow overflows. Returns None if the value is bytes.
sourcepub const fn as_f64_lossy(&self) -> Option<f64>
pub const fn as_f64_lossy(&self) -> Option<f64>
Returns this value as an f64, allowing for precision to be lost if the type was not an f64 originally. Returns None if the value is bytes.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns this numeric as an i64, allowing for precision to be lost if the type was not an i64 originally. Returns None if the value is bytes.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Value
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more