Struct Header

Source
pub struct Header {
    pub file_type: FileType,
    pub protocol_version: ProtocolVersion,
    pub entry_size: u16,
    pub hash_type: HashType,
}
Expand description

Structural representation of 32 byte SLEEP headers.

Fields§

§file_type: FileType

Type of file.

§protocol_version: ProtocolVersion

Version of the SLEEP protocol.

§entry_size: u16

Size of each piece of data in the file body.

§hash_type: HashType

Algorithm used for hashing the content.

Implementations§

Source§

impl Header

Source

pub fn new(file_type: FileType, entry_size: u16, hash_type: HashType) -> Self

Create a new Header.

Source

pub fn from_vec(buffer: &[u8]) -> Result<Header, Error>

Parse a 32 byte buffer slice into a valid Header.

Source

pub fn to_vec(&self) -> Vec<u8>

Convert a Header into a Vec<u8>. Use this to persist a header back to disk.

Source

pub fn is_bitfield(&self) -> bool

Check whether the header is formatted as a .bitfield.

Source

pub fn is_signatures(&self) -> bool

Check whether the header is formatted as a .signatures.

Source

pub fn is_tree(&self) -> bool

Check whether the header is formatted as a .tree.

Trait Implementations§

Source§

impl Debug for Header

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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> 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, 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.