pub struct RsCode { /* private fields */ }Expand description
A systematic Cauchy Reed-Solomon erasure code: k data shards plus
r parity shards, recovering any k of the k + r.
Implementations§
Source§impl RsCode
impl RsCode
Sourcepub fn new(k: usize, r: usize) -> Result<Self, FecError>
pub fn new(k: usize, r: usize) -> Result<Self, FecError>
Build a (k, r) systematic Cauchy-RS code. k >= 1, r >= 1,
k + r <= 256.
Sourcepub fn with_backend(self, backend: Option<GfBackend>) -> Self
pub fn with_backend(self, backend: Option<GfBackend>) -> Self
Pin the GF(256) backend for this code (an A/B-bench / emulation-
validation knob), or None to use the auto-detected fastest rung. The
override is per-instance, so it never affects another RsCode.
Sourcepub fn encode(
&self,
data: &[&[u8]],
parity: &mut [&mut [u8]],
) -> Result<(), FecError>
pub fn encode( &self, data: &[&[u8]], parity: &mut [&mut [u8]], ) -> Result<(), FecError>
Compute the r parity shards from the k data shards. All
shards (data and parity) must have the same length.
Sourcepub fn decode(&self, shards: &mut [Option<Vec<u8>>]) -> Result<(), FecError>
pub fn decode(&self, shards: &mut [Option<Vec<u8>>]) -> Result<(), FecError>
Recover the missing data shards in place. shards has k + r
entries (data shards first, then parity); Some = received,
None = lost. On success every data-shard slot 0..k is
Some. Returns TooFewShards if fewer than k survived.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RsCode
impl RefUnwindSafe for RsCode
impl Send for RsCode
impl Sync for RsCode
impl Unpin for RsCode
impl UnsafeUnpin for RsCode
impl UnwindSafe for RsCode
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
Mutably borrows from an owned value. Read more