Trait CodecSync

Source
pub trait CodecSync: Default + 'static {
    // Required methods
    fn read_register<R, I, A>(
        bound_bus: &mut I2cBoundBusSync<I, A>,
    ) -> Result<R, I::Error>
       where R: ReadableRegister,
             I: I2c<A> + ErrorType,
             A: AddressMode + Copy;
    fn write_register<R, I, A>(
        bound_bus: &mut I2cBoundBusSync<I, A>,
        register: impl AsRef<R>,
    ) -> Result<(), I::Error>
       where R: WritableRegister,
             I: I2c<A> + ErrorType,
             A: AddressMode + Copy;
}
Expand description

Represents a trait for I2C 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, address size, continuous-read mode and more.

Required Methods§

Source

fn read_register<R, I, A>( bound_bus: &mut I2cBoundBusSync<I, A>, ) -> Result<R, I::Error>
where R: ReadableRegister, I: I2c<A> + ErrorType, A: AddressMode + Copy,

Read this register from the given I2C interface/device.

Source

fn write_register<R, I, A>( bound_bus: &mut I2cBoundBusSync<I, A>, register: impl AsRef<R>, ) -> Result<(), I::Error>
where R: WritableRegister, I: I2c<A> + ErrorType, A: AddressMode + Copy,

Write this register to the given I2C interface/device.

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 CodecSync for NoCodec

Source§

impl<const HEADER_SIZE: usize> CodecSync for SimpleCodec<HEADER_SIZE>

Source§

impl<const HEADER_SIZE: usize, const CHUNK_SIZE: usize, C: Crc8Algorithm + 'static> CodecSync for Crc8Codec<HEADER_SIZE, CHUNK_SIZE, C>