Skip to main content

Archive

Trait Archive 

Source
pub trait Archive: Sized {
    type Error;
    type Payload<'a>: MemberPayload<Error = Self::Error>
       where Self: 'a;

    // Required method
    async fn next_member<'a>(
        &'a mut self,
    ) -> Result<Option<Member<Self::Payload<'a>>>, Self::Error>;

    // Provided methods
    fn members(self) -> Members<Self> { ... }
    async fn extract_in<P>(
        self,
        destination: P,
        policy: ExtractPolicy,
    ) -> Result<(), ExtractError<Self::Error>>
       where P: AsRef<Path> { ... }
}
Expand description

A one-pass archive that can enumerate and extract format-neutral members.

Required Associated Types§

Source

type Error

The archive-format error returned during member iteration.

Source

type Payload<'a>: MemberPayload<Error = Self::Error> where Self: 'a

The streaming payload type lent by each file member.

Required Methods§

Source

async fn next_member<'a>( &'a mut self, ) -> Result<Option<Member<Self::Payload<'a>>>, Self::Error>

Reads the next format-neutral member for Members::next.

Implementations must drain and validate an unfinished preceding payload before returning another member. Archive consumers should use Archive::members rather than call this hook directly: Members wraps each payload in LentPayload to enforce the lending cursor contract even when a concrete payload type does not retain its lifetime.

Provided Methods§

Source

fn members(self) -> Members<Self>

Consumes this archive and returns its lending member cursor.

Source

async fn extract_in<P>( self, destination: P, policy: ExtractPolicy, ) -> Result<(), ExtractError<Self::Error>>
where P: AsRef<Path>,

Securely extracts this archive beneath destination under policy.

destination is created if it does not already exist. Symbolic links are preserved by default on platforms that support native creation; hard links require explicit opt-in through extract::LinkPolicy.

Archived Unix permission modes are normalized rather than restored. New regular files are created with mode 0o777 when executable intent is set and 0o666 otherwise, in both cases filtered by the process umask. Directories use the platform’s default creation mode, and special mode bits are not restored. Ownership and timestamps are likewise determined by extraction activity rather than archived metadata.

IMPORTANT: destination must not be concurrently modified during extraction. No correctness or isolation guarantees are made under external mutation.

Extraction is streamwise: a late error can leave a partially extracted destination. Callers requiring all-or-nothing behavior should extract into a new temporary directory and atomically rename it afterward.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<R: AsyncRead + Unpin> Archive for TarArchive<R>

Source§

type Error = DecodeError

Source§

type Payload<'a> = TarMemberPayload<'a, R> where Self: 'a