diff --git a/src/riot-rs-embassy-common/src/identity.rs b/src/riot-rs-embassy-common/src/identity.rs index e28cc30f5..7b9ea98c7 100644 --- a/src/riot-rs-embassy-common/src/identity.rs +++ b/src/riot-rs-embassy-common/src/identity.rs @@ -23,13 +23,6 @@ /// evolve at the (possibly faster) RIOT-rs internal speed of `riot-rs-embassy-common` for /// implementers. pub trait DeviceId: Sized + core::fmt::Debug + defmt::Format + crate::Sealed { - /// Error type indicating that no identifier is available. - /// - /// This is part of the return type of the [`Self::get()`] constructor. - /// - /// It is encouraged to be [`core::convert::Infallible`] where possible. - type Error: Error; - /// Some `[u8; N]` type, returned by [`.bytes()`][Self::bytes]. /// /// This may not represent all the identifying information available on the board, but can @@ -54,7 +47,8 @@ pub trait DeviceId: Sized + core::fmt::Debug + defmt::Format + crate::Sealed { /// # Errors /// /// This produces an error if no device ID is available on this board, or is not implemented. - fn get() -> Result; + /// It is encouraged to use [`core::convert::Infallible`] where possible. + fn get() -> Result; /// The device identifier in serialized bytes format. fn bytes(&self) -> Self::Bytes; @@ -62,8 +56,8 @@ pub trait DeviceId: Sized + core::fmt::Debug + defmt::Format + crate::Sealed { /// Error trait for obtaining [`DeviceId`]. /// -/// This type exists to ease the evolution of [`DeviceId::Error`], and to make it expressible in -/// other crates without duplicating the requirements set. +/// This is part of the signature of [`DeviceId::get`], and indicates that no identifier is +/// available. /// /// Like [`DeviceId`], it is sealed; the same considerations for stability as listed there apply. pub trait Error: core::error::Error + defmt::Format + crate::Sealed {} @@ -83,14 +77,12 @@ pub struct NoDeviceId(core::convert::Infallible, core::marke impl crate::Sealed for NoDeviceId {} impl DeviceId for NoDeviceId { - type Error = E; - // We could also come up with a custom never type that AsRef's into [u8], but that won't fly // once there is a BYTES_LEN. type Bytes = [u8; 0]; - fn get() -> Result { - Err(Default::default()) + fn get() -> Result { + Err::<_, E>(Default::default()) } fn bytes(&self) -> [u8; 0] { diff --git a/src/riot-rs-nrf/src/identity.rs b/src/riot-rs-nrf/src/identity.rs index d9c3a3781..1f0be6152 100644 --- a/src/riot-rs-nrf/src/identity.rs +++ b/src/riot-rs-nrf/src/identity.rs @@ -4,9 +4,11 @@ pub struct DeviceId(u64); impl riot_rs_embassy_common::Sealed for DeviceId {} impl riot_rs_embassy_common::identity::DeviceId for DeviceId { - type Error = core::convert::Infallible; - - fn get() -> Result { + #[allow( + refining_impl_trait_reachable, + reason = "Making this fallible would be a breaking API change for RIOT-rs." + )] + fn get() -> Result { // Embassy does not wrap the FICR register, and given that all we need from there is a register // read that is perfectly fine to do through a stolen register, let's do that rather than // thread the access through several layers. diff --git a/src/riot-rs-stm32/src/identity.rs b/src/riot-rs-stm32/src/identity.rs index e3ed0ccb6..21debff5f 100644 --- a/src/riot-rs-stm32/src/identity.rs +++ b/src/riot-rs-stm32/src/identity.rs @@ -6,9 +6,11 @@ impl riot_rs_embassy_common::Sealed for DeviceId {} impl riot_rs_embassy_common::identity::DeviceId for DeviceId { type Bytes = &'static [u8; 12]; - type Error = core::convert::Infallible; - - fn get() -> Result { + #[allow( + refining_impl_trait_reachable, + reason = "Making this fallible would be a breaking API change for RIOT-rs." + )] + fn get() -> Result { Ok(Self(embassy_stm32::uid::uid())) }