pub struct Archiver { /* private fields */ }
Expand description
Archiver struct.
You can use this struct and its methods to compress directories or files.
For the detail example, see also archive
function.
Implementations§
Source§impl Archiver
impl Archiver
Sourcepub fn set_destination<T: AsRef<Path>>(&mut self, dest: T)
pub fn set_destination<T: AsRef<Path>>(&mut self, dest: T)
Set the destination of compressed files.
If the destination directory does not exist,
it will create a new directory when the archive
function is called.
Sourcepub fn set_thread_count(&mut self, thread_count: u32)
pub fn set_thread_count(&mut self, thread_count: u32)
Set for the number of threads.
Sourcepub fn set_sender(&mut self, sender: Sender<String>)
pub fn set_sender(&mut self, sender: Sender<String>)
Set the std::sync::mpsc::Sender
to send messages whether compressing processes complete.
Sourcepub fn set_format(&mut self, comp_format: Format)
pub fn set_format(&mut self, comp_format: Format)
Sourcepub fn set_format_str<T: ToString>(&mut self, comp_format_str: T)
pub fn set_format_str<T: ToString>(&mut self, comp_format_str: T)
Set the format of the file to be compressed with a string.
use zip_archive::Archiver;
let mut archiver = Archiver::new();
archiver.set_format_str("7z");
Sourcepub fn push_from_iter<I>(&mut self, iter: I)
pub fn push_from_iter<I>(&mut self, iter: I)
Push all elements in givin iterator to the queue. It iterate through all elements and push it to the queue.
§Examples
use zip_archive::Archiver;
let mut archiver = Archiver::new();
archiver.push_from_iter(vec!["origin/dir1", "origin/dir2", "origin/dir3"].into_iter());
Sourcepub fn push<T: AsRef<Path>>(&mut self, path: T)
pub fn push<T: AsRef<Path>>(&mut self, path: T)
Push a single directory to the queue.
§Examples
use zip_archive::Archiver;
let mut archiver = Archiver::new();
archiver.push("origin/dir1");
archiver.push("origin/dir2");
archiver.push("origin/dir3");
Sourcepub fn archive(&self) -> Result<(), Box<dyn Error>>
pub fn archive(&self) -> Result<(), Box<dyn Error>>
Compress directories in the queue with multithread.
§Examples
use std::path::PathBuf;
use zip_archive::Archiver;
let origin = PathBuf::from("./origin");
let dest = PathBuf::from("./dest");
let thread_count = 4;
let mut archiver = Archiver::new();
archiver.push(origin);
archiver.set_destination(dest);
archiver.set_thread_count(thread_count);
match archiver.archive(){
Ok(_) => (),
Err(e) => println!("Cannot archive the directory! {}", e),
};
Auto Trait Implementations§
impl !Freeze for Archiver
impl RefUnwindSafe for Archiver
impl Send for Archiver
impl Sync for Archiver
impl Unpin for Archiver
impl UnwindSafe for Archiver
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