Struct tiberius::numeric::Numeric

source ·
pub struct Numeric { /* private fields */ }
Expand description

Represent a sql Decimal / Numeric type. It is stored in a i128 and has a maximum precision of 38 decimals.

A recommended way of dealing with numeric values is by enabling the rust_decimal feature and using its Decimal type instead.

Implementations§

source§

impl Numeric

source

pub fn new_with_scale(value: i128, scale: u8) -> Self

Creates a new Numeric value.

Panic

It will panic if the scale exceed 37.

source

pub fn dec_part(self) -> i128

Extract the decimal part.

source

pub fn int_part(self) -> i128

Extract the integer part.

source

pub fn scale(self) -> u8

The scale (where is the decimal point) of the value.

source

pub fn value(self) -> i128

The internal integer value

source

pub fn precision(self) -> u8

The precision of the Number as a number of digits.

Trait Implementations§

source§

impl Clone for Numeric

source§

fn clone(&self) -> Numeric

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Numeric

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Display for Numeric

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl From<Numeric> for f64

source§

fn from(n: Numeric) -> f64

Converts to this type from the input type.
source§

impl From<Numeric> for i128

source§

fn from(n: Numeric) -> i128

Converts to this type from the input type.
source§

impl From<Numeric> for u128

source§

fn from(n: Numeric) -> u128

Converts to this type from the input type.
source§

impl<'a> FromSql<'a> for Numeric

source§

fn from_sql(data: &'a ColumnData<'static>) -> Result<Option<Self>>

Returns the value, None being a null value, copying the value.
source§

impl FromSqlOwned for Numeric

source§

fn from_sql_owned(data: ColumnData<'static>) -> Result<Option<Self>>

Returns the value, None being a null value, taking the ownership.
source§

impl<'a> IntoSql<'a> for Numeric

source§

fn into_sql(self) -> ColumnData<'a>

Convert to a value understood by the SQL Server. Conversion by-value.
source§

impl PartialEq for Numeric

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToSql for Numeric

source§

fn to_sql(&self) -> ColumnData<'_>

Convert to a value understood by the SQL Server. Conversion by-reference.
source§

impl Copy for Numeric

source§

impl Eq for Numeric

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<'a, A> IntoRow<'a> for Awhere A: IntoSql<'a>,

source§

fn into_row(self) -> TokenRow<'a>

create a TokenRow from list of values which implements IntoSQL
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more