pub enum Fmt {
Tar,
TarGz,
TarXz,
TarBz,
TarZstd,
Zip,
SevenZip,
}Expand description
Archive format enumeration
Represents the supported archive formats. Each variant is conditionally compiled based on the corresponding feature flag.
Variants§
Tar
Plain tar archive format
TarGz
Gzip-compressed tar archive (.tar.gz, .tgz)
TarXz
XZ-compressed tar archive (.tar.xz, .txz)
TarBz
Bzip2-compressed tar archive (.tar.bz2, .tbz2)
TarZstd
Zstd-compressed tar archive (.tar.zst, .tzst, .tzstd)
Zip
ZIP archive format
SevenZip
7z archive format
Implementations§
Source§impl Fmt
impl Fmt
Sourcepub fn encode(&self, files: Vec<File>) -> Result<Vec<u8>>
pub fn encode(&self, files: Vec<File>) -> Result<Vec<u8>>
Encode files into an archive
§Arguments
files- List of files to include in the archive
§Returns
Ok(Vec<u8>)- The encoded archive as bytesErr(ArchiveError)- If encoding fails or duplicate files are detected
§Example
use easy_archive::{Fmt, File};
let files = vec![
File {
path: "hello.txt".to_string(),
buffer: b"Hello, world!".to_vec(),
..Default::default()
}
];
let archive = Fmt::TarGz.encode(files)?;
std::fs::write("archive.tar.gz", archive)?;Sourcepub fn guess(name: &str) -> Option<Self>
pub fn guess(name: &str) -> Option<Self>
Guess the archive format from a filename
§Arguments
name- The filename to analyze
§Returns
Some(Fmt)- The detected formatNone- If the format cannot be determined
§Example
use easy_archive::Fmt;
assert_eq!(Fmt::guess("archive.tar.gz"), Some(Fmt::TarGz));
assert_eq!(Fmt::guess("file.zip"), Some(Fmt::Zip));
assert_eq!(Fmt::guess("unknown.txt"), None);Sourcepub fn extensions(&self) -> &[&'static str]
pub fn extensions(&self) -> &[&'static str]
Trait Implementations§
impl Copy for Fmt
impl Eq for Fmt
impl StructuralPartialEq for Fmt
Auto Trait Implementations§
impl Freeze for Fmt
impl RefUnwindSafe for Fmt
impl Send for Fmt
impl Sync for Fmt
impl Unpin for Fmt
impl UnsafeUnpin for Fmt
impl UnwindSafe for Fmt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.