Skip to content

uapi16: move Reader and Writer into their own module - #30

Merged
brauner merged 2 commits into
manifestfrom
blocking
Nov 21, 2026
Merged

brauner merged 2 commits into
manifestfrom
blocking

Conversation

@brauner

@brauner brauner commented Nov 20, 2026

Copy link
Copy Markdown
Member

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.

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>
@brauner
brauner added this pull request to stack #29 November 20, 2026 23:44
@brauner
brauner merged commit 186671f into main Nov 21, 2026
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant