pub struct Fec { /* private fields */ }Expand description
Forward Error Correcting encoder/decoder.
The encoder can be defined with 2 values: k and m
kis the number of chunks needed to reconstruct the original messagemis the total number of chunks that will be produced
The first k chunks contain the original unaltered data, meaning that if all the original chunks are
available on the decoding end, no decoding needs to take place.
The final (m-k) chunks contain the parity coding necessary to reproduce any one of the original chunks.
Coding is done with respect to the chunk’s location within the encoded data. This means that each chunk’s sequence number is needed for correct reconstruction.
§Example
use zfec_rs::Fec;
let message = b"Message to be sent";
let fec = Fec::new(5, 8).unwrap();
let (mut encoded_chunks, padding) = fec.encode(&message[..]).unwrap();
encoded_chunks.remove(2);
let decoded_message = fec.decode(&encoded_chunks, padding).unwrap();
assert_eq!(message.to_vec(), decoded_message);Implementations§
Auto Trait Implementations§
impl Freeze for Fec
impl RefUnwindSafe for Fec
impl Send for Fec
impl Sync for Fec
impl Unpin for Fec
impl UnwindSafe for Fec
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