Struct sqlx_pg_uint::PgU64
source · pub struct PgU64 { /* private fields */ }Expand description
PostgreSQL-compatible unsigned 64-bit integer
Implementations§
source§impl PgU64
impl PgU64
sourcepub fn to_uint(&self) -> <PgU64 as UIntType>::Uint
pub fn to_uint(&self) -> <PgU64 as UIntType>::Uint
Converts this type to the associated unsigned integer type
Examples found in repository?
examples/example.rs (line 7)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let a_u64_number = 2937854645u64;
let pg_u_64 = PgU64::from(a_u64_number);
println!("PgU64: {}", pg_u_64);
let back_to_u64: u64 = pg_u_64.to_uint();
println!("Back to u64: {}", back_to_u64);
println!(
"Maths work the same way as you'd expect: {}",
PgU64::from(67) + PgU64::from(2) * PgU64::from(3) / PgU64::from(3)
);
println!(
"Interact with the underlying BigDecimal type directly: {}",
pg_u_64.as_big_decimal()
);
println!("PgUint types can be converted to and from BigDecimals, and are storable in an sqlx::Postgres database.");
println!("If you load a PgUint from a database successfully, you can be sure that it's a valid fixed-size unsigned integer.");
}sourcepub fn new(num: <PgU64 as UIntType>::Uint) -> Self
pub fn new(num: <PgU64 as UIntType>::Uint) -> Self
Creates a new instance of this type from the associated unsigned integer type
sourcepub fn as_big_decimal(&self) -> &BigDecimal
pub fn as_big_decimal(&self) -> &BigDecimal
Returns a shared reference to the inner BigDecimal value
Examples found in repository?
examples/example.rs (line 15)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let a_u64_number = 2937854645u64;
let pg_u_64 = PgU64::from(a_u64_number);
println!("PgU64: {}", pg_u_64);
let back_to_u64: u64 = pg_u_64.to_uint();
println!("Back to u64: {}", back_to_u64);
println!(
"Maths work the same way as you'd expect: {}",
PgU64::from(67) + PgU64::from(2) * PgU64::from(3) / PgU64::from(3)
);
println!(
"Interact with the underlying BigDecimal type directly: {}",
pg_u_64.as_big_decimal()
);
println!("PgUint types can be converted to and from BigDecimals, and are storable in an sqlx::Postgres database.");
println!("If you load a PgUint from a database successfully, you can be sure that it's a valid fixed-size unsigned integer.");
}Trait Implementations§
source§impl AddAssign for PgU64
impl AddAssign for PgU64
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl DivAssign for PgU64
impl DivAssign for PgU64
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moresource§impl<'q> Encode<'q, Postgres> for PgU64
impl<'q> Encode<'q, Postgres> for PgU64
source§fn encode_by_ref(
&self,
buf: &mut <Postgres as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <Postgres as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
Writes the value of
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
source§impl From<PgU64> for BigDecimal
impl From<PgU64> for BigDecimal
source§impl MulAssign for PgU64
impl MulAssign for PgU64
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moresource§impl Ord for PgU64
impl Ord for PgU64
source§impl PartialOrd for PgU64
impl PartialOrd for PgU64
source§impl SubAssign for PgU64
impl SubAssign for PgU64
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moresource§impl TryFrom<BigDecimal> for PgU64
impl TryFrom<BigDecimal> for PgU64
impl Eq for PgU64
impl StructuralPartialEq for PgU64
Auto Trait Implementations§
impl Freeze for PgU64
impl RefUnwindSafe for PgU64
impl Send for PgU64
impl Sync for PgU64
impl Unpin for PgU64
impl UnwindSafe for PgU64
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more