pub struct Integer(pub BigInt);Tuple Fields§
§0: BigIntImplementations§
Source§impl Integer
impl Integer
pub fn new<T: Into<BigInt>>(value: T) -> Self
Sourcepub fn from_string(s: &str) -> Result<Self, NumberParseError>
pub fn from_string(s: &str) -> Result<Self, NumberParseError>
Parse an integer from a string in base 10. Returns an error if the string is not a valid integer.
Sourcepub fn from_string_radix(s: &str, radix: u32) -> Result<Self, NumberParseError>
pub fn from_string_radix(s: &str, radix: u32) -> Result<Self, NumberParseError>
Parse an integer from a string in the given radix (base). Returns an error if the string is not a valid integer in the given radix.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if the integer is negative. Note that zero is neither positive nor negative.
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if the integer is positive. Note that zero is neither positive nor negative.
Sourcepub fn as_i8(&self) -> Option<i8>
pub fn as_i8(&self) -> Option<i8>
Converts the integer to an i8 if it fits, otherwise returns None.
Sourcepub fn as_u8(&self) -> Option<u8>
pub fn as_u8(&self) -> Option<u8>
Converts the integer to a u8 if it fits, otherwise returns None.
Sourcepub fn as_i16(&self) -> Option<i16>
pub fn as_i16(&self) -> Option<i16>
Converts the integer to an i16 if it fits, otherwise returns None.
Sourcepub fn as_u16(&self) -> Option<u16>
pub fn as_u16(&self) -> Option<u16>
Converts the integer to a u16 if it fits, otherwise returns None.
Sourcepub fn as_i32(&self) -> Option<i32>
pub fn as_i32(&self) -> Option<i32>
Converts the integer to an i32 if it fits, otherwise returns None.
Sourcepub fn as_u32(&self) -> Option<u32>
pub fn as_u32(&self) -> Option<u32>
Converts the integer to a u32 if it fits, otherwise returns None.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Converts the integer to an i64 if it fits, otherwise returns None.
Sourcepub fn as_usize(&self) -> Option<usize>
pub fn as_usize(&self) -> Option<usize>
Converts the integer to a usize if it fits, otherwise returns None.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Converts the integer to a u64 if it fits, otherwise returns None.
Sourcepub fn as_i128(&self) -> Option<i128>
pub fn as_i128(&self) -> Option<i128>
Converts the integer to an i128 if it fits, otherwise returns None.
Sourcepub fn as_u128(&self) -> Option<u128>
pub fn as_u128(&self) -> Option<u128>
Converts the integer to a u128 if it fits, otherwise returns None.
pub fn as_f32(&self) -> f32
pub fn as_f64(&self) -> f64
Sourcepub fn as_wrapped_i8(&self) -> i8
pub fn as_wrapped_i8(&self) -> i8
Converts the integer to an i8, wrapping on overflow.
Sourcepub fn as_wrapped_u8(&self) -> u8
pub fn as_wrapped_u8(&self) -> u8
Converts the integer to a u8, wrapping on overflow.
pub fn as_wrapped_i16(&self) -> i16
pub fn as_wrapped_u16(&self) -> u16
pub fn as_wrapped_i32(&self) -> i32
pub fn as_wrapped_u32(&self) -> u32
pub fn as_wrapped_i64(&self) -> i64
pub fn as_wrapped_u64(&self) -> u64
pub fn as_wrapped_i128(&self) -> i128
pub fn as_wrapped_u128(&self) -> u128
Sourcepub fn to_smallest_fitting(&self) -> TypedInteger
pub fn to_smallest_fitting(&self) -> TypedInteger
Converts the integer to the smallest fitting TypedInteger variant. If it doesn’t fit in any smaller type, returns TypedInteger::Big.
Trait Implementations§
Source§impl BinRead for Integer
impl BinRead for Integer
Source§fn read_options<R: Read + Seek>(
reader: &mut R,
_endian: Endian,
_: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( reader: &mut R, _endian: Endian, _: Self::Args<'_>, ) -> BinResult<Self>
Source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
big-endian byte order. Read moreSource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
little-endian byte order. Read moreSource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T from the reader assuming native-endian byte order. Read moreSource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader, assuming big-endian byte order, using the
given arguments. Read moreSource§impl BinWrite for Integer
impl BinWrite for Integer
Source§fn write_options<W: Write + Seek>(
&self,
writer: &mut W,
_endian: Endian,
_: Self::Args<'_>,
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, writer: &mut W, _endian: Endian, _: Self::Args<'_>, ) -> BinResult<()>
Source§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming big-endian byte order. Read moreSource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming little-endian byte order. Read moreSource§fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming native-endian byte order. Read moreSource§fn write_be_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self to the writer, assuming big-endian byte order, using the
given arguments. Read moreSource§impl<'de> Deserialize<'de> for Integer
impl<'de> Deserialize<'de> for Integer
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<Integer> for StructuralTypeDefinition
impl From<Integer> for StructuralTypeDefinition
Source§impl From<TypedInteger> for Integer
impl From<TypedInteger> for Integer
Source§fn from(value: TypedInteger) -> Self
fn from(value: TypedInteger) -> Self
Source§impl PartialOrd for Integer
impl PartialOrd for Integer
Source§impl StructuralEq for Integer
impl StructuralEq for Integer
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
impl Eq for Integer
impl StructuralPartialEq for Integer
Auto Trait Implementations§
impl Freeze for Integer
impl RefUnwindSafe for Integer
impl Send for Integer
impl Sync for Integer
impl Unpin for Integer
impl UnsafeUnpin for Integer
impl UnwindSafe for Integer
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§impl<T> CustomError for T
impl<T> CustomError for T
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
key and return true if they are equal.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>
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>
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