pub struct Integer(_);
Expand description
An integer type that can safely convert between other number types using compile-time evaluation.
Implementations
sourceimpl Integer
impl Integer
sourcepub const fn as_i8(&self) -> Result<i8, Error>
pub const fn as_i8(&self) -> Result<i8, Error>
Returns the contained value as an i8, or an error if the value is unable to fit.
sourcepub const fn as_u8(&self) -> Result<u8, Error>
pub const fn as_u8(&self) -> Result<u8, Error>
Returns the contained value as an u8, or an error if the value is unable to fit.
sourcepub const fn as_i16(&self) -> Result<i16, Error>
pub const fn as_i16(&self) -> Result<i16, Error>
Returns the contained value as an i16, or an error if the value is unable to fit.
sourcepub const fn as_u16(&self) -> Result<u16, Error>
pub const fn as_u16(&self) -> Result<u16, Error>
Returns the contained value as an u16, or an error if the value is unable to fit.
sourcepub const fn as_i32(&self) -> Result<i32, Error>
pub const fn as_i32(&self) -> Result<i32, Error>
Returns the contained value as an i32, or an error if the value is unable to fit.
sourcepub const fn as_u32(&self) -> Result<u32, Error>
pub const fn as_u32(&self) -> Result<u32, Error>
Returns the contained value as an u32, or an error if the value is unable to fit.
sourcepub const fn as_i64(&self) -> Result<i64, Error>
pub const fn as_i64(&self) -> Result<i64, Error>
Returns the contained value as an i64, or an error if the value is unable to fit.
sourcepub const fn as_i128(&self) -> Result<i128, Error>
pub const fn as_i128(&self) -> Result<i128, Error>
Returns the contained value as an i64, or an error if the value is unable to fit.
sourcepub const fn as_u64(&self) -> Result<u64, Error>
pub const fn as_u64(&self) -> Result<u64, Error>
Returns the contained value as an u64, or an error if the value is unable to fit.
sourcepub const fn as_u128(&self) -> Result<u128, Error>
pub const fn as_u128(&self) -> Result<u128, Error>
Returns the contained value as an u64, or an error if the value is unable to fit.
sourcepub fn read_from<R: ReadBytesExt>(
kind: Kind,
byte_len: usize,
reader: &mut R
) -> Result<Self, Error>
pub fn read_from<R: ReadBytesExt>(
kind: Kind,
byte_len: usize,
reader: &mut R
) -> Result<Self, Error>
Reads an integer based on the atom header (kind
and byte_len
).
byte_len
should be the argument from the atom header directly.
sourcepub fn as_f32(&self) -> Result<f32, Error>
pub fn as_f32(&self) -> Result<f32, Error>
Converts this integer to an f32, but only if it can be done without losing precision.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Integer
impl<'de> Deserialize<'de> for Integer
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Integer
impl Eq for Integer
impl StructuralEq for Integer
impl StructuralPartialEq for Integer
Auto Trait Implementations
impl RefUnwindSafe for Integer
impl Send for Integer
impl Sync for Integer
impl Unpin for Integer
impl UnwindSafe for Integer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more