pub struct SegmentHeader { /* private fields */ }Expand description
The segment header contains all informations about the specific segment. Each segment has his own segment header.
This header is not a part of the main header.\
Implementations
sourceimpl SegmentHeader
impl SegmentHeader
sourcepub fn new_empty(
version: u8,
unique_identifier: i64,
segment_number: u64
) -> SegmentHeader
pub fn new_empty(
version: u8,
unique_identifier: i64,
segment_number: u64
) -> SegmentHeader
returns a new empty segment header
sourcepub fn new(
version: u8,
unique_identifier: i64,
segment_number: u64,
length_of_segment: u64,
footer_offset: u64
) -> SegmentHeader
pub fn new(
version: u8,
unique_identifier: i64,
segment_number: u64,
length_of_segment: u64,
footer_offset: u64
) -> SegmentHeader
returns a new segment header with the given values.
sourcepub fn unique_identifier(&self) -> i64
pub fn unique_identifier(&self) -> i64
returns the unique identifier of image (each segment should have the same identifier).
sourcepub fn segment_number(&self) -> u64
pub fn segment_number(&self) -> u64
returns the segment number.
sourcepub fn length_of_segment(&self) -> u64
pub fn length_of_segment(&self) -> u64
returns the length of the segment in bytes.
sourcepub fn set_length_of_segment(&mut self, value: u64)
pub fn set_length_of_segment(&mut self, value: u64)
overwrites the length value in the header with the given value. This can be useful, if you create an ‘empty’ header (with length=0) and want to set the length value after reading the data from source to buffer.
sourcepub fn next_header(&self) -> SegmentHeader
pub fn next_header(&self) -> SegmentHeader
sets the segment number to the next number. This can be useful, for example, if you clone a segment header from the previous one or something like that.
sets the offset of the segment footer.
returns the footer offset.
Trait Implementations
sourceimpl Clone for SegmentHeader
impl Clone for SegmentHeader
sourcefn clone(&self) -> SegmentHeader
fn clone(&self) -> SegmentHeader
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 SegmentHeader
impl Debug for SegmentHeader
sourceimpl HeaderCoding for SegmentHeader
impl HeaderCoding for SegmentHeader
type Item = SegmentHeader
type Item = SegmentHeader
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<SegmentHeader>
fn decode_content(data: Vec<u8>) -> Result<SegmentHeader>
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.
sourceimpl PartialEq<SegmentHeader> for SegmentHeader
impl PartialEq<SegmentHeader> for SegmentHeader
impl Eq for SegmentHeader
impl StructuralEq for SegmentHeader
Auto Trait Implementations
impl RefUnwindSafe for SegmentHeader
impl Send for SegmentHeader
impl Sync for SegmentHeader
impl Unpin for SegmentHeader
impl UnwindSafe for SegmentHeader
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more