pub struct RecoveryDecoder { /* private fields */ }Expand description
Reconstructs a set of missing PAR2 input slices.
Implementations§
Source§impl RecoveryDecoder
impl RecoveryDecoder
Sourcepub fn new(
slice_size: usize,
total_input_slices: usize,
missing: Vec<usize>,
) -> Self
pub fn new( slice_size: usize, total_input_slices: usize, missing: Vec<usize>, ) -> Self
Build a decoder for total_input_slices input slices of slice_size
bytes each, where the global indices listed in missing need
reconstruction.
§Panics
Panics if missing is empty or any index in it is
>= total_input_slices.
Sourcepub fn reconstruct(
&self,
known_slice: impl FnMut(usize) -> Result<Vec<u8>>,
recovery_blocks: &BTreeMap<u32, Vec<u8>>,
) -> Result<Vec<(usize, Vec<u8>)>>
pub fn reconstruct( &self, known_slice: impl FnMut(usize) -> Result<Vec<u8>>, recovery_blocks: &BTreeMap<u32, Vec<u8>>, ) -> Result<Vec<(usize, Vec<u8>)>>
Reconstruct every missing slice.
known_slice(i) must return the padded, slice-sized bytes of known
(non-missing) global input slice i. It is called exactly once per
known slice, in ascending order — a caller reading from disk pays for
one sequential pass over the surviving data, not one pass per missing
slice.
recovery_blocks must hold at least self.missing().len() entries;
the lowest-exponent blocks available are used first (an arbitrary but
deterministic choice). Consecutive exponents always form an invertible
matrix; a non-consecutive selection, left after some recovery blocks
were lost, can be singular (see the crate::matrix module docs).
Returns (global_index, slice_bytes) pairs, one per entry of
missing, in the same order.
Auto Trait Implementations§
impl Freeze for RecoveryDecoder
impl RefUnwindSafe for RecoveryDecoder
impl Send for RecoveryDecoder
impl Sync for RecoveryDecoder
impl Unpin for RecoveryDecoder
impl UnsafeUnpin for RecoveryDecoder
impl UnwindSafe for RecoveryDecoder
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> 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