[−][src]Struct memory_manager::common::Address
Memory address with a valid lifetime.
We need this because raw pointers does not have a lifetime attached. Note that an Address
can be constructed from a raw pointer, and the lifetime attached is ARBITRARY, so it is on the
caller to guarantee the correct lifetime is specified.
Construct from raw pointer
use memory_manager::common::Address; let raw_p = 0xDEAD_BEEF as *mut (); let addr = Address::from(raw_p);
Debug format
assert_eq!(format!("{:?}", addr), "Address(0xdeadbeef)");
Implementations
impl<'a> Address<'a>
[src]
pub fn as_ptr<T>(&self) -> *mut T
[src]
Convert an Address
to a raw pointer of some type T
.
Note that raw pointers do not have lifetime attached, so the lifetime is dropped after
converting to a raw pointer. This should not give rise to any unsafety, as long as the
Address
was constructed correctly.
Panics
This function assert!
that the memory address is properly aligned for T
.
See also assert_aligned
.
The following use would panic:
use memory_manager::common::Address; let addr = Address::from(0xDEAD_BEEF as *mut ()); let raw_p = addr.as_ptr::<usize>();
pub unsafe fn offset(&self, count: isize) -> Self
[src]
Add an offset to an Address
.
This method is analogous to *mut T::offset
.
use memory_manager::common::Address; let addr = Address::from(0x1000 as *mut ()); assert_eq!(unsafe { addr.offset(4isize) }, Address::from(0x1004 as *mut ()));
Trait Implementations
impl<'a> Clone for Address<'a>
[src]
fn clone(&self) -> Address<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Copy for Address<'a>
[src]
impl<'a> Debug for Address<'a>
[src]
impl<'a> Eq for Address<'a>
[src]
impl<'a, T> From<*mut T> for Address<'a>
[src]
impl<'a> From<Address<'a>> for Object<'a>
[src]
impl<'a> Ord for Address<'a>
[src]
fn cmp(&self, other: &Address<'a>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a> PartialEq<Address<'a>> for Address<'a>
[src]
impl<'a> PartialOrd<Address<'a>> for Address<'a>
[src]
fn partial_cmp(&self, other: &Address<'a>) -> Option<Ordering>
[src]
fn lt(&self, other: &Address<'a>) -> bool
[src]
fn le(&self, other: &Address<'a>) -> bool
[src]
fn gt(&self, other: &Address<'a>) -> bool
[src]
fn ge(&self, other: &Address<'a>) -> bool
[src]
impl<'a> StructuralEq for Address<'a>
[src]
impl<'a> StructuralPartialEq for Address<'a>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,