pub struct StreamingZipWriter<W: Write + Seek> { /* private fields */ }Expand description
Streaming ZIP writer that compresses data on-the-fly
Implementations§
Source§impl StreamingZipWriter<File>
impl StreamingZipWriter<File>
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self>
Create a new ZIP writer with default compression level (6) using DEFLATE
Sourcepub fn with_compression<P: AsRef<Path>>(
path: P,
compression_level: u32,
) -> Result<Self>
pub fn with_compression<P: AsRef<Path>>( path: P, compression_level: u32, ) -> Result<Self>
Create a new ZIP writer with custom compression level (0-9) using DEFLATE
Sourcepub fn with_method<P: AsRef<Path>>(
path: P,
method: CompressionMethod,
compression_level: u32,
) -> Result<Self>
pub fn with_method<P: AsRef<Path>>( path: P, method: CompressionMethod, compression_level: u32, ) -> Result<Self>
Create a new ZIP writer with specified compression method and level
§Arguments
path- Path to the output ZIP filemethod- Compression method to use (Deflate, Zstd, or Stored)compression_level- Compression level (0-9 for DEFLATE, 1-21 for Zstd)
Source§impl<W: Write + Seek> StreamingZipWriter<W>
impl<W: Write + Seek> StreamingZipWriter<W>
Sourcepub fn from_writer(writer: W) -> Result<Self>
pub fn from_writer(writer: W) -> Result<Self>
Create a new ZIP writer from an arbitrary writer with default compression level (6) using DEFLATE
Sourcepub fn from_writer_with_compression(
writer: W,
compression_level: u32,
) -> Result<Self>
pub fn from_writer_with_compression( writer: W, compression_level: u32, ) -> Result<Self>
Create a new ZIP writer from an arbitrary writer with custom compression level
Sourcepub fn from_writer_with_method(
writer: W,
method: CompressionMethod,
compression_level: u32,
) -> Result<Self>
pub fn from_writer_with_method( writer: W, method: CompressionMethod, compression_level: u32, ) -> Result<Self>
Create a new ZIP writer from an arbitrary writer with specified compression method and level
§Arguments
writer- Any writer implementing Write + Seekmethod- Compression method to use (Deflate, Zstd, or Stored)compression_level- Compression level (0-9 for DEFLATE, 1-21 for Zstd)
Sourcepub fn start_entry(&mut self, name: &str) -> Result<()>
pub fn start_entry(&mut self, name: &str) -> Result<()>
Start a new entry (file) in the ZIP
Sourcepub fn start_entry_with_hint(
&mut self,
name: &str,
size_hint: Option<u64>,
) -> Result<()>
pub fn start_entry_with_hint( &mut self, name: &str, size_hint: Option<u64>, ) -> Result<()>
Start a new entry with size hint for optimized buffering
Providing an accurate size hint can improve performance by 15-25% for large files. The hint is used to optimize buffer allocation and flush thresholds.
§Arguments
name- The name/path of the entry in the ZIPsize_hint- Optional uncompressed size hint in bytes
§Example
let mut writer = StreamingZipWriter::new("output.zip")?;
// For large files, provide size hint for better performance
writer.start_entry_with_hint("large_file.bin", Some(10_000_000))?;Sourcepub fn write_data(&mut self, data: &[u8]) -> Result<()>
pub fn write_data(&mut self, data: &[u8]) -> Result<()>
Write uncompressed data to current entry (will be compressed and/or encrypted on-the-fly)