Union volatile_mem::Volatile[][src]

#[repr(C)]pub union Volatile<T: Copy, Permission = ReadWrite> {
    // some fields omitted
}

Volatile data or memory.

See crate-level documentation for details.

Implementations

impl<T: Copy, P> Volatile<T, P>[src]

pub unsafe fn from_ptr<'a>(mem: *const T) -> &'a Self[src]

Converts a pointer to T into a reference to Volatile<T>, which can be read-only, write-only, or both readable and writable (the default).

Safety

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

  • mem must be valid for reads and/or writes.

  • mem must be properly aligned.

  • mem must point to a properly initialized value of type T (unless the resulting Volatile<T> is write-only).

Note that even if T has size zero, the pointer must be non-NULL and properly aligned.

Just like in C, whether an operation is volatile has no bearing whatsoever on questions involving concurrent access from multiple threads. Volatile accesses behave exactly like non-atomic accesses in that regard. In particular, a race between a write operation any other operation (reading or writing) to the same location is undefined behavior.

pub unsafe fn from_mut_ptr<'a>(mem: *mut T) -> &'a mut Self[src]

Converts a mutable pointer to T into a mutable reference to Volatile<T>, which can be read-only, write-only, or both readable and writable (the default).

Safety

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

  • mem must be valid for reads and/or writes.

  • mem must be properly aligned.

  • mem must point to a properly initialized value of type T (unless the resulting Volatile<T> is write-only).

Note that even if T has size zero, the pointer must be non-NULL and properly aligned.

pub fn from_ref<'a>(mem: &T) -> &'a Self[src]

Converts a shared reference to T into a shared reference to Volatile<T>, which can be read-only, write-only, or both readable and writable (the default).

pub fn from_mut<'a>(mem: &mut T) -> &'a mut Self[src]

Converts a mutable reference to T into a mutable reference to Volatile<T>, which can be read-only, write-only, or both readable and writable (the default).

Trait Implementations

impl<T: Copy, P, const N: usize> AsMut<[Volatile<T, P>]> for Volatile<[T; N], P>[src]

impl<T: Copy, P, const N: usize> AsRef<[Volatile<T, P>]> for Volatile<[T; N], P>[src]

impl<T: Copy, P, const N: usize> Borrow<[Volatile<T, P>]> for Volatile<[T; N], P>[src]

impl<T: Copy, P, const N: usize> BorrowMut<[Volatile<T, P>]> for Volatile<[T; N], P>[src]

impl<T: Copy, P> Debug for Volatile<T, P>[src]

impl<T: Copy, P, const N: usize> Deref for Volatile<[T; N], P>[src]

type Target = [Volatile<T, P>]

The resulting type after dereferencing.

impl<T: Copy, P, const N: usize> DerefMut for Volatile<[T; N], P>[src]

impl<'a, T: Copy, P> From<&'a T> for &'a Volatile<T, P>[src]

impl<'a, T: Copy, P> From<&'a mut T> for &'a mut Volatile<T, P>[src]

impl<T: Copy, P> VolatileData<T> for Volatile<T, P>[src]

impl<T: Copy, P: Read> VolatileRead<T> for Volatile<T, P>[src]

fn read(&self) -> T[src]

Performs a volatile read of the value in self without moving it. This leaves the memory in self unchanged.

impl<T: Copy, P: Write> VolatileWrite<T> for Volatile<T, P>[src]

fn write(&mut self, val: T)[src]

Performs a volatile write of self with the given value without reading the old value.

Auto Trait Implementations

impl<T, Permission> Send for Volatile<T, Permission> where
    Permission: Send,
    T: Send

impl<T, Permission> Sync for Volatile<T, Permission> where
    Permission: Sync,
    T: Sync

impl<T, Permission> Unpin for Volatile<T, Permission> where
    Permission: Unpin,
    T: Unpin

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.

impl<S, T, U> VolatileReadSlice<T, U> for S where
    T: VolatileRead<U>,
    U: Copy,
    S: AsRef<[T]>, 
[src]

impl<S, T, U> VolatileWriteSlice<T, U> for S where
    T: VolatileWrite<U>,
    U: Copy,
    S: AsMut<[T]>, 
[src]