Struct PosixHeader

Source
#[repr(C, packed(1))]
pub struct PosixHeader {
Show 17 fields pub name: TarFormatString<NAME_LEN>, pub mode: Mode, pub uid: TarFormatOctal<8>, pub gid: TarFormatOctal<8>, pub size: TarFormatOctal<12>, pub mtime: TarFormatDecimal<12>, pub cksum: TarFormatOctal<8>, pub typeflag: TypeFlagRaw, pub linkname: TarFormatString<NAME_LEN>, pub magic: TarFormatString<6>, pub version: TarFormatString<2>, pub uname: TarFormatString<32>, pub gname: TarFormatString<32>, pub dev_major: TarFormatOctal<8>, pub dev_minor: TarFormatOctal<8>, pub prefix: TarFormatString<PREFIX_LEN>, pub _pad: [u8; 12],
}
Expand description

Header of the TAR format as specified by POSIX (POSIX 1003.1-1990).

“New” GNU Tar versions use this archive format by default. (https://www.gnu.org/software/tar/manual/html_node/Formats.html#Formats).

Each file is started by such a header, that describes the size and the file name. After that, the file content stands in chunks of 512 bytes. The number of bytes can be derived from the file size.

This is also mostly compatible with the “Ustar”-header and the “GNU format”. Because this library mainly targets the filename, the data, and basic metadata, we don’t need advanced checks for specific extensions.

Fields§

§name: TarFormatString<NAME_LEN>§mode: Mode§uid: TarFormatOctal<8>§gid: TarFormatOctal<8>§size: TarFormatOctal<12>§mtime: TarFormatDecimal<12>§cksum: TarFormatOctal<8>§typeflag: TypeFlagRaw§linkname: TarFormatString<NAME_LEN>

Name. There is always a null byte, therefore the max len is 99.

§magic: TarFormatString<6>§version: TarFormatString<2>§uname: TarFormatString<32>

Username. There is always a null byte, therefore the max len is N-1.

§gname: TarFormatString<32>

Groupname. There is always a null byte, therefore the max len is N-1.

§dev_major: TarFormatOctal<8>§dev_minor: TarFormatOctal<8>§prefix: TarFormatString<PREFIX_LEN>§_pad: [u8; 12]

Implementations§

Source§

impl PosixHeader

Source

pub fn payload_block_count(&self) -> Result<usize, ParseIntError>

Returns the number of blocks that are required to read the whole file content. Returns an error, if the file size can’t be parsed from the header.

Source

pub fn is_zero_block(&self) -> bool

A Tar archive is terminated, if an end-of-archive entry, which consists of two 512 blocks of zero bytes, is found.

Trait Implementations§

Source§

impl Clone for PosixHeader

Source§

fn clone(&self) -> PosixHeader

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PosixHeader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PosixHeader

Source§

fn eq(&self, other: &PosixHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PosixHeader

Source§

impl Eq for PosixHeader

Source§

impl StructuralPartialEq for PosixHeader

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.