Skip to main content

SliceEvidence

Struct SliceEvidence 

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

A completed PAR2 slice verdict, suitable for passing to a repair session.

Evidence deliberately identifies PAR2 coordinates only. It never exposes a filesystem path or assumes where the downloaded bytes were stored.

A session produces this itself from bytes it hashed (VerificationSession::slice_evidence). A caller that hashed the bytes during its own single pass over them — never handing them to par2-rs at all — mints one with SliceEvidence::from_in_stream_crc32.

Implementations§

Source§

impl SliceEvidence

Source

pub fn recovery_set_id(&self) -> RecoverySetId

Recovery set whose metadata produced this verdict.

Source

pub fn file_id(&self) -> FileId

File to which this PAR2 slice belongs.

Source

pub fn slice_index(&self) -> u32

Zero-based PAR2 slice index within Self::file_id.

Source

pub fn is_valid(&self) -> bool

Whether this slice’s CRC32 and MD5 matched the PAR2 IFSC entry.

Source

pub fn strength(&self) -> SliceEvidenceStrength

Hash strength used to produce this verdict.

Externally attested verdicts report SliceEvidenceStrength::Crc32Only, because that is what was actually computed. Use Self::in_stream_proof to tell them apart from an unattested CRC32 comparison.

Source

pub fn from_in_stream_crc32( recovery_set_id: RecoverySetId, file_id: FileId, slice_index: u32, valid: bool, proof: InStreamCrc32Proof, ) -> Self

Mint a verdict the caller derived itself, in stream, from a slice’s PAR2 CRC32.

This exists for a caller that already hashes every payload byte for its own reasons and can cut that hash on the recovery set’s block grid. It hands par2-rs the conclusion — this slice’s CRC32 did or did not agree with the recovery set’s IFSC entry — without ever handing over the bytes, so nothing is read, buffered or hashed twice.

valid is the result of that comparison. proof is the caller’s attestation, and InStreamCrc32Proof documents exactly what it does and does not assert — in short, that a CRC32 covering the whole slice’s durable bytes agreed with the IFSC entry, and not that the slice’s identity was established, which needs MD5.

The comparison itself is the caller’s: par2-rs is not given the derived CRC32 and does not re-run the check. That is the point — the recovery set’s expected CRC32 is public in its IFSC packet, so a caller that has read the set can compare against it as well as this crate can, and asking it to ship the value back for a redundant comparison would prove nothing the attestation does not already carry.

§Where this lands

A valid verdict seeds a repair input for that one slice, the same seat a slice hashed by VerificationSession takes. It never promotes a file to a whole-file match — only a complete-file hash does that — and repair re-derives both the IFSC CRC32 and MD5 over every byte it consumes, so a mistaken attestation fails the repair loudly instead of producing wrong output.

An invalid verdict routes into the session’s ordinary contradiction handling, which retires the source the verdict named — for a source served by a handle, that is the whole file, because file identity is the only thing such a source has to be named by. A caller holding good verdicts for a file’s other slices should therefore seed those and simply not seed the damaged one, leaving it unresolved for repair or for a read-back pass, rather than seeding a contradiction that retires the good slices alongside it.

Source

pub fn in_stream_proof(&self) -> Option<&InStreamCrc32Proof>

The in-stream attestation carried by this verdict, when it was minted by Self::from_in_stream_crc32 rather than hashed by a session.

Source

pub fn may_seed_repair_input(&self) -> bool

Whether a repair session may act on this verdict.

True for a slice this crate hashed with both the IFSC CRC32 and MD5, and for an externally attested in-stream CRC32 verdict. False for a bare CRC32 comparison with nothing vouching for where its bytes came from — VerificationSession::verify_from_slice_crcs produces those, and a caller-supplied CRC32 with no attestation cannot say whether it describes the bytes a repair would later read.

Trait Implementations§

Source§

impl Clone for SliceEvidence

Source§

fn clone(&self) -> SliceEvidence

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SliceEvidence

Source§

impl Debug for SliceEvidence

Source§

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

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

impl Eq for SliceEvidence

Source§

impl PartialEq for SliceEvidence

Source§

fn eq(&self, other: &SliceEvidence) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SliceEvidence

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more