pub struct Ptr<T: ?Sized = ()> { /* private fields */ }Expand description
Typed virtual address.
Implementations§
Source§impl<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: i64) -> Ptr<U>
pub const fn offset<U: ?Sized>(self, offset: i64) -> 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§
Source§impl<T: ?Sized> Ord for Ptr<T>
impl<T: ?Sized> Ord for Ptr<T>
Source§impl<T: ?Sized> PartialOrd for Ptr<T>
impl<T: ?Sized> PartialOrd for Ptr<T>
impl<T: ?Sized> Copy for Ptr<T>
impl<T: ?Sized> Eq for Ptr<T>
impl<T: ?Sized> Pod for Ptr<T>where
Ptr<T>: 'static,
Auto Trait Implementations§
impl<T> Freeze for Ptr<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Ptr<T>where
T: ?Sized,
impl<T> Send for Ptr<T>where
T: ?Sized,
impl<T> Sync for Ptr<T>where
T: ?Sized,
impl<T> Unpin for Ptr<T>where
T: ?Sized,
impl<T> UnwindSafe for Ptr<T>where
T: ?Sized,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PodMethods for T
impl<T> PodMethods for T
Source§fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Returns the object’s memory as a mutable byte slice.
Source§fn as_data_view(&self) -> &DataView
fn as_data_view(&self) -> &DataView
Returns a data view into the object’s memory.
Source§fn 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.