-
Notifications
You must be signed in to change notification settings - Fork 33
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
Use new Serialization and zenoh-ext API #279
Changes from 3 commits
73dc183
672ad23
9ebe16a
1782a73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,16 +228,22 @@ impl CddsRequestHeader { | |
buf[16] = self.is_little_endian as u8; | ||
|
||
hashmap.insert(ATTACHMENT_KEY_REQUEST_HEADER, buf); | ||
ZBytes::from_iter(hashmap.iter()) | ||
|
||
let mut writer = ZBytes::writer(); | ||
for (k, v) in hashmap.iter() { | ||
writer.append(ZBytes::from(k)); | ||
writer.append(ZBytes::from(v)); | ||
} | ||
writer.finish() | ||
} | ||
} | ||
|
||
impl TryFrom<&ZBytes> for CddsRequestHeader { | ||
type Error = ZError; | ||
|
||
fn try_from(value: &ZBytes) -> Result<Self, Self::Error> { | ||
let hashmap: HashMap<[u8; 3], [u8; 17]> = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On receiving side, we expect the the attachment
Rather than using a hashmap, we could just do:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading Bytes from slice, failing if not enough bytes are found or if bytes do not match |
||
HashMap::from_iter(value.iter::<([u8; 3], [u8; 17])>().map(Result::unwrap)); | ||
let hashmap: HashMap<[u8; 3], [u8; 17]> = zenoh_ext::z_deserialize(value).unwrap(); | ||
|
||
match hashmap.get(&ATTACHMENT_KEY_REQUEST_HEADER) { | ||
Some(buf) => { | ||
if buf.len() == 17 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why a hashmap was used... probably for ease of serialization via
ZBytes::from_iter(hashmap.iter())
.But now that this ease is gone, I don't see the point of this hashmap. We could just do:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed Hashmap, packing bytes directly.