Struct tar_no_std::PosixHeader

source ·
#[repr(C, packed)]
pub struct PosixHeader {
Show 17 fields pub name: StaticCString<{ FILENAME_MAX_LEN }>, pub mode: Mode, pub uid: [u8; 8], pub gid: [u8; 8], pub size: Size, pub mtime: [u8; 12], pub cksum: [u8; 8], pub typeflag: TypeFlag, pub linkname: StaticCString<{ FILENAME_MAX_LEN }>, pub magic: StaticCString<6>, pub version: StaticCString<2>, pub uname: StaticCString<32>, pub gname: StaticCString<32>, pub dev_major: [u8; 8], pub dev_minor: [u8; 8], pub prefix: StaticCString<155>, pub _pad: [u8; 12],
}
Expand description

Header of the TAR format as specified by POSIX (POSIX 1003.1-1990. “New” (version?) 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 only needs to fetch data and filename, we don’t need further checks.

Fields§

§name: StaticCString<{ FILENAME_MAX_LEN }>

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

§mode: Mode§uid: [u8; 8]§gid: [u8; 8]§size: Size§mtime: [u8; 12]§cksum: [u8; 8]§typeflag: TypeFlag§linkname: StaticCString<{ FILENAME_MAX_LEN }>

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

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

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

§gname: StaticCString<32>

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

§dev_major: [u8; 8]§dev_minor: [u8; 8]§prefix: StaticCString<155>

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

§_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 a 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 Copy for PosixHeader

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.