Struct sqlx::postgres::types::PgMoney[][src]

pub struct PgMoney(pub i64);
This is supported on crate feature postgres only.

The PostgreSQL MONEY type stores a currency amount with a fixed fractional precision. The fractional precision is determined by the database's lc_monetary setting.

Data is read and written as 64-bit signed integers, and conversion into a decimal should be done using the right precision.

Reading MONEY value in text format is not supported and will cause an error.

Implementations

impl PgMoney[src]

pub fn to_bigdecimal(self, scale: i64) -> BigDecimal[src]

Convert the money value into a BigDecimal using the correct precision defined in the PostgreSQL settings. The default precision is two.

pub fn to_decimal(self, scale: u32) -> Decimal[src]

Convert the money value into a Decimal using the correct precision defined in the PostgreSQL settings. The default precision is two.

pub fn from_decimal(decimal: Decimal, scale: u32) -> PgMoney[src]

Convert a Decimal value into money using the correct precision defined in the PostgreSQL settings. The default precision is two.

Conversion may involve a loss of precision.

pub fn from_bigdecimal(
    decimal: BigDecimal,
    scale: u32
) -> Result<PgMoney, Box<dyn Error + 'static + Send + Sync, Global>>
[src]

Convert a BigDecimal value into money using the correct precision defined in the PostgreSQL settings. The default precision is two.

Trait Implementations

impl Add<PgMoney> for PgMoney[src]

type Output = PgMoney

The resulting type after applying the + operator.

pub fn add(self, rhs: PgMoney) -> <PgMoney as Add<PgMoney>>::Output[src]

Adds two monetary values.

Panics

Panics if overflowing the i64::MAX.

impl AddAssign<PgMoney> for PgMoney[src]

pub fn add_assign(&mut self, rhs: PgMoney)[src]

An assigning add for two monetary values.

Panics

Panics if overflowing the i64::MAX.

impl Clone for PgMoney[src]

impl Copy for PgMoney[src]

impl Debug for PgMoney[src]

impl<'_> Decode<'_, Postgres> for PgMoney[src]

impl<'_> Encode<'_, Postgres> for PgMoney[src]

impl Eq for PgMoney[src]

impl<T> From<T> for PgMoney where
    T: Into<i64>, 
[src]

impl PartialEq<PgMoney> for PgMoney[src]

impl StructuralEq for PgMoney[src]

impl StructuralPartialEq for PgMoney[src]

impl Sub<PgMoney> for PgMoney[src]

type Output = PgMoney

The resulting type after applying the - operator.

pub fn sub(self, rhs: PgMoney) -> <PgMoney as Sub<PgMoney>>::Output[src]

Subtracts two monetary values.

Panics

Panics if underflowing the i64::MIN.

impl SubAssign<PgMoney> for PgMoney[src]

pub fn sub_assign(&mut self, rhs: PgMoney)[src]

An assigning subtract for two monetary values.

Panics

Panics if underflowing the i64::MIN.

impl Type<Postgres> for PgMoney[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,