-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add support for asynchronous decoding of rrd stream #8705
base: main
Are you sure you want to change the base?
Changes from 11 commits
8f1418b
d1d7e10
b27c424
648ea1e
fa3e44b
14c8fc9
3a2a8e4
791604d
ad2cd56
45994e4
5a27933
c341c42
a70d536
bfc4433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,11 @@ impl MessageHeader { | |
let mut buf = [0; std::mem::size_of::<Self>()]; | ||
data.read_exact(&mut buf)?; | ||
|
||
Self::from_bytes(&buf) | ||
} | ||
|
||
#[cfg(feature = "decoder")] | ||
pub fn from_bytes(buf: &[u8]) -> Result<Self, crate::decoder::DecodeError> { | ||
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. I don't like the fact that this is a public method that takes a slice of bytes that must respect a bunch of undocumented invariants (e.g. this will take down the entire app if These invariants should be A) documented in the docstring and B) checked for on entry so nice error can be returned if they are violated. 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. Agree. Also, thinking about this, I don't think this should be public, Will document and add the checks regardless. |
||
#[allow(clippy::unwrap_used)] // cannot fail | ||
let kind = u64::from_le_bytes(buf[0..8].try_into().unwrap()); | ||
let kind = match kind { | ||
|
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.
please sort this 💀