diff --git a/commons/zenoh-config/src/wrappers.rs b/commons/zenoh-config/src/wrappers.rs index fd6d2ef50b..d04950f21e 100644 --- a/commons/zenoh-config/src/wrappers.rs +++ b/commons/zenoh-config/src/wrappers.rs @@ -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 { @@ -54,6 +58,15 @@ impl From for ZenohId { } } +impl TryFrom<&[u8]> for ZenohId { + type Error = zenoh_result::Error; + + fn try_from(value: &[u8]) -> Result { + let proto: ZenohIdProto = value.try_into()?; + Ok(ZenohId::from(proto)) + } +} + impl From for ZenohIdProto { fn from(id: ZenohId) -> Self { id.0