Skip to main content

AtomicPod

Trait AtomicPod 

Source
pub trait AtomicPod:
    Pod
    + Default
    + Send
    + Sync
    + 'static {
    type Blob: AtomicPodBlob;

    // Required methods
    fn read_from_blob(blob: &Self::Blob) -> Self;
    fn write_to_blob(&self, blob: &Self::Blob);
}
Expand description

Data that can be converted to an array of std::sync::atomic::AtomicU32 values.

That array is known as the blob (Self::Blob). The trait provides methods to copy data into and out of the blob type.

Note that, while implementing this trait isn’t unsafe, it can be tedious, and in any case implementing AtomicPodBlob is unsafe. Therefore, you should almost always use the impl_atomic_pod! macro to produce implementations of this trait.

Required Associated Types§

Source

type Blob: AtomicPodBlob

The blob type that allows shared mutation.

This type must be an array of std::sync::atomic::AtomicU32s. Because the renderer can’t guarantee that, the AtomicPodBlob trait is unsafe. However, the crate::impl_atomic_pod macro can automatically generate safe implementations of AtomicPodBlob for you.

Required Methods§

Source

fn read_from_blob(blob: &Self::Blob) -> Self

Produces a value of this type from the blob, typically by reading its fields one after another atomically.

Source

fn write_to_blob(&self, blob: &Self::Blob)

Copies the self value to the blob, typically by writing its fields one after another atomically.

Note that, because we’re using atomics, the blob parameter doesn’t need a mutable reference.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AtomicPod for ()

Implementors§