MainHeader

Struct MainHeader 

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

The main header is the first Header, which can be found at the beginning of the first segment.
This header contains a lot of metadata about the zff container

  • the target chunk size: the size of the chunks in which the original data was read.
  • the target segment size
  • a unique identifier, written to each segment header: With this identifier you can uniquely assign the corresponding segments that belong together: there may be cases where you don’t want to or can’t do this via the file names.

Implementations§

Source§

impl MainHeader

Source

pub fn new( version: u8, chunk_size: u8, segment_size: u64, unique_identifier: i64, ) -> MainHeader

returns a new main header with the given values.

Source

pub fn chunk_size(&self) -> usize

returns the chunk_size.

Source

pub fn segment_size(&self) -> u64

returns the segment size

Source

pub fn get_encoded_size(&self) -> usize

returns the len() of the Vec<u8> (encoded main header).

Source

pub fn unique_identifier(&self) -> i64

returns the unique identifier

Trait Implementations§

Source§

impl Clone for MainHeader

Source§

fn clone(&self) -> MainHeader

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 MainHeader

Source§

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

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

impl HeaderCoding for MainHeader

Source§

type Item = MainHeader

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<MainHeader>

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.

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