[][src]Struct memory_manager::common::Address

pub struct Address<'a> { /* fields omitted */ }

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:

This example panics
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]

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]

impl<'a> PartialEq<Address<'a>> for Address<'a>[src]

impl<'a> PartialOrd<Address<'a>> for Address<'a>[src]

impl<'a> StructuralEq for Address<'a>[src]

impl<'a> StructuralPartialEq for Address<'a>[src]

Auto Trait Implementations

impl<'a> !Send for Address<'a>

impl<'a> !Sync for Address<'a>

impl<'a> Unpin for Address<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.