pub struct ZipArchiveWriterBuilder { /* private fields */ }Expand description
Builds a ZipArchiveWriter.
Implementations§
Source§impl ZipArchiveWriterBuilder
impl ZipArchiveWriterBuilder
Sourcepub fn with_capacity(self, capacity: usize) -> Self
pub fn with_capacity(self, capacity: usize) -> Self
Sets the anticipated number of files to optimize memory allocation.
Sourcepub fn with_offset(self, offset: u64) -> Self
pub fn with_offset(self, offset: u64) -> Self
Sets the starting offset for writing. Useful when there is prelude data prior to the zip archive.
When there is prelude data, setting the offset may not technically be required, but it is recommended. For standard zip files, many zip readers can self correct when the prelude data isn’t properly declared. However for zip64 archives, setting the correct offset is required.
§Example: Appending ZIP to existing data
use std::io::{Cursor, Write, Seek, SeekFrom};
// Create a file with some prefix data
let mut output = Cursor::new(Vec::new());
output.write_all(b"This is a custom header or prefix data\n").unwrap();
let zip_start_offset = output.position();
// Create ZIP archive starting after the prefix data
let mut archive = rawzip::ZipArchiveWriter::builder()
.with_offset(zip_start_offset) // Tell the archive where it starts
.build(&mut output);
// Add files normally
let mut file = archive.new_file("data.txt").create().unwrap();
let mut writer = rawzip::ZipDataWriter::new(&mut file);
writer.write_all(b"File content").unwrap();
let (_, desc) = writer.finish().unwrap();
file.finish(desc).unwrap();
archive.finish().unwrap();
// The resulting file contains both prefix data and the ZIP archive
let final_data = output.into_inner();
assert!(final_data.starts_with(b"This is a custom header"));Sourcepub fn build<W>(&self, writer: W) -> ZipArchiveWriter<W>
pub fn build<W>(&self, writer: W) -> ZipArchiveWriter<W>
Builds a ZipArchiveWriter that writes to writer.
Trait Implementations§
Source§impl Debug for ZipArchiveWriterBuilder
impl Debug for ZipArchiveWriterBuilder
Source§impl Default for ZipArchiveWriterBuilder
impl Default for ZipArchiveWriterBuilder
Source§fn default() -> ZipArchiveWriterBuilder
fn default() -> ZipArchiveWriterBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ZipArchiveWriterBuilder
impl RefUnwindSafe for ZipArchiveWriterBuilder
impl Send for ZipArchiveWriterBuilder
impl Sync for ZipArchiveWriterBuilder
impl Unpin for ZipArchiveWriterBuilder
impl UnsafeUnpin for ZipArchiveWriterBuilder
impl UnwindSafe for ZipArchiveWriterBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more