RawRegisterIO

Trait RawRegisterIO 

Source
pub trait RawRegisterIO {
    type Error;

    // Required methods
    unsafe fn try_read<T: RegInt>(
        &self,
        ptr: *const T,
    ) -> Result<T, Self::Error>;
    unsafe fn try_write<T: RegInt>(
        &self,
        ptr: *mut T,
        value: T,
    ) -> Result<(), Self::Error>;
}
Expand description

Raw register I/O trait

Types that implement this trait also automatically implement RegisterIO.

Required Associated Types§

Source

type Error

The error type this register transport returns. For infallible transports (e.g., direct volatile pointer accesses), this should be core::convert::Infallible so that the Reg type can provide an infallible API in addition to the try_* API.

Required Methods§

Source

unsafe fn try_read<T: RegInt>(&self, ptr: *const T) -> Result<T, Self::Error>

Try to read a primitive integer from memory.

The returned value is in the register’s native endianness (not necessarily the host’s endianness).

§Safety

This method may dereference raw pointer. The caller must ensure the pointer is valid and points to a valid memory location.

Source

unsafe fn try_write<T: RegInt>( &self, ptr: *mut T, value: T, ) -> Result<(), Self::Error>

Try to write primitive integer to memory

The provided value is in the register’s native endianness (not necessarily the host’s endianness).

§Safety

This method may dereference a raw pointer. The caller must ensure the pointer is valid and points to a valid writeable memory location.

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.

Implementors§