Struct sevenz_rust::SevenZWriter

source ·
pub struct SevenZWriter<W: Write> { /* private fields */ }
Expand description

Writes a 7z file

Implementations§

source§

impl<W: Write + Seek> SevenZWriter<W>

source

pub fn push_source_path( &mut self, path: impl AsRef<Path>, filter: impl Fn(&Path) -> bool, ) -> Result<&mut Self, Error>

Solid compression compress all files in [path]. With multiple files in one block.

source

pub fn push_source_path_non_solid( &mut self, path: impl AsRef<Path>, filter: impl Fn(&Path) -> bool, ) -> Result<&mut Self, Error>

[Non-solid compression] compress all files in [path]. With one file per block.

source§

impl SevenZWriter<File>

source

pub fn create(path: impl AsRef<Path>) -> Result<Self, Error>

Creates a file to write a 7z archive to

source§

impl<W: Write + Seek> SevenZWriter<W>

source

pub fn new(writer: W) -> Result<Self, Error>

Prepares writer to write a 7z archive to

source

pub fn set_content_methods( &mut self, content_methods: Vec<SevenZMethodConfiguration>, ) -> &mut Self

Sets the default compression methods to use for entry contents. The default is LZMA2. And currently only support LZMA2

source

pub fn set_encrypt_header(&mut self, enabled: bool)

Whether to enable encrypt-header Default’s true

source

pub fn create_archive_entry( path: impl AsRef<Path>, entry_name: String, ) -> SevenZArchiveEntry

👎Deprecated

Create an archive entry using the file in path and entry_name provided. #deprecated use SevenZArchiveEntry::from_path instead

source

pub fn push_archive_entry<R: Read>( &mut self, entry: SevenZArchiveEntry, reader: Option<R>, ) -> Result<&SevenZArchiveEntry, Error>

Adds an archive entry with data from reader

§Examples
use sevenz_rust::*;
use std::fs::File;
use std::path::Path;
let mut sz = SevenZWriter::create("path/to/dest.7z").expect("create writer ok");
let src = Path::new("path/to/source.txt");
let name = "source.txt".to_string();
let entry = sz.push_archive_entry(
              SevenZArchiveEntry::from_path(&src, name),
              Some(File::open(src).unwrap()),
          )
          .expect("ok");
let compressed_size = entry.compressed_size;
sz.finish().expect("done");
source

pub fn push_archive_entries<R: Read>( &mut self, entries: Vec<SevenZArchiveEntry>, reader: SeqReader<SourceReader<R>>, ) -> Result<&mut Self, Error>

Solid compression pack [entries] into one pack

§Panics

Panics if entries’s length not equals to reader.reader_len()

source

pub fn finish(self) -> Result<W>

Finishes the compression.

Auto Trait Implementations§

§

impl<W> Freeze for SevenZWriter<W>
where W: Freeze,

§

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

§

impl<W> Send for SevenZWriter<W>
where W: Send,

§

impl<W> Sync for SevenZWriter<W>
where W: Sync,

§

impl<W> Unpin for SevenZWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for SevenZWriter<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>,

§

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>,

§

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.