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
.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more