about summary refs log tree commit diff
path: root/tvix/nix-compat/src/nar
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2024-04-29T17·34+0000
committeredef <edef@edef.eu>2024-05-08T06·03+0000
commit51e0f78e9317c1234bc982dcaa280c0d3674d164 (patch)
tree057023b4f0aa6545a757f69da0978d5028618590 /tvix/nix-compat/src/nar
parentebad318ab3accf34dff84a49d18b96a7efd15c22 (diff)
feat(nix-compat/wire/bytes/reader): support buffered reading r/8086
If our underlying reader supports AsyncBufRead, then we can too.

Change-Id: If4b948c983400ca591c1c475bbcf7dc00d562040
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11545
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nix-compat/src/nar')
-rw-r--r--tvix/nix-compat/src/nar/reader/async/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/nix-compat/src/nar/reader/async/mod.rs b/tvix/nix-compat/src/nar/reader/async/mod.rs
index aaf00faf4441..048283a67cb5 100644
--- a/tvix/nix-compat/src/nar/reader/async/mod.rs
+++ b/tvix/nix-compat/src/nar/reader/async/mod.rs
@@ -94,6 +94,16 @@ impl<'a, 'r> AsyncRead for FileReader<'a, 'r> {
     }
 }
 
+impl<'a, 'r> AsyncBufRead for FileReader<'a, 'r> {
+    fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll<io::Result<&[u8]>> {
+        Pin::new(&mut self.get_mut().inner).poll_fill_buf(cx)
+    }
+
+    fn consume(self: Pin<&mut Self>, amt: usize) {
+        Pin::new(&mut self.get_mut().inner).consume(amt)
+    }
+}
+
 /// A directory iterator, yielding a sequence of [Node]s.
 /// It must be fully consumed before reading further from the [DirReader] that produced it, if any.
 pub struct DirReader<'a, 'r> {