pub struct FsEntry<'a> {
pub fs_type: FsEntryType,
pub text: Cow<'a, str>,
pub offset_start: u64,
pub offset_end: u64,
}
Expand description
Directory or file entry, parsed without any allocation
Fields§
§fs_type: FsEntryType
If the FsEntryType == Dir
, then offset_start..offset_end
points
to the start / end bytes of the next directory level, relative to the
file header
If the FsEntryType = File
, then offset_start..offset_end
points
to the actual file contents in the volume.data
field
Inside of a directory level, all files are grouped by the name of the parent directory, at parsing time only the top-level directories are parsed
text: Cow<'a, str>
Directory / file name, for example usr
, lib
or var
in "/usr/lib/var"
offset_start: u64
§offset_end: u64
Implementations§
source§impl<'a> FsEntry<'a>
impl<'a> FsEntry<'a>
pub fn calculate_byte_length(entries: &[Self]) -> usize
sourcepub fn into_bytes(entries: &[Self]) -> Option<Vec<u8>>
pub fn into_bytes(entries: &[Self]) -> Option<Vec<u8>>
Serializes a list of FsEntry
into bytes (usually
done to encode one directory level)
Binary format
[8 bytes]: size of the directory level itself
[
[1 byte]: file entry type (0 = Directory, 1 = File, .. ?)
[7 bytes]: text length N (only 7 bytes long instead of 8, maximum file
name length = 268435456 instead of 4294967296 bytes)
[8 bytes]: offset_start
[8 bytes]: offset_end
[n bytes]: text (directory / file name)
]
sourcepub fn parse(data: &'a [u8]) -> Vec<Self>
pub fn parse(data: &'a [u8]) -> Vec<Self>
Reverse function of Self::into_bytes
, parses one directory level
from a set of bytes. One additional feature is that not more than n
bytes are parsed if n
is the size of the serialized directory level,
even if the input buffer is larger than n
.
If the directory level could not be parsed, the parsing is interrupted and the given file entries are returns as-is (no check for completeness)
Trait Implementations§
source§impl<'a> PartialEq<FsEntry<'a>> for FsEntry<'a>
impl<'a> PartialEq<FsEntry<'a>> for FsEntry<'a>
impl<'a> Eq for FsEntry<'a>
impl<'a> StructuralEq for FsEntry<'a>
impl<'a> StructuralPartialEq for FsEntry<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for FsEntry<'a>
impl<'a> Send for FsEntry<'a>
impl<'a> Sync for FsEntry<'a>
impl<'a> Unpin for FsEntry<'a>
impl<'a> UnwindSafe for FsEntry<'a>
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.