Skip to main content

Candidate

Struct Candidate 

Source
pub struct Candidate {
    pub offset: u64,
    pub meta: EntryMeta,
    pub declared_len: Option<u64>,
    pub verifier: Option<Verifier>,
    pub available_len: Option<u64>,
}
Expand description

A record a scanner believes it found, before anything is decoded.

Fields§

§offset: u64

Byte offset of the record’s header in the archive.

§meta: EntryMeta§declared_len: Option<u64>

Declared payload length. None when the header does not carry one.

§verifier: Option<Verifier>

The checksum the ORIGINAL writer computed, when the format has one. None is what produces the intact/complete split honestly, rather than by a per-format convention someone has to remember.

§available_len: Option<u64>

How many of declared_len’s bytes the SOURCE actually holds, when it holds fewer — the truncated-tail case. None means the declared payload is entirely present (the ordinary case) or nothing was declared at all; Some(n) always means n < declared_len.

§Why a scanner reports this instead of dropping the candidate

A truncated archive — an interrupted download — is the single most common damaged zip there is, and it was the one shape salvage said nothing at all about. zip_salvage.rs’s validation gate refused any candidate whose declared payload ran past the end of the file, which is a correct refusal to INVENT the missing bytes (zip -FF fabricates them and reports success) implemented as SILENCE: no row, no note, no non-zero exit. Swept across six truncation points inside a three-header archive’s last entry, every one reported “2 scanned” at exit 0 — the third header was not even counted.

Reporting the candidate with this field set is what turns the refusal into a statement. Nothing is invented: the declared length stays exactly what the header said, so a reader can see both figures, and the bytes that ARE present are still a genuine prefix. What a scanner must NOT do is fold the shortfall into declared_len — that would make a truncated entry indistinguishable from a whole one of the smaller size, which is the same mistake in a different place.

Trait Implementations§

Source§

impl Debug for Candidate

Source§

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

Formats the value using the given formatter. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.