Expand description
Typed virtual address.
Implementations
sourceimpl<T: ?Sized> Ptr<T>
impl<T: ?Sized> Ptr<T>
sourcepub const fn cast<U: ?Sized>(self) -> Ptr<U>
pub const fn cast<U: ?Sized>(self) -> Ptr<U>
Casts the pointer to a different type keeping the pointer address fixed.
sourcepub const fn offset<U: ?Sized>(self, offset: i32) -> Ptr<U>
pub const fn offset<U: ?Sized>(self, offset: i32) -> Ptr<U>
Offsets and casts 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 = p.offset::<f32>(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 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: 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 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moresourceimpl<T: ?Sized> Pod for Ptr<T>where
Ptr<T>: 'static,
impl<T: ?Sized> Pod for Ptr<T>where
Ptr<T>: 'static,
sourcefn as_bytes(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
fn as_bytes(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Returns the object’s memory as a byte slice.
sourcefn as_bytes_mut(&mut self) -> &mut [u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
fn as_bytes_mut(&mut self) -> &mut [u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Returns the object’s memory as a mutable byte slice.
sourcefn as_data_view(&self) -> &DataView
fn as_data_view(&self) -> &DataView
Returns a data view into the object’s memory.
sourcefn as_data_view_mut(&mut self) -> &mut DataView
fn as_data_view_mut(&mut self) -> &mut DataView
Returns a mutable data view into the object’s memory.
sourcefn transmute_ref<T>(&self) -> &Twhere
T: Pod,
fn transmute_ref<T>(&self) -> &Twhere
T: Pod,
Safely transmutes references to another type. Read more
sourcefn transmute_mut<T>(&mut self) -> &mut Twhere
T: Pod,
fn transmute_mut<T>(&mut self) -> &mut Twhere
T: Pod,
Safely transmutes references to another type. Read more
impl<T: ?Sized> Copy for Ptr<T>
impl<T: ?Sized> Eq for Ptr<T>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for Ptr<T>
impl<T: ?Sized> Send for Ptr<T>
impl<T: ?Sized> Sync for Ptr<T>
impl<T: ?Sized> Unpin for Ptr<T>
impl<T: ?Sized> UnwindSafe for Ptr<T>
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