Skip to main content

ArchiveWriter

Struct ArchiveWriter 

Source
pub struct ArchiveWriter<W: Write> { /* private fields */ }
Expand description

A writer for creating compressed archives.

ArchiveWriter allows creating archives in any destination that implements Write. It supports various formats (TAR, ZIP, 7ZIP, etc.) and compression filters (GZIP, BZIP2, XZ, etc.).

Implementations§

Source§

impl<W: Write> ArchiveWriter<W>

Source

pub fn new(dest: W) -> Result<ArchiveWriter<W>, Error>
where W: Write,

Creates a new ArchiveWriter that writes to the given destination.

Source

pub fn set_output_format(&mut self, format: c_int) -> Result<(), Error>

Sets the output format for the archive (e.g., TAR, ZIP).

Source

pub fn set_output_filter(&mut self, filter: c_int) -> Result<(), Error>

Sets the output filter (compression) for the archive (e.g., GZIP, BZIP2).

Source

pub fn add_filter_option( &mut self, name: &str, value: &str, ) -> Result<(), Error>

Source

pub fn add_format_option( &mut self, name: &str, value: &str, ) -> Result<(), Error>

Source

pub fn open(&mut self) -> Result<(), Error>

Opens the archive for writing. This must be called after setting the format and filter, but before adding files.

Source

pub fn set_compression_high(&mut self) -> Result<(), Error>

Source

pub fn set_compression_mid(&mut self) -> Result<(), Error>

Source

pub fn set_compression_low(&mut self) -> Result<(), Error>

Source

pub fn set_output_targz(&mut self) -> Result<(), Error>

Source

pub fn set_output_tarxz(&mut self) -> Result<(), Error>

Source

pub fn set_output_tarzst(&mut self) -> Result<(), Error>

Source

pub fn set_output_7zlzma2(&mut self) -> Result<(), Error>

Source

pub fn set_output_zip(&mut self) -> Result<(), Error>

Source

pub fn add_obj_from_reader<S: Read>( &mut self, source: S, archivepath: &str, objmeta: &Metadata, ) -> Result<(), Error>

Source

pub fn add_file( &mut self, localpath: &str, archivepath: &str, ) -> Result<(), Error>

Adds a file from the local filesystem to the archive.

Source

pub fn add_data( &mut self, archivepath: &str, data: &[u8], mtime: i64, mtime_nano: i64, is_dir: bool, ) -> Result<(), Error>

Add an entry directly from an in-memory byte slice.

Trait Implementations§

Source§

impl<W: Write> Drop for ArchiveWriter<W>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<W> !Send for ArchiveWriter<W>

§

impl<W> !Sync for ArchiveWriter<W>

§

impl<W> Freeze for ArchiveWriter<W>

§

impl<W> RefUnwindSafe for ArchiveWriter<W>
where W: RefUnwindSafe,

§

impl<W> Unpin for ArchiveWriter<W>

§

impl<W> UnsafeUnpin for ArchiveWriter<W>

§

impl<W> UnwindSafe for ArchiveWriter<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.