pub struct ArchiveEncoding {
pub archive: ArchiveFormat,
pub compression: CompressionFormat,
}Expand description
Archive container plus outer compression wrapper.
Fields§
§archive: ArchiveFormatArchive container format.
compression: CompressionFormatOuter compression format, if any.
Implementations§
Source§impl ArchiveEncoding
impl ArchiveEncoding
Sourcepub const fn new(
archive: ArchiveFormat,
compression: CompressionFormat,
) -> ArchiveEncoding
pub const fn new( archive: ArchiveFormat, compression: CompressionFormat, ) -> ArchiveEncoding
Creates an archive encoding from explicit parts.
Sourcepub const fn unknown() -> ArchiveEncoding
pub const fn unknown() -> ArchiveEncoding
Returns an unknown archive encoding.
Sourcepub fn from_extension(input: &str) -> ArchiveEncoding
pub fn from_extension(input: &str) -> ArchiveEncoding
Detects an archive encoding from a filename or extension.
Examples found in repository?
examples/basic_usage.rs (line 7)
6fn main() {
7 let encoding = ArchiveEncoding::from_extension("release.tar.zst");
8
9 assert_eq!(encoding.archive, ArchiveFormat::Tar);
10 assert_eq!(encoding.compression, CompressionFormat::Zstd);
11 assert!(is_safe_relative_archive_path("docs/readme.md"));
12 assert!(!is_safe_relative_archive_path("../secrets.env"));
13
14 let policy = ArchivePolicy::strict();
15 let manifest = ArchiveManifest::new(encoding).with_entries(vec![
16 ArchiveEntry::new("docs/readme.md", ArchiveEntryKind::File).with_size(128),
17 ]);
18
19 assert!(policy.allows_entries(manifest.entries()));
20 assert_eq!(manifest.file_count(), 1);
21 assert_eq!(manifest.total_size(), 128);
22}Sourcepub fn from_filename(input: &str) -> ArchiveEncoding
pub fn from_filename(input: &str) -> ArchiveEncoding
Detects an archive encoding from a filename.
Sourcepub const fn has_archive(self) -> bool
pub const fn has_archive(self) -> bool
Returns whether the archive container is known.
Sourcepub const fn is_compressed(self) -> bool
pub const fn is_compressed(self) -> bool
Returns whether an outer compression wrapper is known.
Trait Implementations§
Source§impl Clone for ArchiveEncoding
impl Clone for ArchiveEncoding
Source§fn clone(&self) -> ArchiveEncoding
fn clone(&self) -> ArchiveEncoding
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ArchiveEncoding
impl Debug for ArchiveEncoding
Source§impl Default for ArchiveEncoding
impl Default for ArchiveEncoding
Source§fn default() -> ArchiveEncoding
fn default() -> ArchiveEncoding
Returns the “default value” for a type. Read more
Source§impl Display for ArchiveEncoding
impl Display for ArchiveEncoding
Source§impl Hash for ArchiveEncoding
impl Hash for ArchiveEncoding
Source§impl Ord for ArchiveEncoding
impl Ord for ArchiveEncoding
Source§fn cmp(&self, other: &ArchiveEncoding) -> Ordering
fn cmp(&self, other: &ArchiveEncoding) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ArchiveEncoding
impl PartialEq for ArchiveEncoding
Source§fn eq(&self, other: &ArchiveEncoding) -> bool
fn eq(&self, other: &ArchiveEncoding) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ArchiveEncoding
impl PartialOrd for ArchiveEncoding
impl Copy for ArchiveEncoding
impl Eq for ArchiveEncoding
impl StructuralPartialEq for ArchiveEncoding
Auto Trait Implementations§
impl Freeze for ArchiveEncoding
impl RefUnwindSafe for ArchiveEncoding
impl Send for ArchiveEncoding
impl Sync for ArchiveEncoding
impl Unpin for ArchiveEncoding
impl UnsafeUnpin for ArchiveEncoding
impl UnwindSafe for ArchiveEncoding
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