pub struct CqlDecimal { /* private fields */ }
Expand description
Native CQL decimal
representation.
Represented as a pair:
- a
CqlVarint
value - 32-bit integer which determines the position of the decimal point
The type is not very useful in most use cases.
However, users can make use of more complex types
such as bigdecimal::BigDecimal
(v0.4).
The library support (e.g. conversion from CqlValue
) for the type is
enabled via bigdecimal-04
crate feature.
§DB data format
Notice that constructors
don’t perform any normalization on the provided data.
For more details, see CqlVarint
documentation.
Implementations§
Source§impl CqlDecimal
Constructors
impl CqlDecimal
Constructors
Sourcepub fn from_signed_be_bytes_and_exponent(bytes: Vec<u8>, scale: i32) -> Self
pub fn from_signed_be_bytes_and_exponent(bytes: Vec<u8>, scale: i32) -> Self
Creates a CqlDecimal
from an array of bytes
representing CqlVarint
and a 32-bit scale.
See: disclaimer about non-normalized values.
Sourcepub fn from_signed_be_bytes_slice_and_exponent(bytes: &[u8], scale: i32) -> Self
pub fn from_signed_be_bytes_slice_and_exponent(bytes: &[u8], scale: i32) -> Self
Creates a CqlDecimal
from a slice of bytes
representing CqlVarint
and a 32-bit scale.
See: disclaimer about non-normalized values.
Source§impl CqlDecimal
Conversion to raw bytes
impl CqlDecimal
Conversion to raw bytes
Sourcepub fn as_signed_be_bytes_slice_and_exponent(&self) -> (&[u8], i32)
pub fn as_signed_be_bytes_slice_and_exponent(&self) -> (&[u8], i32)
Returns a slice of bytes in two’s complement binary big-endian representation and a scale.
Sourcepub fn into_signed_be_bytes_and_exponent(self) -> (Vec<u8>, i32)
pub fn into_signed_be_bytes_and_exponent(self) -> (Vec<u8>, i32)
Converts CqlDecimal
to an array of bytes in two’s
complement binary big-endian representation and a scale.
Trait Implementations§
Source§impl Clone for CqlDecimal
impl Clone for CqlDecimal
Source§fn clone(&self) -> CqlDecimal
fn clone(&self) -> CqlDecimal
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more