Make EncryptedDiskReader generic over R

This commit is contained in:
Edward Shen 2021-07-14 13:32:00 -04:00
parent 973ece3604
commit 7ce974b4f9
Signed by: edward
GPG key ID: 19182661E818369F

10
src/cache/fs.rs vendored
View file

@ -138,13 +138,13 @@ async fn read_file(
} }
} }
struct EncryptedDiskReader { struct EncryptedDiskReader<R> {
file: Pin<Box<File>>, file: Pin<Box<R>>,
keystream: XChaCha20, keystream: XChaCha20,
} }
impl EncryptedDiskReader { impl<R> EncryptedDiskReader<R> {
fn new(file: File, nonce: &XNonce, key: &Key) -> Self { fn new(file: R, nonce: &XNonce, key: &Key) -> Self {
Self { Self {
file: Box::pin(file), file: Box::pin(file),
keystream: XChaCha20::new(key, nonce), keystream: XChaCha20::new(key, nonce),
@ -165,7 +165,7 @@ impl<R: AsyncBufRead + Send> MetadataFetch for R {
} }
} }
impl AsyncRead for EncryptedDiskReader { impl<R: AsyncRead> AsyncRead for EncryptedDiskReader<R> {
fn poll_read( fn poll_read(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
cx: &mut Context<'_>, cx: &mut Context<'_>,