Struct Byte

Source
#[repr(C)]
pub struct Byte(/* private fields */);
Expand description

A Byte is a value representing data, useful for its ability to be addressed and subsequently accessed by a ByteAddr. Suppose you have some byte address in ba and you want to ensure that the lowest bit of that word is not set:

let b : Byte = ba.load();
assert!(b.is_aligned_to(2) == true);

Trait Implementations§

Source§

impl Address for Byte

Source§

fn from_usize(val: usize) -> Byte

Constructor for a byte value from a raw usize.

let w = Byte::from_usize(0xff);
Source§

fn as_usize(&self) -> usize

Deconstructor for a byte value into a raw usize value.

let w = Byte::from_usize(0xff);
assert!(w.as_usize() == 255);
Source§

fn verify(self) -> bool

All possible byte values are valid:

let w = Byte::from_usize(0xff);
assert!(w.verify());
Source§

fn load<T: Copy>(&self) -> T

A byte cannot be accessed.

Source§

fn store<T>(&self, _value: T)

A byte cannot be accessed.

Source§

fn memset(&self, _char: u8, _length: usize)

Raw byte values are not writeable.

Source§

fn plus<A: Address>(&self, bytes: usize) -> A

Add some number of bytes to this address, producing an address of type A. Read more
Source§

fn sub<A: Address>(&self, bytes: usize) -> A

Subtract some number of bytes from this address, producing an address of type A. Read more
Source§

fn offset<T, A: Address>(&self, offset: usize) -> A

Offset this &self address some number of instances of type T, producing an address of type A. Read more
Source§

fn is_zero(&self) -> bool

Is the value of this address equivalent to the (universal) null value? Read more
Source§

fn align_up<A: Address>(&self, align: usize) -> A

Align this pointer up (increasing value) to the nearest address with a value aligned to align bytes. For example the following properties hold: Read more
Source§

fn gte<A: Address>(&self, addr: A) -> bool

Is the value of this address greater than or equal to the value of the given address? Read more
Source§

fn greater<A: Address>(&self, addr: A) -> bool

Is the value of this address greater than the value of the given address? Read more
Source§

fn lte<A: Address>(&self, addr: A) -> bool

Is the value of this address less than or equal to the value of the given address? Read more
Source§

fn less<A: Address>(&self, addr: A) -> bool

Is the value of this address less than the value of the given address? Read more
Source§

fn is_aligned_to(&self, align: usize) -> bool

Is the value of this address exactly aligned to the given alignment? Read more
Source§

fn from_ptr<T>(ptr: *const T) -> Self

Construct an address from an immutable constant Rust pointer type. Read more
Source§

fn to_ptr<T>(&self) -> *const T

Deconstruct an address into an immutable constant Rust pointer type. Read more
Source§

fn to_ptr_mut<T>(&self) -> *mut T

Construct an address from a mutable constant Rust pointer type. Read more
Source§

fn zero() -> Self

Construct the (universal) null address. Read more
Source§

fn diff<A: Address>(&self, another: A) -> usize

Compute the number of bytes before this address (exclusive) and after another address (inclusive). Read more
Source§

impl Clone for Byte

Source§

fn clone(&self) -> Byte

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Byte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Display this address as a prettified alphanumeric hex string for debugging.

Source§

impl Display for Byte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Display this address as a prettified alphanumeric hex string.

Source§

impl Hash for Byte

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Byte

Source§

fn cmp(&self, other: &Byte) -> Ordering

Address ordinality delegates to usize ordinality.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Byte

Source§

fn eq(&self, other: &Byte) -> bool

Address equality delegates to usize equality

Source§

fn ne(&self, other: &Byte) -> bool

Address inequality delegates to usize equality

Source§

impl PartialOrd for Byte

Source§

fn partial_cmp(&self, other: &Byte) -> Option<Ordering>

Address ordinality delegates to usize ordinality.

1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Pointer for Byte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Display this address as a prettified alphanumeric hex string.

Source§

impl UpperHex for Byte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Format this address as an alphanumeric hex string.

Source§

impl Copy for Byte

Source§

impl Eq for Byte

Auto Trait Implementations§

§

impl Freeze for Byte

§

impl RefUnwindSafe for Byte

§

impl Send for Byte

§

impl Sync for Byte

§

impl Unpin for Byte

§

impl UnwindSafe for Byte

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.