Struct scylla_cql::frame::value::CqlDecimal
source · 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
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
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 moresource§impl Debug for CqlDecimal
impl Debug for CqlDecimal
source§impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for CqlDecimal
impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for CqlDecimal
source§fn type_check(typ: &ColumnType<'_>) -> Result<(), TypeCheckError>
fn type_check(typ: &ColumnType<'_>) -> Result<(), TypeCheckError>
source§fn deserialize(
typ: &'metadata ColumnType<'metadata>,
v: Option<FrameSlice<'frame>>,
) -> Result<Self, DeserializationError>
fn deserialize( typ: &'metadata ColumnType<'metadata>, v: Option<FrameSlice<'frame>>, ) -> Result<Self, DeserializationError>
source§impl FromCqlVal<CqlValue> for CqlDecimal
impl FromCqlVal<CqlValue> for CqlDecimal
source§fn from_cql(cql_val: CqlValue) -> Result<CqlDecimal, FromCqlValError>
fn from_cql(cql_val: CqlValue) -> Result<CqlDecimal, FromCqlValError>
source§impl PartialEq for CqlDecimal
impl PartialEq for CqlDecimal
source§fn eq(&self, other: &CqlDecimal) -> bool
fn eq(&self, other: &CqlDecimal) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl SerializeValue for CqlDecimal
impl SerializeValue for CqlDecimal
source§fn serialize<'b>(
&self,
typ: &ColumnType<'_>,
writer: CellWriter<'b>,
) -> Result<WrittenCellProof<'b>, SerializationError>
fn serialize<'b>( &self, typ: &ColumnType<'_>, writer: CellWriter<'b>, ) -> Result<WrittenCellProof<'b>, SerializationError>
source§impl Value for CqlDecimal
impl Value for CqlDecimal
impl Emptiable for CqlDecimal
impl Eq for CqlDecimal
impl StructuralPartialEq for CqlDecimal
Auto Trait Implementations§
impl Freeze for CqlDecimal
impl RefUnwindSafe for CqlDecimal
impl Send for CqlDecimal
impl Sync for CqlDecimal
impl Unpin for CqlDecimal
impl UnwindSafe for CqlDecimal
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)