Rework tor_bytes::Truncated
Fixes #1614 (closed)
Roughly along these lines #1614 (comment 3074562)
- I tried const generics and it's quite syntactic vinegar. In my experiments turning
Reader
into a trait looked like it would help but isn't entirely straightforward and also probably not uncontroversial. - I used
from_possibly_incomplete_slice
for the new constructor. There are 8 call sites all in the same formulaic code in tor-socksproto, which is probably ripe for tidying up anyway (#1590 (closed)). FTR I don't mind renaming it (in this MR if we can come up with a good name quickly). - I did rename
Truncated
. That also removes what was an API break. - I found it best to have test cases use the
from_possibly_incomplete_slice
Reader
, but calling that in test cases was odd, so I inventedReader::from_slice_for_test
. - I renamed a whole bunch of
Reader
variables fromr
tob
since I kept tripping over them while doing bulk changes