Struct VolBox

Source
pub struct VolBox<T, R, W> { /* private fields */ }
Expand description

An owned memory location for volatile reads and writes.

Implementations§

Source§

impl<T, R, W> VolBox<T, R, W>

Source

pub const unsafe fn new(loc: *mut T) -> Self

Acquire ownership of a memory location.

If either R or W are Warn, this volatile box should document the additional safety requirements for Self::read/Self::read_at and Self::write/Self::write_at respectively.

§Safety

Behavior is undefined if any of the following conditions are violated during the lifetime of self:

  • loc must not be aliased by any reference or read/written thru any aliased pointer.
  • loc must be valid for reads if R is not Deny.
  • loc must be valid for writes if W is not Deny.
  • loc must be properly aligned.
  • loc must point to a properly initialized value of type T if R is not Deny.
Source

pub fn into_raw(self) -> *mut T

Release ownership of the memory location.

Source§

impl<T: Copy, W> VolBox<T, Warn, W>

Source

pub unsafe fn read(&self) -> T

Performs a volatile read on the owned memory location.

§Safety

Please consult the documentation on self.

Source§

impl<T: Copy, W> VolBox<T, Allow, W>

Source

pub fn read(&self) -> T

Performs a volatile read on the owned memory location.

Source§

impl<T: Copy, R> VolBox<T, R, Warn>

Source

pub unsafe fn write(&mut self, t: T)

Performs a volatile write on the owned memory location.

§Safety

Please consult the documentation on self.

Source§

impl<T: Copy, R> VolBox<T, R, Allow>

Source

pub fn write(&mut self, t: T)

Performs a volatile write on the owned memory location.

Source§

impl<T: Copy, W, const N: usize> VolBox<[T; N], Warn, W>

Source

pub unsafe fn read_at(&self, i: usize) -> T

Performs a volatile read on the owned memory location at a specific index.

§Panics

Panics if the index is out of bounds.

§Safety

Please consult the documentation on self.

Source§

impl<T: Copy, W, const N: usize> VolBox<[T; N], Allow, W>

Source

pub fn read_at(&self, i: usize) -> T

Performs a volatile read on the owned memory location at a specific index.

§Panics

Panics if the index is out of bounds.

Source§

impl<T: Copy, R, const N: usize> VolBox<[T; N], R, Warn>

Source

pub unsafe fn write_at(&mut self, i: usize, t: T)

Performs a volatile write on the owned memory location at a specific index.

§Panics

Panics if the index is out of bounds.

§Safety

Please consult the documentation on self.

Source§

impl<T: Copy, R, const N: usize> VolBox<[T; N], R, Allow>

Source

pub fn write_at(&mut self, i: usize, t: T)

Performs a volatile write on the owned memory location at a specific index.

§Safety

Please consult the documentation on self.

Trait Implementations§

Source§

impl<T: Debug, R: Debug, W: Debug> Debug for VolBox<T, R, W>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, R, W> Pointer for VolBox<T, R, W>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Send, R, W> Send for VolBox<T, R, W>

Source§

impl<T: Sync, R, W> Sync for VolBox<T, R, W>

Auto Trait Implementations§

§

impl<T, R, W> Freeze for VolBox<T, R, W>

§

impl<T, R, W> RefUnwindSafe for VolBox<T, R, W>

§

impl<T, R, W> Unpin for VolBox<T, R, W>
where R: Unpin, W: Unpin,

§

impl<T, R, W> UnwindSafe for VolBox<T, R, W>

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> 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, 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.