Skip to main content

RegisterInterface

Trait RegisterInterface 

Source
pub trait RegisterInterface {
    type Error;
    type AddressType: Copy;

    // Required methods
    fn write_register(
        &mut self,
        address: Self::AddressType,
        size_bits: u32,
        data: &[u8],
    ) -> Result<(), Self::Error>;
    fn read_register(
        &mut self,
        address: Self::AddressType,
        size_bits: u32,
        data: &mut [u8],
    ) -> Result<(), Self::Error>;
}
Expand description

A trait to represent the interface to the device.

This is called to write to and read from registers.

Required Associated Types§

Source

type Error

The error type

Source

type AddressType: Copy

The address type used by this interface. Should likely be an integer.

Required Methods§

Source

fn write_register( &mut self, address: Self::AddressType, size_bits: u32, data: &[u8], ) -> Result<(), Self::Error>

Write the given data to the register located at the given address

Source

fn read_register( &mut self, address: Self::AddressType, size_bits: u32, data: &mut [u8], ) -> Result<(), Self::Error>

Read the register located at the given addres to the given data slice

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§