yaxpeax_arch

Struct AddressDiff

Source
pub struct AddressDiff<T: AddressBase> { /* private fields */ }
Expand description

a struct describing the differece between some pair of A: Address. this is primarily useful in describing the size of an instruction, or the relative offset of a branch.

for any address type A, the following must hold:

use yaxpeax_arch::AddressBase;
fn diff_check<A: AddressBase + core::fmt::Debug>(left: A, right: A) {
    let diff = left.diff(&right);
    if let Some(offset) = diff {
        assert_eq!(left.wrapping_offset(offset), right);
    }
}

which is to say, yaxpeax assumes associativity holds when diff yields a Some.

Implementations§

Source§

impl<T: Address> AddressDiff<T>

Source

pub fn from_const(amount: T::Diff) -> Self

Source

pub fn to_const(&self) -> T::Diff

Source§

impl<T: Address> AddressDiff<T>

Source

pub fn one() -> Self

Source

pub fn zero() -> Self

Trait Implementations§

Source§

impl Add<AddressDiff<u16>> for u16

Source§

type Output = u16

The resulting type after applying the + operator.
Source§

fn add(self, other: AddressDiff<Self>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<AddressDiff<u32>> for u32

Source§

type Output = u32

The resulting type after applying the + operator.
Source§

fn add(self, other: AddressDiff<Self>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<AddressDiff<u64>> for u64

Source§

type Output = u64

The resulting type after applying the + operator.
Source§

fn add(self, other: AddressDiff<Self>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<AddressDiff<usize>> for usize

Source§

type Output = usize

The resulting type after applying the + operator.
Source§

fn add(self, other: AddressDiff<Self>) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<AddressDiff<u16>> for u16

Source§

fn add_assign(&mut self, other: AddressDiff<Self>)

Performs the += operation. Read more
Source§

impl AddAssign<AddressDiff<u32>> for u32

Source§

fn add_assign(&mut self, other: AddressDiff<Self>)

Performs the += operation. Read more
Source§

impl AddAssign<AddressDiff<u64>> for u64

Source§

fn add_assign(&mut self, other: AddressDiff<Self>)

Performs the += operation. Read more
Source§

impl AddAssign<AddressDiff<usize>> for usize

Source§

fn add_assign(&mut self, other: AddressDiff<Self>)

Performs the += operation. Read more
Source§

impl<T: Clone + AddressBase> Clone for AddressDiff<T>
where T::Diff: Clone,

Source§

fn clone(&self) -> AddressDiff<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Address> Debug for AddressDiff<T>
where T::Diff: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Ord + AddressBase> Ord for AddressDiff<T>
where T::Diff: Ord,

Source§

fn cmp(&self, other: &AddressDiff<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq + AddressBase> PartialEq for AddressDiff<T>
where T::Diff: PartialEq,

Source§

fn eq(&self, other: &AddressDiff<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd + AddressBase> PartialOrd for AddressDiff<T>
where T::Diff: PartialOrd,

Source§

fn partial_cmp(&self, other: &AddressDiff<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<AddressDiff<u16>> for u16

Source§

type Output = u16

The resulting type after applying the - operator.
Source§

fn sub(self, other: AddressDiff<Self>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<AddressDiff<u32>> for u32

Source§

type Output = u32

The resulting type after applying the - operator.
Source§

fn sub(self, other: AddressDiff<Self>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<AddressDiff<u64>> for u64

Source§

type Output = u64

The resulting type after applying the - operator.
Source§

fn sub(self, other: AddressDiff<Self>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<AddressDiff<usize>> for usize

Source§

type Output = usize

The resulting type after applying the - operator.
Source§

fn sub(self, other: AddressDiff<Self>) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<AddressDiff<u16>> for u16

Source§

fn sub_assign(&mut self, other: AddressDiff<Self>)

Performs the -= operation. Read more
Source§

impl SubAssign<AddressDiff<u32>> for u32

Source§

fn sub_assign(&mut self, other: AddressDiff<Self>)

Performs the -= operation. Read more
Source§

impl SubAssign<AddressDiff<u64>> for u64

Source§

fn sub_assign(&mut self, other: AddressDiff<Self>)

Performs the -= operation. Read more
Source§

impl SubAssign<AddressDiff<usize>> for usize

Source§

fn sub_assign(&mut self, other: AddressDiff<Self>)

Performs the -= operation. Read more
Source§

impl<T: Copy + AddressBase> Copy for AddressDiff<T>
where T::Diff: Copy,

Source§

impl<T: Eq + AddressBase> Eq for AddressDiff<T>
where T::Diff: Eq,

Source§

impl<T: AddressBase> StructuralPartialEq for AddressDiff<T>

Auto Trait Implementations§

§

impl<T> Freeze for AddressDiff<T>
where <T as AddressBase>::Diff: Freeze,

§

impl<T> RefUnwindSafe for AddressDiff<T>

§

impl<T> Send for AddressDiff<T>
where <T as AddressBase>::Diff: Send,

§

impl<T> Sync for AddressDiff<T>
where <T as AddressBase>::Diff: Sync,

§

impl<T> Unpin for AddressDiff<T>
where <T as AddressBase>::Diff: Unpin,

§

impl<T> UnwindSafe for AddressDiff<T>
where <T as AddressBase>::Diff: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.