Expand description
Typed virtual address.
Implementations
sourceimpl<T: ?Sized> Ptr<T>
impl<T: ?Sized> Ptr<T>
sourcepub fn cast<U: ?Sized>(self) -> Ptr<U>
pub fn cast<U: ?Sized>(self) -> Ptr<U>
Casts the pointer to a different type keeping the pointer address fixed.
sourcepub fn shift<U: ?Sized>(self, offset: Va) -> Ptr<U>
pub fn shift<U: ?Sized>(self, offset: Va) -> Ptr<U>
Offset and cast the pointer.
Access nearby values (such as data members) by offsetting and casting the pointer.
Because the type of the current and the target may be unrelated, this is a byte offset.
Examples
use pelite::pe64::Ptr;
#[repr(C)]
struct Composite {
int: i32,
float: f32,
}
let p: Ptr<Composite> = Ptr::from(0x2000);
let target: Ptr<f32> = p.shift(4);
assert_eq!(target, Ptr::from(0x2004));
Trait Implementations
sourceimpl<T: ?Sized> Ord for Ptr<T>
impl<T: ?Sized> Ord for Ptr<T>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: ?Sized> PartialOrd<Ptr<T>> for Ptr<T>
impl<T: ?Sized> PartialOrd<Ptr<T>> for Ptr<T>
sourcefn partial_cmp(&self, rhs: &Ptr<T>) -> Option<Ordering>
fn partial_cmp(&self, rhs: &Ptr<T>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T: ?Sized> Copy for Ptr<T>
impl<T: ?Sized> Eq for Ptr<T>
impl<T: ?Sized> Send for Ptr<T>
impl<T: ?Sized> Sync for Ptr<T>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for Ptr<T>where
T: RefUnwindSafe,
impl<T: ?Sized> Unpin for Ptr<T>
impl<T: ?Sized> UnwindSafe for Ptr<T>where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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