Struct sleep_parser::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
impl Header
sourcepub fn new(file_type: FileType, entry_size: u16, hash_type: HashType) -> Self
pub fn new(file_type: FileType, entry_size: u16, hash_type: HashType) -> Self
Create a new Header
.
sourcepub fn from_vec(buffer: &[u8]) -> Result<Header, Error>
pub fn from_vec(buffer: &[u8]) -> Result<Header, Error>
Parse a 32 byte buffer slice into a valid Header.
sourcepub fn to_vec(&self) -> Vec<u8>
pub fn to_vec(&self) -> Vec<u8>
Convert a Header
into a Vec<u8>
. Use this to persist a header back to
disk.
sourcepub fn is_bitfield(&self) -> bool
pub fn is_bitfield(&self) -> bool
Check whether the header is formatted as a .bitfield
.
sourcepub fn is_signatures(&self) -> bool
pub fn is_signatures(&self) -> bool
Check whether the header is formatted as a .signatures
.