-
Notifications
You must be signed in to change notification settings - Fork 124
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(s2n-quic-core): add buffer reader/writer traits #2097
Conversation
c009209
to
d33dfa2
Compare
e588bf2
to
4f2cbc2
Compare
bdfc68d
to
8fcf0e5
Compare
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.
Got through quic/s2n-quic-core/src/buffer/reader/storage.rs for now, publishing the initial round of comments...
10ebab1
to
d62c051
Compare
3680946
to
0f61e93
Compare
/// A wrapper around an underlying buffer (`duplex`) which will prefer to read/write from a | ||
/// user-provided temporary buffer (`storage`). The underlying buffer (`duplex`)'s current | ||
/// position and total length are updated if needed. | ||
pub struct Interposer<'a, S, D> |
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.
where did this name come from? :-)
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.
/// Maps from an infallible error into a more specific error | ||
#[inline] | ||
pub fn mapped<E>(error: Error) -> Error<E> { |
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.
What is this doing? Doesn't seem to change the error?
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.
Yeah this is when you call a function that returns an Error<Infallible>
in a function that returns Error<T>
. The conversion is sound since the reader error can never fail, but we still need to translate the other two enum variants.
Empty::new(self) | ||
} | ||
|
||
/// Enables checking the reader for correctness invariants |
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.
The comment could mention debug_assertions
must be enabled to enable this
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.
Good call
// TODO add better support for copy avoidance by iterating to the appropriate slot and | ||
// copying into that, if possible |
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.
want to add a tracking issue for these TODOs?
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 was going to try and address it relatively quickly, since this current implementation doesn't really offer any copy avoidance. but i didn't want to group this optimization in this pr, since it's already very large and this change would also be quite large 😄
476e4da
to
66cd9c9
Compare
Description of changes:
This PR implements a number of buffer traits that makes it easy to support reading/writing streams of bytes while avoiding copies as much as possible.
Call-outs:
I've renamed the
ReceiveBuffer
toReassembler
, since it better describes what it's intended use is.Testing:
Each of the concrete implementations should have a few tests showing them working and behaving correctly.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.