Enum bonsaidb_core::keyvalue::Numeric
source · [−]Expand description
A numerical value.
Variants
Integer(i64)
A 64-bit signed integer.
UnsignedInteger(u64)
A 64-bit unsigned integer.
Float(f64)
A 64-bit floating point number.
Implementations
sourceimpl Numeric
impl Numeric
sourcepub fn validate(self) -> Result<Self, Error>
pub fn validate(self) -> Result<Self, Error>
Ensures this value contains a valid value.
Errors
Error::NotANumber is returned if this contains a NaN floating point
value.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns this numeric as an i64. If this conversion cannot be done
without losing precision or overflowing, None will be returned.
sourcepub fn as_i64_lossy(&self, saturating: bool) -> i64
pub fn as_i64_lossy(&self, saturating: bool) -> i64
Returns this numeric 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.
sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns this numeric as an u64. If this conversion cannot be done
without losing precision or overflowing, None will be returned.
sourcepub fn as_u64_lossy(&self, saturating: bool) -> u64
pub fn as_u64_lossy(&self, saturating: bool) -> u64
Returns this numeric as an u64, allowing for precision to be lost if
the type was not an i64 originally. If saturating is true, the
conversion will not allow overflows.
sourcepub const fn as_f64(&self) -> Option<f64>
pub const fn as_f64(&self) -> Option<f64>
Returns this numeric as an f64. If this conversion cannot be done
without losing precision, None will be returned.
sourcepub const fn as_f64_lossy(&self) -> f64
pub const fn as_f64_lossy(&self) -> f64
Returns this numeric as an f64, allowing for precision to be lost if
the type was not an f64 originally.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Numeric
impl<'de> Deserialize<'de> for Numeric
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
sourceimpl TryFrom<Numeric> for f64
impl TryFrom<Numeric> for f64
type Error = IncompatibleTypeError
type Error = IncompatibleTypeError
The type returned in the event of a conversion error.
sourcefn try_from(value: Numeric) -> Result<Self, IncompatibleTypeError>
fn try_from(value: Numeric) -> Result<Self, IncompatibleTypeError>
Performs the conversion.
sourceimpl TryFrom<Numeric> for u64
impl TryFrom<Numeric> for u64
type Error = IncompatibleTypeError
type Error = IncompatibleTypeError
The type returned in the event of a conversion error.
sourcefn try_from(value: Numeric) -> Result<Self, IncompatibleTypeError>
fn try_from(value: Numeric) -> Result<Self, IncompatibleTypeError>
Performs the conversion.
sourceimpl TryFrom<Numeric> for i64
impl TryFrom<Numeric> for i64
type Error = IncompatibleTypeError
type Error = IncompatibleTypeError
The type returned in the event of a conversion error.
sourcefn try_from(value: Numeric) -> Result<Self, IncompatibleTypeError>
fn try_from(value: Numeric) -> Result<Self, IncompatibleTypeError>
Performs the conversion.
impl StructuralPartialEq for Numeric
Auto Trait Implementations
impl RefUnwindSafe for Numeric
impl Send for Numeric
impl Sync for Numeric
impl Unpin for Numeric
impl UnwindSafe for Numeric
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