pub struct VerificationSession { /* private fields */ }Expand description
Streaming verification session that tracks PAR2 verification state as data arrives during download.
Usage:
- Call
Self::add_par2_datawhen PAR2 metadata packets arrive. - Call
Self::feed_dataas decoded file data arrives (slice-aligned). - Query
Self::file_status,Self::repairability, orSelf::is_completeat any time. - Call
Self::verification_resultonce all data has been fed.
Implementations§
Source§impl VerificationSession
impl VerificationSession
Sourcepub fn with_options(options: VerificationSessionOptions) -> Self
pub fn with_options(options: VerificationSessionOptions) -> Self
Create a session using the supplied buffering policy.
Sourcepub fn with_memory_budget(memory_budget: VerificationMemoryBudget) -> Self
pub fn with_memory_budget(memory_budget: VerificationMemoryBudget) -> Self
Create a session using a caller-shareable boundary-buffer budget.
Sourcepub fn memory_budget(&self) -> &VerificationMemoryBudget
pub fn memory_budget(&self) -> &VerificationMemoryBudget
The budget used for incomplete slice data in this session.
Sourcepub fn add_par2_data(&mut self, packets: &[Packet])
pub fn add_par2_data(&mut self, packets: &[Packet])
Called when PAR2 metadata arrives. May be called multiple times as packets from different .par2 volumes arrive.
Once a valid Par2FileSet can be built from the accumulated packets,
per-file verification state is initialized.
Sourcepub fn feed_data(&mut self, file_id: &FileId, offset: u64, data: &[u8])
pub fn feed_data(&mut self, file_id: &FileId, offset: u64, data: &[u8])
Feed decoded file data for a specific file.
This compatibility wrapper accepts the historical aligned input and
intentionally discards the detailed outcome. New callers should use
feed_range to receive evidence and settle reads.
If PAR2 metadata has not yet arrived, the data is silently ignored. (The assembly layer should re-feed data after PAR2 metadata arrives if needed, or the caller can handle this at a higher level.)
Sourcepub fn feed_range(
&mut self,
file_id: &FileId,
offset: u64,
data: &[u8],
) -> FeedOutcome
pub fn feed_range( &mut self, file_id: &FileId, offset: u64, data: &[u8], ) -> FeedOutcome
Feed an arbitrary logical byte range for a PAR2 file.
Aligned complete slices are checksummed immediately without retaining
the slice payload. Only incomplete boundary slices are buffered. The
returned FeedOutcome reports newly settled SliceEvidence and
precise SettleRead ranges needed to complete or disambiguate a slice.
Sourcepub fn feed_data_range(
&mut self,
file_id: &FileId,
offset: u64,
data: &[u8],
) -> FeedOutcome
pub fn feed_data_range( &mut self, file_id: &FileId, offset: u64, data: &[u8], ) -> FeedOutcome
Alias for callers that use feed_data terminology for arbitrary ranges.
Sourcepub fn file_status(&self, file_id: &FileId) -> Option<FileStatus>
pub fn file_status(&self, file_id: &FileId) -> Option<FileStatus>
Query the current status of a specific file.
Sourcepub fn repairability(&self) -> Repairability
pub fn repairability(&self) -> Repairability
Estimate repairability given the current state.
This accounts for both verified-damaged slices and pending (unverified) slices, treating pending slices optimistically (assuming they will pass).
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if all files have been verified successfully.
Sourcepub fn verification_result(&self) -> Option<VerificationResult>
pub fn verification_result(&self) -> Option<VerificationResult>
Produce a full VerificationResult from the current session state.
This can be passed to plan_repair if
repair is needed. Returns None if PAR2 metadata has not been loaded.
Sourcepub fn verify_from_slice_crcs(
&mut self,
file_id: &FileId,
slice_crcs: &[u32],
) -> Option<Vec<bool>>
pub fn verify_from_slice_crcs( &mut self, file_id: &FileId, slice_crcs: &[u32], ) -> Option<Vec<bool>>
Verify a file’s slices using pre-computed CRC32 values from download.
Each entry in slice_crcs must be the CRC32 of the (possibly zero-padded)
slice data. This is a CRC-only check (no MD5); it avoids re-reading files
from disk when the download layer already computed per-slice CRCs.
Returns per-slice validity, or None if PAR2 metadata isn’t loaded or
the file is unknown.
Sourcepub fn slice_evidence(&self) -> Vec<SliceEvidence>
pub fn slice_evidence(&self) -> Vec<SliceEvidence>
Return every settled slice verdict held by this session.
The result is deterministic by file ID and slice index, and contains only PAR2 coordinates plus validity so it can be handed to a later repair stage without coupling it to filesystem paths.
Sourcepub fn par2_set(&self) -> Option<&Arc<Par2FileSet>>
pub fn par2_set(&self) -> Option<&Arc<Par2FileSet>>
Get a reference to the underlying PAR2 file set, if loaded.
Trait Implementations§
Source§impl Default for VerificationSession
impl Default for VerificationSession
Source§impl Drop for VerificationSession
impl Drop for VerificationSession
Auto Trait Implementations§
impl Freeze for VerificationSession
impl RefUnwindSafe for VerificationSession
impl Send for VerificationSession
impl Sync for VerificationSession
impl Unpin for VerificationSession
impl UnsafeUnpin for VerificationSession
impl UnwindSafe for VerificationSession
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> 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