fix(nix-compat/wire/bytes/reader): always read trailer tag data

Even if we have an aligned (or zero) size (and thus have no padding),
we may still have a non-padding trailer.

Since an exact read of only the user data bytes must always read the
trailer bytes as well, this has to happen for aligned sizes too.

For zero-sized trailers, we solve this by reading immediately, since no
read is required of the user at all.

user_len thus becomes a NonZeroU64, and the definition of "body data"
is adjusted to always exclude the final block.

Change-Id: I2c6bb51270fb22ad72a65076a3468673ab56ef68
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11597
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
edef 2024-05-07 08:33:31 +00:00
parent 0472b55b20
commit ebad318ab3
3 changed files with 73 additions and 16 deletions

View file

@ -1,4 +1,4 @@
mod wire;
pub(crate) mod wire;
pub mod reader;
pub mod writer;