safeatomic

Trait AtomicSliceOps

Source
pub trait AtomicSliceOps {
    // Required methods
    unsafe fn atomic_read_ptr(&self, dest: *mut u8, len: usize);
    unsafe fn atomic_write_ptr(&self, src: *const u8, len: usize);
    fn atomic_fill(&self, value: u8);
    fn as_atomic<T: Atomic>(&self) -> Option<&T>;
    fn as_atomic_slice<T: Atomic>(&self) -> Option<&[T]>;

    // Provided methods
    fn atomic_read(&self, dest: &mut [u8]) { ... }
    fn atomic_read_obj<T: FromBytes + Immutable + KnownLayout>(&self) -> T { ... }
    fn atomic_write(&self, src: &[u8]) { ... }
    fn atomic_write_obj<T: IntoBytes + Immutable + KnownLayout>(&self, obj: &T) { ... }
}

Required Methods§

Source

unsafe fn atomic_read_ptr(&self, dest: *mut u8, len: usize)

§Safety

The caller must ensure that dest..dest+len is a valid target for writes.

Source

unsafe fn atomic_write_ptr(&self, src: *const u8, len: usize)

§Safety

The caller must ensure that src..src+len is a valid source for reads.

Source

fn atomic_fill(&self, value: u8)

Fills the slice with value.

Source

fn as_atomic<T: Atomic>(&self) -> Option<&T>

Source

fn as_atomic_slice<T: Atomic>(&self) -> Option<&[T]>

Provided Methods§

Source

fn atomic_read(&self, dest: &mut [u8])

Reads from the slice into dest.

Panics if the slice is not the same size as dest.

Source

fn atomic_read_obj<T: FromBytes + Immutable + KnownLayout>(&self) -> T

Reads an object from the slice.

Panics if the slice is not the same size as T.

Source

fn atomic_write(&self, src: &[u8])

Writes src to the slice.

Panics if the slice is not the same size as src.

Source

fn atomic_write_obj<T: IntoBytes + Immutable + KnownLayout>(&self, obj: &T)

Writes an object to the slice.

Panics if the slice is not the same size as T.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AtomicSliceOps for [AtomicU8]

Source§

unsafe fn atomic_read_ptr(&self, dest: *mut u8, len: usize)

Source§

unsafe fn atomic_write_ptr(&self, src: *const u8, len: usize)

Source§

fn atomic_fill(&self, value: u8)

Source§

fn as_atomic<T: Atomic>(&self) -> Option<&T>

Source§

fn as_atomic_slice<T: Atomic>(&self) -> Option<&[T]>

Implementors§