Skip to content

Commit f9260bb

Browse files
authored
Merge pull request #1373 from ZettaScaleLabs/feat/zenohid/fromslice
feat(zenoh_id): exposing into `[u8; 16]` & `to_le_bytes()`
2 parents 603cc58 + 5e04759 commit f9260bb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

commons/zenoh-config/src/wrappers.rs

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ impl ZenohId {
3535
pub fn into_keyexpr(self) -> OwnedKeyExpr {
3636
self.into()
3737
}
38+
39+
pub fn to_le_bytes(self) -> [u8; uhlc::ID::MAX_SIZE] {
40+
self.0.to_le_bytes()
41+
}
3842
}
3943

4044
impl fmt::Debug for ZenohId {
@@ -54,6 +58,15 @@ impl From<ZenohIdProto> for ZenohId {
5458
}
5559
}
5660

61+
impl TryFrom<&[u8]> for ZenohId {
62+
type Error = zenoh_result::Error;
63+
64+
fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
65+
let proto: ZenohIdProto = value.try_into()?;
66+
Ok(ZenohId::from(proto))
67+
}
68+
}
69+
5770
impl From<ZenohId> for ZenohIdProto {
5871
fn from(id: ZenohId) -> Self {
5972
id.0

0 commit comments

Comments
 (0)