Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zenoh_id): exposing into [u8; 16] & to_le_bytes() #1373

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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