[][src]Struct memflow::types::address::Address

#[repr(transparent)]pub struct Address(_);

This type represents a address on the target system. It internally holds a u64 value but can also be used when working in 32-bit environments.

This type will not handle overflow for 32-bit or 64-bit addresses / lengths.

Implementations

impl Address[src]

pub const NULL: Address[src]

A address with the value of zero.

Examples

use memflow::types::Address;

println!("address: {}", Address::NULL);

pub const INVALID: Address[src]

A address with an invalid value.

Examples

use memflow::types::Address;

println!("address: {}", Address::INVALID);

pub const fn null() -> Self[src]

Returns an address with a value of zero.

Examples

use memflow::types::Address;

println!("address: {}", Address::null());

pub fn bit_mask<T: TryInto<u64>>(bits: Range<T>) -> Address[src]

Creates a a bit mask. This function accepts an (half-open) range excluding the end bit from the mask.

Examples

use memflow::types::Address;

println!("mask: {}", Address::bit_mask(0..11));

pub const fn is_null(self) -> bool[src]

Checks wether the address is zero or not.

Examples

use memflow::types::Address;

assert_eq!(Address::null().is_null(), true);
assert_eq!(Address::from(0x1000u64).is_null(), false);

pub fn non_null(self) -> Option<Address>[src]

Converts the address to an Option that is None when it is null

Examples

use memflow::types::Address;

assert_eq!(Address::null().non_null(), None);
assert_eq!(Address::from(0x1000u64).non_null(), Some(Address::from(0x1000)));

pub const fn invalid() -> Self[src]

Returns an address with a invalid value.

Examples

use memflow::types::Address;

println!("address: {}", Address::invalid());

pub const fn is_valid(self) -> bool[src]

Checks wether the address is valid or not.

Examples

use memflow::types::Address;

assert_eq!(Address::invalid().is_valid(), false);
assert_eq!(Address::from(0x1000u64).is_valid(), true);

pub const fn as_u32(self) -> u32[src]

Converts the address into a u32 value.

Examples

use memflow::types::Address;

let addr = Address::from(0x1000u64);
let addr_u32: u32 = addr.as_u32();
assert_eq!(addr_u32, 0x1000);

pub const fn as_u64(self) -> u64[src]

Converts the address into a u64 value.

Examples

use memflow::types::Address;

let addr = Address::from(0x1000u64);
let addr_u64: u64 = addr.as_u64();
assert_eq!(addr_u64, 0x1000);

pub const fn as_usize(self) -> usize[src]

Converts the address into a usize value.

Examples

use memflow::types::Address;

let addr = Address::from(0x1000u64);
let addr_usize: usize = addr.as_usize();
assert_eq!(addr_usize, 0x1000);

pub const fn as_page_aligned(self, page_size: usize) -> Address[src]

Aligns the containing address to the given page size. It returns the base address of the containing page.

Examples

use memflow::types::{Address, size};

let addr = Address::from(0x1234);
let aligned = addr.as_page_aligned(size::kb(4));
assert_eq!(aligned, Address::from(0x1000));

pub const fn bit_at(self, idx: u8) -> bool[src]

Returns true or false wether the bit at the specified index is either 0 or 1. An index of 0 will check the least significant bit.

Examples

use memflow::types::Address;

let addr = Address::from(2);
let bit = addr.bit_at(1);
assert_eq!(bit, true);

pub fn extract_bits<T: TryInto<u64>>(self, bits: Range<T>) -> Address[src]

Extracts the given range of bits by applying a corresponding bitmask. This function accepts an (half-open) range excluding the end bit from the mask.

Examples

use memflow::types::Address;

let addr = Address::from(123456789);
println!("bits[0..2] = {}", addr.extract_bits(0..2));

Trait Implementations

impl<'a, T: Into<u64> + Copy> Add<&'a T> for Address[src]

Adds any compatible type reference to Address

type Output = Self

The resulting type after applying the + operator.

impl Add<usize> for Address[src]

Adds a usize to a Address which results in a Address.

Examples

use memflow::types::Address;
assert_eq!(Address::from(10) + 5usize, Address::from(15));

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<usize> for Address[src]

Adds a usize to a Address.

Examples

use memflow::types::Address;

let mut addr = Address::from(10);
addr += 5;
assert_eq!(addr, Address::from(15));

impl Clone for Address[src]

impl Copy for Address[src]

impl Debug for Address[src]

impl Default for Address[src]

Returns a address with a value of zero.

Examples

use memflow::types::Address;

assert_eq!(Address::default().is_null(), true);

impl<'de> Deserialize<'de> for Address[src]

impl Display for Address[src]

impl Eq for Address[src]

impl From<Address> for PhysicalAddress[src]

Converts a Address into a PhysicalAddress with no page information attached.

impl From<PhysicalAddress> for Address[src]

Converts a PhysicalAddress into a Address.

impl<T: ?Sized> From<Pointer32<T>> for Address[src]

impl<T: ?Sized> From<Pointer64<T>> for Address[src]

impl From<i32> for Address[src]

Constructs an Address from a i32 value.

impl From<u32> for Address[src]

Constructs an Address from a u32 value.

impl From<u64> for Address[src]

Constructs an Address from a u64 value.

impl From<usize> for Address[src]

Constructs an Address from a usize value.

impl LowerHex for Address[src]

impl Ord for Address[src]

impl PartialEq<Address> for Address[src]

impl PartialOrd<Address> for Address[src]

impl Serialize for Address[src]

impl StructuralEq for Address[src]

impl StructuralPartialEq for Address[src]

impl<'a, T: Into<u64> + Copy> Sub<&'a T> for Address[src]

Subtracts any compatible type reference to Address

type Output = Self

The resulting type after applying the - operator.

impl Sub<Address> for Address[src]

Subtracts a Address from a Address resulting in a usize.

Examples

use memflow::types::Address;

assert_eq!(Address::from(10) - 5, Address::from(5));

type Output = usize

The resulting type after applying the - operator.

impl Sub<usize> for Address[src]

Subtracts a usize from a Address resulting in a Address.

type Output = Address

The resulting type after applying the - operator.

impl SubAssign<usize> for Address[src]

Subtracts a usize from a Address.

Examples

use memflow::types::Address;

let mut addr = Address::from(10);
addr -= 5;
assert_eq!(addr, Address::from(5));

impl UpperHex for Address[src]

Auto Trait Implementations

impl RefUnwindSafe for Address

impl Send for Address

impl Sync for Address

impl Unpin for Address

impl UnwindSafe for Address

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.