pub trait CodecAsync: RegisterCodec {
// Required methods
async fn read_register<R, I, A>(
bound_bus: &mut I2cBoundBusAsync<I, A>,
) -> Result<R, TransportError<Self::Error, I::Error>>
where R: Register<CodecError = Self::Error> + ReadableRegister,
I: I2c<A> + ErrorType,
A: AddressMode + Copy + Debug;
async fn write_register<R, I, A>(
bound_bus: &mut I2cBoundBusAsync<I, A>,
register: impl AsRef<R>,
) -> Result<(), TransportError<Self::Error, I::Error>>
where R: Register<CodecError = Self::Error> + WritableRegister,
I: I2c<A> + ErrorType,
A: AddressMode + Copy + Debug;
}
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§
Sourceasync fn read_register<R, I, A>(
bound_bus: &mut I2cBoundBusAsync<I, A>,
) -> Result<R, TransportError<Self::Error, I::Error>>where
R: Register<CodecError = Self::Error> + ReadableRegister,
I: I2c<A> + ErrorType,
A: AddressMode + Copy + Debug,
async fn read_register<R, I, A>(
bound_bus: &mut I2cBoundBusAsync<I, A>,
) -> Result<R, TransportError<Self::Error, I::Error>>where
R: Register<CodecError = Self::Error> + ReadableRegister,
I: I2c<A> + ErrorType,
A: AddressMode + Copy + Debug,
Read this register through the given I2C interface.
Sourceasync fn write_register<R, I, A>(
bound_bus: &mut I2cBoundBusAsync<I, A>,
register: impl AsRef<R>,
) -> Result<(), TransportError<Self::Error, I::Error>>where
R: Register<CodecError = Self::Error> + WritableRegister,
I: I2c<A> + ErrorType,
A: AddressMode + Copy + Debug,
async fn write_register<R, I, A>(
bound_bus: &mut I2cBoundBusAsync<I, A>,
register: impl AsRef<R>,
) -> Result<(), TransportError<Self::Error, I::Error>>where
R: Register<CodecError = Self::Error> + WritableRegister,
I: I2c<A> + ErrorType,
A: AddressMode + Copy + Debug,
Write this register through the given I2C 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.