Struct switchboard_solana::decimal::SwitchboardDecimal
source · #[repr(packed(1))]pub struct SwitchboardDecimal {
pub mantissa: i128,
pub scale: u32,
}
Fields§
§mantissa: i128
The part of a floating-point number that represents the significant digits of that number, and that is multiplied by the base, 10, raised to the power of scale to give the actual value of the number.
scale: u32
The number of decimal places to move to the left to yield the actual value.
Implementations§
source§impl SwitchboardDecimal
impl SwitchboardDecimal
pub fn new(mantissa: i128, scale: u32) -> SwitchboardDecimal
pub fn from_rust_decimal(d: Decimal) -> SwitchboardDecimal
pub fn from_f64(v: f64) -> SwitchboardDecimal
pub fn scale_to(&self, new_scale: u32) -> i128
pub fn new_with_scale(&self, new_scale: u32) -> Self
Trait Implementations§
source§impl BorshDeserialize for SwitchboardDecimal
impl BorshDeserialize for SwitchboardDecimal
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl Clone for SwitchboardDecimal
impl Clone for SwitchboardDecimal
source§fn clone(&self) -> SwitchboardDecimal
fn clone(&self) -> SwitchboardDecimal
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SwitchboardDecimal
impl Debug for SwitchboardDecimal
source§impl Default for SwitchboardDecimal
impl Default for SwitchboardDecimal
source§fn default() -> SwitchboardDecimal
fn default() -> SwitchboardDecimal
Returns the “default value” for a type. Read more
source§impl From<BorshDecimal> for SwitchboardDecimal
impl From<BorshDecimal> for SwitchboardDecimal
source§fn from(val: BorshDecimal) -> Self
fn from(val: BorshDecimal) -> Self
Converts to this type from the input type.
source§impl From<Decimal> for SwitchboardDecimal
impl From<Decimal> for SwitchboardDecimal
source§impl From<SwitchboardDecimal> for BorshDecimal
impl From<SwitchboardDecimal> for BorshDecimal
source§fn from(s: SwitchboardDecimal) -> Self
fn from(s: SwitchboardDecimal) -> Self
Converts to this type from the input type.
source§impl From<SwitchboardDecimal> for bool
impl From<SwitchboardDecimal> for bool
source§fn from(s: SwitchboardDecimal) -> Self
fn from(s: SwitchboardDecimal) -> Self
Converts to this type from the input type.
source§impl Ord for SwitchboardDecimal
impl Ord for SwitchboardDecimal
source§impl PartialEq for SwitchboardDecimal
impl PartialEq for SwitchboardDecimal
source§fn eq(&self, other: &SwitchboardDecimal) -> bool
fn eq(&self, other: &SwitchboardDecimal) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for SwitchboardDecimal
impl PartialOrd for SwitchboardDecimal
source§impl TryInto<Decimal> for &SwitchboardDecimal
impl TryInto<Decimal> for &SwitchboardDecimal
source§impl TryInto<Decimal> for SwitchboardDecimal
impl TryInto<Decimal> for SwitchboardDecimal
source§impl TryInto<f64> for SwitchboardDecimal
impl TryInto<f64> for SwitchboardDecimal
source§impl TryInto<i64> for SwitchboardDecimal
impl TryInto<i64> for SwitchboardDecimal
source§impl TryInto<u64> for SwitchboardDecimal
impl TryInto<u64> for SwitchboardDecimal
impl Copy for SwitchboardDecimal
impl Eq for SwitchboardDecimal
impl StructuralPartialEq for SwitchboardDecimal
Auto Trait Implementations§
impl Freeze for SwitchboardDecimal
impl RefUnwindSafe for SwitchboardDecimal
impl Send for SwitchboardDecimal
impl Sync for SwitchboardDecimal
impl Unpin for SwitchboardDecimal
impl UnwindSafe for SwitchboardDecimal
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
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