Skip to main content

VerificationSession

Struct VerificationSession 

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

Streaming verification session that tracks PAR2 verification state as data arrives during download.

Usage:

  1. Call Self::add_par2_data when PAR2 metadata packets arrive.
  2. Call Self::feed_data as decoded file data arrives (slice-aligned).
  3. Query Self::file_status, Self::repairability, or Self::is_complete at any time.
  4. Call Self::verification_result once all data has been fed.

Implementations§

Source§

impl VerificationSession

Source

pub fn new() -> Self

Create a new empty verification session.

Source

pub fn with_options(options: VerificationSessionOptions) -> Self

Create a session using the supplied buffering policy.

Source

pub fn with_memory_budget(memory_budget: VerificationMemoryBudget) -> Self

Create a session using a caller-shareable boundary-buffer budget.

Source

pub fn memory_budget(&self) -> &VerificationMemoryBudget

The budget used for incomplete slice data in this session.

Source

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.

Source

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.)

Source

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.

Source

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.

Source

pub fn file_status(&self, file_id: &FileId) -> Option<FileStatus>

Query the current status of a specific file.

Source

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).

Source

pub fn is_complete(&self) -> bool

Check if all files have been verified successfully.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for VerificationSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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, 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