Skip to main content

PaxBuilder

Struct PaxBuilder 

Source
pub struct PaxBuilder { /* private fields */ }
Expand description

Builder for PAX extended header records.

PAX extended headers contain key-value pairs that extend the basic tar header format, allowing for longer paths, larger file sizes, and additional metadata.

§Format

Each record has the format: <length> <key>=<value>\n where <length> is the total record length including the length field itself.

§Example

use tar_core::builder::PaxBuilder;

let mut builder = PaxBuilder::new();
builder
    .path(b"/very/long/path/that/exceeds/100/characters/limit.txt")
    .size(1_000_000_000_000);
let data = builder.finish();

Implementations§

Source§

impl PaxBuilder

Source

pub fn new() -> Self

Create a new empty PAX builder.

Source

pub fn add(&mut self, key: &str, value: impl AsRef<[u8]>) -> &mut Self

Add a key-value record.

The record is formatted as <length> <key>=<value>\n.

The length prefix includes itself, which requires computing how many decimal digits the total length will occupy. This uses the same algorithm as tar-rs’s append_pax_extensions.

Source

pub fn path(&mut self, path: impl AsRef<[u8]>) -> &mut Self

Add a path record.

Source

pub fn linkpath(&mut self, path: impl AsRef<[u8]>) -> &mut Self

Add a linkpath record.

Source

pub fn add_u64(&mut self, key: &str, value: u64) -> &mut Self

Add a record with a u64 value formatted as decimal.

Source

pub fn size(&mut self, size: u64) -> &mut Self

Add a size record.

Source

pub fn uid(&mut self, uid: u64) -> &mut Self

Add a uid record.

Source

pub fn gid(&mut self, gid: u64) -> &mut Self

Add a gid record.

Source

pub fn uname(&mut self, name: impl AsRef<[u8]>) -> &mut Self

Add a uname (username) record.

Source

pub fn gname(&mut self, name: impl AsRef<[u8]>) -> &mut Self

Add a gname (group name) record.

Source

pub fn mtime(&mut self, mtime: u64) -> &mut Self

Add an mtime record.

Source

pub fn atime(&mut self, atime: u64) -> &mut Self

Add an atime record.

Source

pub fn ctime(&mut self, ctime: u64) -> &mut Self

Add a ctime record.

Source

pub fn as_bytes(&self) -> &[u8]

Get the current data (for inspection).

Source

pub fn finish(self) -> Vec<u8>

Return the finished PAX extended header data.

Trait Implementations§

Source§

impl Clone for PaxBuilder

Source§

fn clone(&self) -> PaxBuilder

Returns a duplicate 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 PaxBuilder

Source§

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

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

impl Default for PaxBuilder

Source§

fn default() -> PaxBuilder

Returns the “default value” for a type. Read more

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.