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 {
file: Pin<Box<File>>,
struct EncryptedDiskReader<R> {
file: Pin<Box<R>>,
keystream: XChaCha20,
}
impl EncryptedDiskReader {
fn new(file: File, nonce: &XNonce, key: &Key) -> Self {
impl<R> EncryptedDiskReader<R> {
fn new(file: R, nonce: &XNonce, key: &Key) -> Self {
Self {
file: Box::pin(file),
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(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,