pub struct Number { /* private fields */ }
Expand description
An integral value in a particular Numeric
representation.
Implementations§
Source§impl Number
impl Number
Sourcepub const fn from_u64_and_size(val: u64, size: Size) -> Self
pub const fn from_u64_and_size(val: u64, size: Size) -> Self
Cast a short constant to a specific representation.
pub const fn from_u64_and_repr(value: u64, repr: NumericRepr) -> Self
pub const fn repr(self) -> NumericRepr
pub fn byte(val: u8) -> Self
pub fn word(val: u16) -> Self
pub fn dword(val: u32) -> Self
pub fn qword(val: u64) -> Self
pub fn as_u8(self) -> u8
pub fn as_i8(self) -> i8
pub fn as_u16(self) -> u16
pub fn as_i16(self) -> i16
pub fn as_u32(self) -> u32
pub fn as_i32(self) -> i32
pub fn as_u64(self) -> u64
pub fn as_i64(self) -> i64
Sourcepub fn cast_as(self, repr: NumericRepr) -> Number
pub fn cast_as(self, repr: NumericRepr) -> Number
Perform a cast in 2-complement.
Casts work like Rust as
coercion. A sign extension is performed when the source is
signed, else the number is zero extended.
Sourcepub fn convert(self, repr: NumericRepr) -> Option<Number>
pub fn convert(self, repr: NumericRepr) -> Option<Number>
Do a value preserving (TryFrom
) conversion.
This is not the same as lossless, u32
and i32
can be converted without loss but do not
preserve the values.
pub fn make_signed(self, signed: bool) -> Number
pub fn write_le_bytes(self, buf: &mut Vec<u8>)
pub fn to_le_bytes(self) -> Vec<u8> ⓘ
Trait Implementations§
Source§impl Ord for Number
impl Ord for Number
Source§impl PartialOrd for Number
impl PartialOrd for Number
impl Copy for Number
impl Eq for Number
impl StructuralPartialEq for Number
Auto Trait Implementations§
impl Freeze for Number
impl RefUnwindSafe for Number
impl Send for Number
impl Sync for Number
impl Unpin for Number
impl UnwindSafe for Number
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