pub enum AccessMode {
RandomAccess,
Sequential,
}Expand description
How the files of a source can be reached — the read-side counterpart of
MutationCapability. Returned by Filesystem::access_mode.
This is the forward-scan flag: it tells a caller whether addressing an
individual file is cheap (an index / positional structure exists) or
requires walking the archive from the start. A single forward pass — a
repack, or one walk_* — is always cheap; the distinction matters for
random per-file access (list of a deep path, read_file of one entry),
which on a Sequential source costs a fresh O(n) scan.
Variants§
RandomAccess
The format carries an index or positional structure (inode table,
extent maps, a central directory, a seekable device): any file is
reachable in roughly constant time via read_at. All real
filesystems, indexed archives (zip), and disk-image containers.
Sequential
No index — the format is an ordered stream of entries, so reaching a given file means scanning forward from the start (O(n) per lookup). Sequential archives (tar, cpio, ar) and whole-file-compressed streams. Cheap to walk once; expensive to address repeatedly.
Implementations§
Source§impl AccessMode
impl AccessMode
Sourcepub fn requires_forward_scan(self) -> bool
pub fn requires_forward_scan(self) -> bool
Whether reaching an individual file requires an (expensive) forward
scan — true for Sequential. Callers use this
to gate or warn before doing random per-file access on such a source.
Trait Implementations§
Source§impl Clone for AccessMode
impl Clone for AccessMode
Source§fn clone(&self) -> AccessMode
fn clone(&self) -> AccessMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more