FileHeader

Struct FileHeader 

Source
pub struct FileHeader { /* private fields */ }
Expand description

Each dumped file* contains a FileHeader containing several metadata. The following metadata are included in a FileHeader:

  • the internal file number of the appropriate file.
  • the FileType of the appropriate file.
  • the original filename of the appropriate file without the full path (just the filename, e.g. “my_texfile.txt” or “my_directory”)
  • the file number of the parent directory of this file (if the file lies into the root directory, this is 0 because the first valid file number in zff is 1).
  • the atime, mtime, ctime and btime.
  • A HashMap to extend the metadata based on the operating system/filesystem. Some fields are predefined, see the full list in the wiki

Implementations§

Source§

impl FileHeader

Source

pub fn new<F: Into<String>>( version: u8, file_number: u64, file_type: FileType, filename: F, parent_file_number: u64, atime: u64, mtime: u64, ctime: u64, btime: u64, metadata_ext: HashMap<String, String>, ) -> FileHeader

creates a new FileHeader with the given values.

Source

pub fn file_number(&self) -> u64

returns the file number

Source

pub fn file_type(&self) -> FileType

returns the FileType

Source

pub fn filename(&self) -> &str

returns the filename

Source

pub fn parent_file_number(&self) -> u64

returns the file number of the parent directory

Source

pub fn atime(&self) -> u64

returns the atime

Source

pub fn mtime(&self) -> u64

returns the mtime

Source

pub fn ctime(&self) -> u64

returns the ctime

Source

pub fn btime(&self) -> u64

returns the btime

Source

pub fn metadata_ext(&self) -> &HashMap<String, String>

returns the extended metadata HashMap as a reference.

transforms the inner FileType to a FileType::Hardlink. This does not work with a FileType::Symlink!

Source

pub fn encode_encrypted_header_directly<K>( &self, key: K, encryption_header: EncryptionHeader, ) -> Result<Vec<u8>>
where K: AsRef<[u8]>,

encodes the file header to a Vec<u8>. The encryption flag of the appropriate object header has to be set to 2.

§Error

The method returns an error, if the encryption fails.

Source

pub fn decode_encrypted_header_with_key<R, K>( data: &mut R, key: K, encryption_header: EncryptionHeader, ) -> Result<FileHeader>
where R: Read, K: AsRef<[u8]>,

decodes the encrypted header with the given key and crate::header::EncryptionHeader. The appropriate crate::header::EncryptionHeader has to be stored in the appropriate crate::header::ObjectHeader.

Trait Implementations§

Source§

impl Clone for FileHeader

Source§

fn clone(&self) -> FileHeader

Returns a duplicate 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 Debug for FileHeader

Source§

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

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

impl HeaderCoding for FileHeader

Source§

type Item = FileHeader

the return value for decode_content(), decode_directly(), decode_for_key();
Source§

fn identifier() -> u32

returns the identifier (=Magic bytes) of the header.
Source§

fn version(&self) -> u8

returns the version of the header.
Source§

fn encode_header(&self) -> Vec<u8>

encodes the header.
Source§

fn decode_content(data: Vec<u8>) -> Result<FileHeader>

decodes the content of the header.
Source§

fn header_size(&self) -> usize

returns the size of the encoded header (in bytes)
Source§

fn encode_key<K: Into<String>>(key: K) -> Vec<u8>

encodes a given key.
Source§

fn encode_directly(&self) -> Vec<u8>

encodes the (header) value/object directly (= without key).
Source§

fn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8>

encodes a key to the (header) value/object.
Source§

fn decode_header_length<R: Read>(data: &mut R) -> Result<u64>

decodes the length of the header.
Source§

fn check_identifier<R: Read>(data: &mut R) -> bool

checks if the read identifier is valid for this header.
Source§

fn check_key_on_position<K: Into<String>, R: Read>(data: &mut R, key: K) -> bool

helper method to check, if the key is on position.
Source§

fn decode_directly<R: Read>(data: &mut R) -> Result<Self::Item>

decodes the header directly.
Source§

fn decode_for_key<K: Into<String>, R: Read>( data: &mut R, key: K, ) -> Result<Self::Item>

decodes the header for the given key.
Source§

impl PartialEq for FileHeader

Source§

fn eq(&self, other: &FileHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for FileHeader

Source§

impl StructuralPartialEq for FileHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V