Skip to content

Commit

Permalink
Merge pull request #1373 from ZettaScaleLabs/feat/zenohid/fromslice
Browse files Browse the repository at this point in the history
feat(zenoh_id): exposing into `[u8; 16]` & `to_le_bytes()`
  • Loading branch information
Mallets authored Sep 9, 2024
2 parents 603cc58 + 5e04759 commit f9260bb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions commons/zenoh-config/src/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl ZenohId {
pub fn into_keyexpr(self) -> OwnedKeyExpr {
self.into()
}

pub fn to_le_bytes(self) -> [u8; uhlc::ID::MAX_SIZE] {
self.0.to_le_bytes()
}
}

impl fmt::Debug for ZenohId {
Expand All @@ -54,6 +58,15 @@ impl From<ZenohIdProto> for ZenohId {
}
}

impl TryFrom<&[u8]> for ZenohId {
type Error = zenoh_result::Error;

fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
let proto: ZenohIdProto = value.try_into()?;
Ok(ZenohId::from(proto))
}
}

impl From<ZenohId> for ZenohIdProto {
fn from(id: ZenohId) -> Self {
id.0
Expand Down

0 comments on commit f9260bb

Please sign in to comment.