MetadataValue

Trait MetadataValue 

Source
pub trait MetadataValue:
    Unsigned
    + Zero
    + WrappingAdd
    + WrappingSub
    + Bits
    + BitwiseOps
    + ToPrimitive
    + Copy
    + FromPrimitive
    + Display
    + Debug {
    // Required methods
    unsafe fn load(addr: Address) -> Self;
    unsafe fn load_atomic(addr: Address, order: Ordering) -> Self;
    unsafe fn store(addr: Address, value: Self);
    unsafe fn store_atomic(addr: Address, value: Self, order: Ordering);
    unsafe fn compare_exchange(
        addr: Address,
        current: Self,
        new: Self,
        success: Ordering,
        failure: Ordering,
    ) -> Result<Self, Self>;
    unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self;
    unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self;
    unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self;
    unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self;
    unsafe fn fetch_update<F>(
        addr: Address,
        set_order: Ordering,
        fetch_order: Ordering,
        f: F,
    ) -> Result<Self, Self>
       where F: FnMut(Self) -> Option<Self>;
}
Expand description

The number type for accessing metadata. It requires a few traits from num-traits and a few traits we defined above. The methods in this trait are mostly about atomically accessing such types.

Required Methods§

Source

unsafe fn load(addr: Address) -> Self

Non atomic load

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type. The caller also needs to be aware that the method is not thread safe, as it is a non-atomic operation.

Source

unsafe fn load_atomic(addr: Address, order: Ordering) -> Self

Atomic load

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

Source

unsafe fn store(addr: Address, value: Self)

Non atomic store

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type. The caller also needs to be aware that the method is not thread safe, as it is a non-atomic operation.

Source

unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)

Atomic store

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type. The caller also needs to be aware that the method is not thread safe, as it is a non-atomic operation.

Source

unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering, ) -> Result<Self, Self>

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

Source

unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

Source

unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

Source

unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

Source

unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

Source

unsafe fn fetch_update<F>( addr: Address, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>,

§Safety

The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.

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 MetadataValue for u8

Source§

unsafe fn load(addr: Address) -> Self

Source§

unsafe fn load_atomic(addr: Address, order: Ordering) -> Self

Source§

unsafe fn store(addr: Address, value: Self)

Source§

unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)

Source§

unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering, ) -> Result<Self, Self>

Source§

unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_update<F>( addr: Address, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>,

Source§

impl MetadataValue for u16

Source§

unsafe fn load(addr: Address) -> Self

Source§

unsafe fn load_atomic(addr: Address, order: Ordering) -> Self

Source§

unsafe fn store(addr: Address, value: Self)

Source§

unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)

Source§

unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering, ) -> Result<Self, Self>

Source§

unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_update<F>( addr: Address, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>,

Source§

impl MetadataValue for u32

Source§

unsafe fn load(addr: Address) -> Self

Source§

unsafe fn load_atomic(addr: Address, order: Ordering) -> Self

Source§

unsafe fn store(addr: Address, value: Self)

Source§

unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)

Source§

unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering, ) -> Result<Self, Self>

Source§

unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_update<F>( addr: Address, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>,

Source§

impl MetadataValue for u64

Source§

unsafe fn load(addr: Address) -> Self

Source§

unsafe fn load_atomic(addr: Address, order: Ordering) -> Self

Source§

unsafe fn store(addr: Address, value: Self)

Source§

unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)

Source§

unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering, ) -> Result<Self, Self>

Source§

unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_update<F>( addr: Address, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>,

Source§

impl MetadataValue for usize

Source§

unsafe fn load(addr: Address) -> Self

Source§

unsafe fn load_atomic(addr: Address, order: Ordering) -> Self

Source§

unsafe fn store(addr: Address, value: Self)

Source§

unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)

Source§

unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering, ) -> Result<Self, Self>

Source§

unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self

Source§

unsafe fn fetch_update<F>( addr: Address, set_order: Ordering, fetch_order: Ordering, f: F, ) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>,

Implementors§