Conversation
kskalski
reviewed
Mar 4, 2026
Contributor
kskalski
left a comment
There was a problem hiding this comment.
Those are awesome changes!
A couple of minor comments / questions.
c8b45dd to
9f4f6ad
Compare
244160a to
00f021d
Compare
kskalski
reviewed
Mar 12, 2026
| } | ||
|
|
||
| #[test] | ||
| fn test_reader_consume_input_too_large(bytes in any::<Vec<u8>>()) { |
Contributor
There was a problem hiding this comment.
we should keep the test I guess
kskalski
previously approved these changes
Mar 16, 2026
cbb9819 to
d06d2f9
Compare
kskalski
approved these changes
Mar 17, 2026
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 PR refactors
ReaderandWritertraits in an attempt to simplify implementations and reduce trait surface area.Removal of
TrustedAssociated TypeReaderandWriterboth have an associated typeTrusted, which must implement eitherReaderorWriterrespectively. We aren't getting value out ofTrustedbeing designated as an associated type, asSchemaRead/SchemaWriteimplementations simply take animpl Readerorimpl Writerargument -- there isn't any way to further constrain an implementation based on aReader's orWriter'sTrustedassociated type, and I can't think of a use-case where we would want that functionality (and would require adjustingread/writeto take a genericReaderorWritertype parameter, which is different, more complicated refactor).As such, the signatures of
as_trusted_fornow returnReadResult<impl Reader<'a>>orWriteResult<impl Writer>, forReaderandWriter, respectively.A nice result of this is that we can now provide a default implementation for
as_trusted_for. In particular, by default we can simply returnOk(self). ThisReader/Writerimplementations (they're already eliding bounds checks, no need to build and return another instance of itself)as_trusted_forcan simply not implement itReaderandWriteronly requires implementingcopy_into_sliceandwrite, respectively.A fun consequence of 3 is that we can easily implement something like
core::iter::from_fn, but forReaderorWriter. Unsure if this has a concrete use-case at the moment, but could see value as a convenience in io basedas_trusted_forimplementations.Additionally, we no longer have to deal with generic associated types (GATs), which get quite cumbersome to deal with and ugly in the
Readercase for non-borrowing types. E.g.,wincode/wincode/src/io/cursor.rs
Lines 124 to 131 in 343c866
vs
wincode/wincode/src/io/cursor.rs
Lines 132 to 140 in 3a4c462
Much nicer!
Refactor of
TrustedSliceReader,TrustedSliceReaderZeroCopy,Trusted....We had a proliferation of specialized
Trusted*Reader*/Trusted*Writer*, etc. These are all subsumed by three, more general types.SliceUncheckedSliceScopedUncheckedSliceMutUncheckedThis is a result of an observation that all
Trusted*permutations were effectively abstractions over an in-memory slice, with slight semantic differences:All
as_trusted_forimplementations in the library now use one of the three, which simplifies everything.Additionally, due to
ReaderandWriterno longer having an associatedTrustedtype, these implementations can totally elide alltrustedmachinery.wincode/wincode/src/io/slice.rs
Lines 57 to 95 in 343c866
vs
wincode/wincode/src/io/slice.rs
Lines 57 to 76 in 3a4c462