pub struct Header {
pub name: String,
pub size: u64,
pub mtime: u64,
pub prefix: String,
pub bytes: Vec<u8>,
}Expand description
Metadata representation of a file with attributes necessary for an archive entry.
Fields§
§name: StringBase name of the file from an entry.
size: u64Size of the file in bytes.
mtime: u64Last modified time relative to UNIX epochs.
prefix: StringPath of the file without the final component, its name.
bytes: Vec<u8>A representation of name, size, mtime and perfix in a blob of bytes.
Each field is zero padded to meets predefined boundaries.
Implementations§
Source§impl Header
impl Header
Sourcepub fn from_bytes(block: &[u8]) -> Result<Header, HeaderError>
pub fn from_bytes(block: &[u8]) -> Result<Header, HeaderError>
Parse an archive metadata entry for a file from a block of bytes.
Sourcepub fn from_file_metadata<P: AsRef<Path>>(
path: P,
) -> Result<Header, FileParseError>
pub fn from_file_metadata<P: AsRef<Path>>( path: P, ) -> Result<Header, FileParseError>
Generate an archive metadata entry for a file given its path.
§Example
use wpress_oxide::Header;
let header = Header::from_file_metadata("tests/writer/file.txt")?;
assert_eq!(header.name, "file.txt");
assert_eq!(header.size, 5);
assert_eq!(header.prefix, "tests/writer");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