fix(nix-compat/nar/reader): require BufRead
We rely on being able to make small reads cheaply, so this was already an implicit practical requirement. Requiring it explicitly removes a performance footgun, and makes further optimisations possible. Change-Id: I7f65880a41b1d6b5e6bf2e52dfe47d4c49b34bcd Reviewed-on: https://cl.tvl.fyi/c/depot/+/10088 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
2eaee1d48e
commit
785ff80c8b
2 changed files with 4 additions and 4 deletions
|
@ -5,7 +5,7 @@
|
||||||
//! and transferring store paths between Nix stores.
|
//! and transferring store paths between Nix stores.
|
||||||
|
|
||||||
use std::io::{
|
use std::io::{
|
||||||
self,
|
self, BufRead,
|
||||||
ErrorKind::{InvalidData, UnexpectedEof},
|
ErrorKind::{InvalidData, UnexpectedEof},
|
||||||
Read,
|
Read,
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ mod read;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|
||||||
pub type Reader<'a> = dyn Read + Send + 'a;
|
pub type Reader<'a> = dyn BufRead + Send + 'a;
|
||||||
|
|
||||||
/// Start reading a NAR file from `reader`.
|
/// Start reading a NAR file from `reader`.
|
||||||
pub fn open<'a, 'r>(reader: &'a mut Reader<'r>) -> io::Result<Node<'a, 'r>> {
|
pub fn open<'a, 'r>(reader: &'a mut Reader<'r>) -> io::Result<Node<'a, 'r>> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
io::{self, Read},
|
io::{self, BufRead},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ use tvix_castore::{
|
||||||
/// This function is not async (because the NAR reader is not)
|
/// This function is not async (because the NAR reader is not)
|
||||||
/// and calls [tokio::task::block_in_place] when interacting with backing
|
/// and calls [tokio::task::block_in_place] when interacting with backing
|
||||||
/// services, so make sure to only call this with spawn_blocking.
|
/// services, so make sure to only call this with spawn_blocking.
|
||||||
pub fn read_nar<R: Read + Send>(
|
pub fn read_nar<R: BufRead + Send>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
blob_service: Arc<dyn BlobService>,
|
blob_service: Arc<dyn BlobService>,
|
||||||
directory_service: Arc<dyn DirectoryService>,
|
directory_service: Arc<dyn DirectoryService>,
|
||||||
|
|
Loading…
Reference in a new issue