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.

Returns Ok(None) at the end of the archive. See the implementation’s documentation for whether reads can continue after a decoding error or cancellation.

Provided Methods§

Source

fn members(self) -> Members<Self>

Consumes this archive and returns its lending member cursor.

Member paths may repeat, and distinct paths may resolve to the same file on disk. Callers that write members to disk themselves must decide how to handle those collisions. Doing so is non-trivial. Most users are strongly encouraged to use Self::extract_in.

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.

This method requires the fs feature.

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. When creating a regular file on Unix, the extractor requests mode 0o777 if the archive marks the file executable and 0o666 otherwise. The host determines the file’s effective permissions from that mode and local settings such as the process umask or an access control list inherited from the parent directory. 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§