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
impl SliceEvidence
Sourcepub fn recovery_set_id(&self) -> RecoverySetId
pub fn recovery_set_id(&self) -> RecoverySetId
Recovery set whose metadata produced this verdict.
Sourcepub fn slice_index(&self) -> u32
pub fn slice_index(&self) -> u32
Zero-based PAR2 slice index within Self::file_id.
Sourcepub fn strength(&self) -> SliceEvidenceStrength
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.
Sourcepub fn from_in_stream_crc32(
recovery_set_id: RecoverySetId,
file_id: FileId,
slice_index: u32,
valid: bool,
proof: InStreamCrc32Proof,
) -> Self
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.
Sourcepub fn in_stream_proof(&self) -> Option<&InStreamCrc32Proof>
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.
Sourcepub fn may_seed_repair_input(&self) -> bool
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
impl Clone for SliceEvidence
Source§fn clone(&self) -> SliceEvidence
fn clone(&self) -> SliceEvidence
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SliceEvidence
Source§impl Debug for SliceEvidence
impl Debug for SliceEvidence
impl Eq for SliceEvidence
Source§impl PartialEq for SliceEvidence
impl PartialEq for SliceEvidence
impl StructuralPartialEq for SliceEvidence
Auto Trait Implementations§
impl Freeze for SliceEvidence
impl RefUnwindSafe for SliceEvidence
impl Send for SliceEvidence
impl Sync for SliceEvidence
impl Unpin for SliceEvidence
impl UnsafeUnpin for SliceEvidence
impl UnwindSafe for SliceEvidence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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