use core::marker::PhantomData;
use crate::TransportError;
use crate::registers::{ReadableRegister, Register, RegisterCodec, WritableRegister};
pub struct UnsupportedCodec<E: core::fmt::Debug> {
_marker: PhantomData<E>,
}
impl<E: core::fmt::Debug> RegisterCodec for UnsupportedCodec<E> {
type Error = E;
}
#[maybe_async_cfg::maybe(
idents(hal(sync = "embedded_hal", async = "embedded_hal_async"), Codec),
sync(feature = "sync"),
async(feature = "async"),
keep_self
)]
impl<E: core::fmt::Debug> crate::registers::spi::Codec for UnsupportedCodec<E> {
#[inline]
async fn read_register<R, I>(_interface: &mut I) -> Result<R, TransportError<Self::Error, I::Error>>
where
R: Register<CodecError = Self::Error> + ReadableRegister,
I: hal::spi::r#SpiDevice,
{
Err(TransportError::Unexpected("unsupported interface"))
}
#[inline]
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: hal::spi::r#SpiDevice,
{
Err(TransportError::Unexpected("unsupported interface"))
}
}