forked from ariel-os/ariel-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(device-id): Move ID data into type
Previously, the type was just a never-instanciated-even-though-you-could type to put things into a trait. Now it *is* the return type, opening up for further evolution through provided methods.
- Loading branch information
Showing
4 changed files
with
58 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
pub struct DeviceId; | ||
#[derive(Debug, defmt::Format)] | ||
pub struct DeviceId(&'static [u8; 12]); | ||
|
||
impl riot_rs_embassy_common::identity::DeviceId for DeviceId { | ||
type DeviceId = &'static [u8; 12]; | ||
type Bytes = &'static [u8; 12]; | ||
|
||
type Error = core::convert::Infallible; | ||
|
||
fn get() -> Result<Self::DeviceId, Self::Error> { | ||
Ok(embassy_stm32::uid::uid()) | ||
fn get() -> Result<Self, Self::Error> { | ||
Ok(Self(embassy_stm32::uid::uid())) | ||
} | ||
|
||
fn bytes(&self) -> Self::Bytes { | ||
self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters