CodecAsync

Trait CodecAsync 

Source
pub trait CodecAsync: RegisterCodec {
    // Required methods
    async fn read_register<R, I>(
        interface: &mut I,
    ) -> Result<R, TransportError<Self::Error, I::Error>>
       where R: Register<CodecError = Self::Error> + ReadableRegister,
             I: SpiDevice;
    async fn write_register<R, I>(
        interface: &mut I,
        register: impl AsRef<R>,
    ) -> Result<(), TransportError<Self::Error, I::Error>>
       where R: Register<CodecError = Self::Error> + WritableRegister,
             I: SpiDevice;
}
Expand description

Represents a trait for SPI codecs. These are responsible to perform writes and reads to registers, given the register address and the raw data. Different devices can have different ways to encode the desired address, R/W bit location, continuous-read mode and more.

Required Methods§

Source

async fn read_register<R, I>( interface: &mut I, ) -> Result<R, TransportError<Self::Error, I::Error>>
where R: Register<CodecError = Self::Error> + ReadableRegister, I: SpiDevice,

Read this register through the given SPI interface

Source

async fn write_register<R, I>( interface: &mut I, register: impl AsRef<R>, ) -> Result<(), TransportError<Self::Error, I::Error>>
where R: Register<CodecError = Self::Error> + WritableRegister, I: SpiDevice,

Write this register through the given SPI interface

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§

Source§

impl<E: Debug> CodecAsync for UnsupportedCodec<E>

Source§

impl<const HEADER_SIZE: usize, const ADDR_MSB: u8, const ADDR_LSB: u8, const RW_BIT: u8, const RW_1_IS_READ: bool, const READ_DELAY: usize> CodecAsync for StandardCodec<HEADER_SIZE, ADDR_MSB, ADDR_LSB, RW_BIT, RW_1_IS_READ, READ_DELAY>