Struct webc::v1::FsEntry

source ·
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>

source

pub fn get_len(&self) -> u64

Returns the length of the file in bytes (0 for directories)

source

pub fn calculate_byte_length(entries: &[Self]) -> usize

source

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)
]
source

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> Clone for FsEntry<'a>

source§

fn clone(&self) -> FsEntry<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for FsEntry<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> PartialEq<FsEntry<'a>> for FsEntry<'a>

source§

fn eq(&self, other: &FsEntry<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Eq for FsEntry<'a>

source§

impl<'a> StructuralEq for FsEntry<'a>

source§

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<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.