diff --git a/lib/src/archive/entry.rs b/lib/src/archive/entry.rs index 6a012281..cda298f6 100644 --- a/lib/src/archive/entry.rs +++ b/lib/src/archive/entry.rs @@ -6,7 +6,6 @@ mod options; mod read; mod write; -pub(crate) use self::read::MutexRead; pub use self::{builder::*, header::*, meta::*, name::*, options::*}; use self::{private::*, read::*, write::*}; use crate::{ @@ -39,7 +38,7 @@ pub trait Entry: SealedIntoChunks { /// Readable archive entry. pub trait ReadEntry: Entry { - type Reader: Read + Sync + Send; + type Reader: Read; fn header(&self) -> &EntryHeader; fn metadata(&self) -> &Metadata; fn into_reader(self, option: ReadOption) -> io::Result; @@ -437,9 +436,7 @@ fn decompress_reader<'r, R: Read>( Ok(match compression { Compression::No => DecompressReader::Store(reader), Compression::Deflate => DecompressReader::Deflate(flate2::read::ZlibDecoder::new(reader)), - Compression::ZStandard => { - DecompressReader::ZStd(MutexRead::new(zstd::Decoder::new(reader)?)) - } + Compression::ZStandard => DecompressReader::ZStd(zstd::Decoder::new(reader)?), Compression::XZ => DecompressReader::Xz(xz2::read::XzDecoder::new(reader)), }) } diff --git a/lib/src/archive/entry/read.rs b/lib/src/archive/entry/read.rs index 89095927..c397de11 100644 --- a/lib/src/archive/entry/read.rs +++ b/lib/src/archive/entry/read.rs @@ -4,23 +4,6 @@ use camellia::Camellia256; use crypto_common::BlockSizeUser; use std::io; use std::io::Read; -use std::sync::Mutex; - -// NOTE: zstd crate not support Sync + Send trait -pub(crate) struct MutexRead(Mutex); - -impl MutexRead { - pub(super) fn new(reader: R) -> Self { - Self(Mutex::new(reader)) - } -} - -impl Read for MutexRead { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - let reader = self.0.get_mut().unwrap(); - reader.read(buf) - } -} pub(super) fn aes_ctr_cipher_reader( mut reader: R, diff --git a/lib/src/compress.rs b/lib/src/compress.rs index a61cca24..12324107 100644 --- a/lib/src/compress.rs +++ b/lib/src/compress.rs @@ -1,4 +1,3 @@ -use crate::archive::MutexRead; use crate::io::{TryIntoInner, TryIntoInnerWrite}; use flate2::{read::ZlibDecoder, write::ZlibEncoder}; use std::io::{BufReader, Read, Result, Write}; @@ -52,7 +51,7 @@ impl<'w, W: Write> TryIntoInnerWrite for CompressionWriter<'w, W> {} pub(crate) enum DecompressReader<'r, R: Read> { Store(R), Deflate(ZlibDecoder), - ZStd(MutexRead>>), + ZStd(ZStdDecoder<'r, BufReader>), Xz(XzDecoder), }