Skip to main content

SpmiDevice

Trait SpmiDevice 

Source
pub trait SpmiDevice {
    // Required methods
    async fn read_reg(&self, address: u16, size: u32) -> Result<Vec<u8>, Error>;
    async fn write_reg(&self, address: u16, data: &[u8]) -> Result<(), Error>;
}
Expand description

Trait for SPMI devices to abstract register read/write operations.

This trait allows the Register and spmi_register_block! macros to interact with any underlying hardware interface or mock device that implements these basic SPMI read and write operations.

Implementations must handle the low-level transport (e.g., FIDL calls to a Fuchsia SPMI driver) and handle error mapping.

Required Methods§

Source

async fn read_reg(&self, address: u16, size: u32) -> Result<Vec<u8>, Error>

Reads a contiguous sequence of bytes from the device.

§Arguments
  • address - The 16-bit base register address to read from.
  • size - The number of bytes to read.
§Returns

Returns a vector containing the read bytes on success, or a crate::Error on failure.

Source

async fn write_reg(&self, address: u16, data: &[u8]) -> Result<(), Error>

Writes a contiguous sequence of bytes to the device.

§Arguments
  • address - The 16-bit base register address to write to.
  • data - The byte slice to write to the device.
§Returns

Returns Ok(()) on success, or a crate::Error on failure.

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 SpmiDevice for DeviceProxy

Source§

async fn read_reg(&self, address: u16, size: u32) -> Result<Vec<u8>, Error>

Source§

async fn write_reg(&self, address: u16, data: &[u8]) -> Result<(), Error>

Implementors§