Repository navigation
Conversation
Move Reader and Writer into blocking.rs so reader.rs and writer.rs only contain the sans-I/O Decoder and Encoder. The tests for the drivers' own behavior move along with them. No functional changes. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Only the impl block of Writer needs W: Write. With the bound on the struct definition every type and function that names a Writer<W> has to repeat it. The Rust API guidelines keep such bounds off struct definitions unless something requires them (cf. [1]), like the Drop impl of std's BufWriter does. Writer has no Drop impl and Reader already has no bound on its struct. No functional changes. [1]: https://rust-lang.github.io/api-guidelines/future-proofing.html#c-struct-bounds Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This sits on top of #19.
The uapi16 crate has a sans-I/O core in Decoder and Encoder and two thin
blocking drivers on top of it, Reader and Writer. So far the drivers
live in reader.rs and writer.rs right next to the cores. This moves them
into a module of their own, blocking.rs, the way serde_json,
tokio-util's codec and flate2 keep their I/O adapters in separate
modules. reader.rs and writer.rs now only have the code that does no
I/O.
The first commit is pure code motion. Reader and Writer are still
re-exported at the crate root, so the public API stays the same and the
callers in src/fat and src/bin don't change at all. Writer reads the
record number of its Encoder, so that field became pub(crate). So did
READ_SIZE, which the decoder tests use. The test helpers both sets of
tests use moved into the crate's testing module. A few intra-doc links
got explicit targets since what they point to is no longer in scope, and
two in the docs of Writer lost theirs since Reader now is.
The tests for the drivers' own behavior moved along: WouldBlock and
errors of the inner reader or writer, flush, get_ref(), signed_len(),
and the Iterator and FusedIterator impls. Tests that only use Reader or
Writer to get at the decoding and encoding rules stay where they are.
The second commit drops the Write bound from the Writer struct
definition and leaves it on the impl block. Writer has no Drop impl
that would need it and Reader has no bound on its struct either.