diff --git a/commons/zenoh-config/src/wrappers.rs b/commons/zenoh-config/src/wrappers.rs index fd6d2ef50b..96f365f34f 100644 --- a/commons/zenoh-config/src/wrappers.rs +++ b/commons/zenoh-config/src/wrappers.rs @@ -54,6 +54,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 @@ -72,6 +81,13 @@ impl From for OwnedKeyExpr { } } +impl From for Vec { + fn from(value: ZenohId) -> Self { + let proto: ZenohIdProto = value.into(); + proto.to_le_bytes().to_vec() + } +} + impl From<&ZenohId> for OwnedKeyExpr { fn from(zid: &ZenohId) -> Self { (*zid).into()