Enum bonsaidb_core::keyvalue::Value
source · pub enum Value {
Bytes(Bytes),
Numeric(Numeric),
}
Expand description
A value stored in a key.
Variants§
Implementations§
source§impl 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.