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 other headers (e.g. compression header, description header, …) and start information.
Implementations
sourceimpl MainHeader
impl MainHeader
sourcepub fn new(
version: u8,
encryption_header: Option<EncryptionHeader>,
compression_header: CompressionHeader,
description_header: DescriptionHeader,
hash_header: HashHeader,
chunk_size: u8,
signature_flag: u8,
segment_size: u64,
number_of_segments: u64,
unique_identifier: i64,
length_of_data: u64
) -> MainHeader
pub fn new(
version: u8,
encryption_header: Option<EncryptionHeader>,
compression_header: CompressionHeader,
description_header: DescriptionHeader,
hash_header: HashHeader,
chunk_size: u8,
signature_flag: u8,
segment_size: u64,
number_of_segments: u64,
unique_identifier: i64,
length_of_data: u64
) -> MainHeader
returns a new main header with the given values.
sourcepub fn encrypted_header_identifier() -> u32
pub fn encrypted_header_identifier() -> u32
returns the header identifier for the encrypted main header.
sourcepub fn decode_encrypted_header_with_password<R, P>(
data: &mut R,
password: P
) -> Result<MainHeader> where
R: Read,
P: AsRef<[u8]>,
pub fn decode_encrypted_header_with_password<R, P>(
data: &mut R,
password: P
) -> Result<MainHeader> where
R: Read,
P: AsRef<[u8]>,
decodes the encrypted main header with the given password.
sourcepub fn encode_encrypted_header_directly<K>(&self, key: K) -> Result<Vec<u8>> where
K: AsRef<[u8]>,
pub fn encode_encrypted_header_directly<K>(&self, key: K) -> Result<Vec<u8>> where
K: AsRef<[u8]>,
encodes the main header to a Vec<u8>. The encryption flag will be set to 2.
Error
The method returns an error, if the encryption header is missing (=None).
sourcepub fn set_length_of_data(&mut self, len: u64)
pub fn set_length_of_data(&mut self, len: u64)
sets the length of the dumped data.
sourcepub fn set_hash_header(&mut self, hash_header: HashHeader)
pub fn set_hash_header(&mut self, hash_header: HashHeader)
sets the hash header.
sourcepub fn chunk_size(&self) -> usize
pub fn chunk_size(&self) -> usize
returns the chunk_size.
sourcepub fn segment_size(&self) -> u64
pub fn segment_size(&self) -> u64
returns the segment size
sourcepub fn get_encoded_size(&self) -> usize
pub fn get_encoded_size(&self) -> usize
returns the len() of the Vec<u8> (encoded main header).
sourcepub fn get_encrypted_encoded_size<K>(&self, key: K) -> Result<usize> where
K: AsRef<[u8]>,
pub fn get_encrypted_encoded_size<K>(&self, key: K) -> Result<usize> where
K: AsRef<[u8]>,
returns the len() of the Vec<u8> (encoded encrypted main header).
Error
The method fails, if the encryption fails or no encryption header is present.
sourcepub fn has_signature(&self) -> bool
pub fn has_signature(&self) -> bool
returns, if the chunks has a ed25519 signature or not.
sourcepub fn set_acquisition_end(&mut self, timestamp: u64)
pub fn set_acquisition_end(&mut self, timestamp: u64)
sets the acquisition end timestamp of the inner description header.
sourcepub fn compression_header(&self) -> &CompressionHeader
pub fn compression_header(&self) -> &CompressionHeader
returns a reference to the inner compression header
sourcepub fn encryption_header(&self) -> &Option<EncryptionHeader>
pub fn encryption_header(&self) -> &Option<EncryptionHeader>
returns a reference to the inner encryption header (if available)
sourcepub fn description_header(&self) -> &DescriptionHeader
pub fn description_header(&self) -> &DescriptionHeader
returns a reference to the inner description header
sourcepub fn hash_header(&self) -> &HashHeader
pub fn hash_header(&self) -> &HashHeader
returns a reference to the inner hash header
sourcepub fn length_of_data(&self) -> u64
pub fn length_of_data(&self) -> u64
returns the length of the content data
sourcepub fn unique_identifier(&self) -> i64
pub fn unique_identifier(&self) -> i64
returns the unique identifier
sourcepub fn set_number_of_segments(&mut self, value: u64)
pub fn set_number_of_segments(&mut self, value: u64)
sets the number of segments
sourcepub fn number_of_segments(&self) -> u64
pub fn number_of_segments(&self) -> u64
returns the number of segments
Trait Implementations
sourceimpl Clone for MainHeader
impl Clone for MainHeader
sourcefn clone(&self) -> MainHeader
fn clone(&self) -> MainHeader
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for MainHeader
impl Debug for MainHeader
sourceimpl HeaderCoding for MainHeader
impl HeaderCoding for MainHeader
type Item = MainHeader
type Item = MainHeader
the return value for decode_content(), decode_directly(), decode_for_key();
sourcefn identifier() -> u32
fn identifier() -> u32
returns the identifier (=Magic bytes) of the header.
sourcefn encode_header(&self) -> Vec<u8>
fn encode_header(&self) -> Vec<u8>
encodes the header.
sourcefn decode_content(data: Vec<u8>) -> Result<MainHeader>
fn decode_content(data: Vec<u8>) -> Result<MainHeader>
decodes the content of the header.
sourcefn header_size(&self) -> usize
fn header_size(&self) -> usize
returns the size of the encoded header (in bytes)
sourcefn encode_directly(&self) -> Vec<u8>
fn encode_directly(&self) -> Vec<u8>
encodes the (header) value/object directly (= without key).
sourcefn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8>
fn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8>
encodes a key to the (header) value/object.
sourcefn decode_header_length<R: Read>(data: &mut R) -> Result<u64>
fn decode_header_length<R: Read>(data: &mut R) -> Result<u64>
decodes the length of the header.
sourcefn check_identifier<R: Read>(data: &mut R) -> bool
fn check_identifier<R: Read>(data: &mut R) -> bool
checks if the read identifier is valid for this header.
Auto Trait Implementations
impl RefUnwindSafe for MainHeader
impl Send for MainHeader
impl Sync for MainHeader
impl Unpin for MainHeader
impl UnwindSafe for MainHeader
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more