[][src]Struct shared_data::Volatile

pub struct Volatile<T>(_);

Data stored in memory that can be changed at any time, for example shared memory.

It is safe to take a reference to a Volatile<T> in shared memory, even when it is not safe to take a reference to a T in shared memory. For example if a usize is stored in shared memory, it is not safe to take a &usize reference to it, since the Rust compiler assumes that the value pointed to is immutable, and it's UB if the value changes.

The trait SharedMemRef allows a &Volatile<T> to be dereferenced as a &T when its safe to do so, for example for AtomicUsize.

Methods

impl<T: SharedMemCast> Volatile<T>[src]

pub fn new(value: T) -> Volatile<T>[src]

Create a new volatile.

pub fn zeroed() -> Volatile<T>[src]

A volatile whose byte representation is all zeros.

pub fn from_volatile_bytes(bytes: &[Volatile<u8>]) -> Option<&Volatile<T>>[src]

Try to create a volatile from some volatile bytes. Returns None if there are not enough bytes.

pub fn slice_from_volatile_bytes(
    bytes: &[Volatile<u8>],
    length: usize
) -> Option<&[Volatile<T>]>
[src]

Try to create a slice of volatiles from some volatile bytes. Returns None if there are not enough bytes.

pub fn as_ptr(&self) -> *mut T[src]

The volatile as a raw pointer.

pub fn read_volatile(&self) -> T[src]

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

This has the same semantics as ptr::read_volatile.

This may have unexpected results if T does not implement Copy,

pub fn write_volatile(&self, value: T)[src]

Performs a volatile write of the underlying value with the given value without reading or dropping the old value.

This has the same semantics as ptr::write_volatile.

This may have unexpected results if T has drop code.

Trait Implementations

impl<T: SharedMemCast + SharedMemRef> Deref for Volatile<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: SharedMemCast> Send for Volatile<T>[src]

impl<T: SharedMemCast> SharedMemCast for Volatile<T>[src]

impl<T: SharedMemCast> SharedMemRef for Volatile<T>[src]

impl<T: SharedMemCast> Sync for Volatile<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Volatile<T>

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

impl<T> UnwindSafe for Volatile<T> where
    T: UnwindSafe

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> Erased for T[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<V, T> VZip<V> for T where
    V: MultiLane<T>,