#[cfg(not(feature = "python"))]
use rand::seq::SliceRandom;
#[cfg(not(feature = "python"))]
use rand::Rng;
#[cfg(not(feature = "python"))]
use raptorq::{Decoder, Encoder, EncodingPacket};
#[cfg(not(feature = "python"))]
fn main() {
let mut data: Vec<u8> = vec![0; 10_000];
for byte in data.iter_mut() {
*byte = rand::rng().random();
}
let encoder = Encoder::with_defaults(&data, 1400);
let mut packets: Vec<Vec<u8>> = encoder
.get_encoded_packets(15)
.iter()
.map(|packet| packet.serialize())
.collect();
packets.shuffle(&mut rand::rng());
let length = packets.len();
packets.truncate(length - 10);
let mut decoder = Decoder::new(encoder.get_config());
let mut result = None;
while !packets.is_empty() {
result = decoder.decode(EncodingPacket::deserialize(&packets.pop().unwrap()));
if result.is_some() {
break;
}
}
assert_eq!(result.unwrap(), data);
}
#[cfg(feature = "python")]
fn main() {
panic!("This is not indented to compile for `python` feature.");
}