pub struct Writer<W> { /* private fields */ }Expand description
A 7z archive writer.
Implementations§
Source§impl<W: Write + Seek> Writer<W>
impl<W: Write + Seek> Writer<W>
Sourcepub fn add_path(
&mut self,
disk_path: impl AsRef<Path>,
archive_path: ArchivePath,
) -> Result<()>
pub fn add_path( &mut self, disk_path: impl AsRef<Path>, archive_path: ArchivePath, ) -> Result<()>
Sourcepub fn add_directory(
&mut self,
archive_path: ArchivePath,
meta: EntryMeta,
) -> Result<()>
pub fn add_directory( &mut self, archive_path: ArchivePath, meta: EntryMeta, ) -> Result<()>
Sourcepub fn add_anti_item(&mut self, archive_path: ArchivePath) -> Result<()>
pub fn add_anti_item(&mut self, archive_path: ArchivePath) -> Result<()>
Adds an anti-item entry (file marked for deletion in incremental backups).
Anti-items are empty entries that indicate a file or directory should be deleted when the incremental archive is applied. This is useful for incremental backup systems.
§Arguments
archive_path- Path within the archive to mark for deletion
§Example
let mut writer = Writer::create_file("incremental.7z")?;
writer.add_anti_item(ArchivePath::new("deleted_file.txt")?)?;
writer.finish()?;Sourcepub fn add_anti_directory(&mut self, archive_path: ArchivePath) -> Result<()>
pub fn add_anti_directory(&mut self, archive_path: ArchivePath) -> Result<()>
Adds an anti-item directory (directory marked for deletion).
§Arguments
archive_path- Directory path within the archive to mark for deletion
Sourcepub fn add_stream(
&mut self,
archive_path: ArchivePath,
source: &mut dyn Read,
meta: EntryMeta,
) -> Result<()>
pub fn add_stream( &mut self, archive_path: ArchivePath, source: &mut dyn Read, meta: EntryMeta, ) -> Result<()>
Source§impl Writer<Cursor<Vec<u8>>>
impl Writer<Cursor<Vec<u8>>>
Sourcepub fn finish(self) -> Result<WriteResult>
pub fn finish(self) -> Result<WriteResult>
Finishes writing the archive to an owned cursor.
Source§impl Writer<Cursor<&mut Vec<u8>>>
impl Writer<Cursor<&mut Vec<u8>>>
Sourcepub fn finish(self) -> Result<WriteResult>
pub fn finish(self) -> Result<WriteResult>
Finishes writing the archive to a borrowed cursor.
Source§impl Writer<MultiVolumeWriter>
impl Writer<MultiVolumeWriter>
Sourcepub fn create_multivolume(config: VolumeConfig) -> Result<Self>
pub fn create_multivolume(config: VolumeConfig) -> Result<Self>
Creates a new multi-volume archive writer.
The archive will be split across multiple files when each volume reaches the configured size limit.
§Arguments
config- Volume configuration specifying size and base path
§Errors
Returns an error if the first volume file cannot be created.
§Example
use zesven::{Writer, VolumeConfig, ArchivePath};
let config = VolumeConfig::new("archive.7z", 50 * 1024 * 1024); // 50 MB volumes
let mut writer = Writer::create_multivolume(config)?;
writer.add_bytes(ArchivePath::new("data.bin")?, &large_data)?;
let result = writer.finish()?;
println!("Created {} volumes", result.volume_count);Sourcepub fn finish(self) -> Result<WriteResult>
pub fn finish(self) -> Result<WriteResult>
Source§impl<W: Write + Seek> Writer<W>
impl<W: Write + Seek> Writer<W>
Sourcepub fn options(self, options: WriteOptions) -> Self
pub fn options(self, options: WriteOptions) -> Self
Sets the write options.
Sourcepub fn finish_into_inner(self) -> Result<(WriteResult, W)>
pub fn finish_into_inner(self) -> Result<(WriteResult, W)>
Finishes writing the archive and returns the underlying sink.
This is useful when you need access to the written data, such as
when writing to a Cursor<Vec<u8>> and need to retrieve the buffer.
§Returns
A tuple of (WriteResult, W) where W is the underlying sink.
§Errors
Returns an error if header writing fails.
§Example
use zesven::write::Writer;
use std::io::Cursor;
let mut writer = Writer::create(Cursor::new(Vec::new()))?;
writer.add_bytes("test.txt".try_into()?, b"Hello")?;
let (result, cursor) = writer.finish_into_inner()?;
let archive_bytes = cursor.into_inner();Auto Trait Implementations§
impl<W> Freeze for Writer<W>where
W: Freeze,
impl<W> RefUnwindSafe for Writer<W>where
W: RefUnwindSafe,
impl<W> Send for Writer<W>where
W: Send,
impl<W> Sync for Writer<W>where
W: Sync,
impl<W> Unpin for Writer<W>where
W: Unpin,
impl<W> UnwindSafe for Writer<W>where
W: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more