From eeca2d92e236f092b4b26512c40362a791a6b307 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 8 Apr 2024 17:59:05 +0300 Subject: feat(tvix/nix-compat): add BytesReader This adds AsyncRead counterpart for read_bytes. Change-Id: I751da9944984c7a523abee305f8f8a050e705f04 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11385 Tested-by: BuildkiteCI Reviewed-by: raitobezarius Reviewed-by: Brian Olsen Autosubmit: flokli --- tvix/nix-compat/src/wire/bytes_writer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tvix/nix-compat/src/wire/bytes_writer.rs') diff --git a/tvix/nix-compat/src/wire/bytes_writer.rs b/tvix/nix-compat/src/wire/bytes_writer.rs index 933b0e6efa6c..8bd0a2d00ef6 100644 --- a/tvix/nix-compat/src/wire/bytes_writer.rs +++ b/tvix/nix-compat/src/wire/bytes_writer.rs @@ -6,7 +6,7 @@ use tokio::io::AsyncWrite; use super::bytes::EMPTY_BYTES; /// The length of the size field, in bytes is always 8. -const LEN_SIZE: usize = 8; +pub(crate) const LEN_SIZE: usize = 8; pin_project! { /// Writes a "bytes wire packet" to the underlying writer. @@ -52,6 +52,8 @@ pin_project! { /// move to the beginning of the next one: /// - Size(LEN_SIZE) must be expressed as Payload(0) /// - Payload(self.payload_len) must be expressed as Padding(0) +/// There's one exception - Size(LEN_SIZE) in the reader represents a failure +/// state we enter in case the allowed size doesn't match the allowed range. /// /// Padding(padding_len) means we're at the end of the bytes wire packet. #[derive(Clone, Debug, PartialEq, Eq)] -- cgit 1.4.1