pub struct ArchiveEntry {
pub path: String,
pub kind: ArchiveEntryKind,
pub size: Option<u64>,
pub mode: Option<u32>,
pub modified_unix_seconds: Option<i64>,
}Expand description
Generic archive entry metadata.
Fields§
§path: StringArchive-internal path.
kind: ArchiveEntryKindArchive entry kind.
size: Option<u64>Entry payload size in bytes, when known.
mode: Option<u32>Entry mode or permission bits, when known.
modified_unix_seconds: Option<i64>Unix timestamp seconds for the modified time, when known.
Implementations§
Source§impl ArchiveEntry
impl ArchiveEntry
Sourcepub fn new(path: impl Into<String>, kind: ArchiveEntryKind) -> ArchiveEntry
pub fn new(path: impl Into<String>, kind: ArchiveEntryKind) -> ArchiveEntry
Creates archive entry metadata from a path and kind.
Examples found in repository?
examples/basic_usage.rs (line 16)
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 file(path: impl Into<String>) -> ArchiveEntry
pub fn file(path: impl Into<String>) -> ArchiveEntry
Creates a regular file entry.
Sourcepub fn directory(path: impl Into<String>) -> ArchiveEntry
pub fn directory(path: impl Into<String>) -> ArchiveEntry
Creates a directory entry.
Sourcepub fn symlink(path: impl Into<String>) -> ArchiveEntry
pub fn symlink(path: impl Into<String>) -> ArchiveEntry
Creates a symbolic link entry.
Sourcepub const fn with_size(self, size: u64) -> ArchiveEntry
pub const fn with_size(self, size: u64) -> ArchiveEntry
Adds known entry size metadata.
Examples found in repository?
examples/basic_usage.rs (line 16)
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 const fn with_mode(self, mode: u32) -> ArchiveEntry
pub const fn with_mode(self, mode: u32) -> ArchiveEntry
Adds known entry mode metadata.
Sourcepub const fn with_modified_unix_seconds(self, seconds: i64) -> ArchiveEntry
pub const fn with_modified_unix_seconds(self, seconds: i64) -> ArchiveEntry
Adds known modified timestamp metadata.
Sourcepub const fn kind(&self) -> ArchiveEntryKind
pub const fn kind(&self) -> ArchiveEntryKind
Returns the archive entry kind.
Sourcepub const fn modified_unix_seconds(&self) -> Option<i64>
pub const fn modified_unix_seconds(&self) -> Option<i64>
Returns the known modified timestamp.
Sourcepub const fn is_directory(&self) -> bool
pub const fn is_directory(&self) -> bool
Returns whether this is a directory entry.
Sourcepub const fn is_symlink(&self) -> bool
pub const fn is_symlink(&self) -> bool
Returns whether this is a symbolic link entry.
Trait Implementations§
Source§impl Clone for ArchiveEntry
impl Clone for ArchiveEntry
Source§fn clone(&self) -> ArchiveEntry
fn clone(&self) -> ArchiveEntry
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 ArchiveEntry
impl Debug for ArchiveEntry
Source§impl Hash for ArchiveEntry
impl Hash for ArchiveEntry
Source§impl PartialEq for ArchiveEntry
impl PartialEq for ArchiveEntry
Source§fn eq(&self, other: &ArchiveEntry) -> bool
fn eq(&self, other: &ArchiveEntry) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for ArchiveEntry
impl StructuralPartialEq for ArchiveEntry
Auto Trait Implementations§
impl Freeze for ArchiveEntry
impl RefUnwindSafe for ArchiveEntry
impl Send for ArchiveEntry
impl Sync for ArchiveEntry
impl Unpin for ArchiveEntry
impl UnsafeUnpin for ArchiveEntry
impl UnwindSafe for ArchiveEntry
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