Skip to content

Commit

Permalink
Remove wasm support
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Nov 26, 2023
1 parent cd1df04 commit 36d8fe8
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 132 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ crate-type = ["lib"]
[dependencies]
serde = {version = "1.0.102", features=["std", "derive"], optional = true}
pyo3 = {version = "0.20", features=["extension-module", "abi3-py37"], optional = true }
wasm-bindgen = {version = "0.2", optional = true}
js-sys = {version = "0.3.60", optional = true}

[dev-dependencies]
criterion = "0.3"
Expand Down Expand Up @@ -57,4 +55,3 @@ benchmarking = ["std"]
python = ["pyo3", "std"]
serde_support = ["serde", "std"]
std = []
wasm = ["wasm-bindgen", "js-sys", "std"]
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ install_py: pre

test_py: install_py
python3 -m unittest discover

build_wasm: pre
wasm-pack build --target web --features wasm
37 changes: 0 additions & 37 deletions examples/index.html

This file was deleted.

12 changes: 6 additions & 6 deletions examples/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use rand::seq::SliceRandom;

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use rand::Rng;

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use raptorq::{Decoder, Encoder, EncodingPacket};

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
fn main() {
// Generate some random data to send
let mut data: Vec<u8> = vec![0; 10_000];
Expand Down Expand Up @@ -50,7 +50,7 @@ fn main() {
assert_eq!(result.unwrap(), data);
}

#[cfg(any(feature = "python", feature = "wasm"))]
#[cfg(feature = "python")]
fn main() {
panic!("This is not indented to compile for `python` and `wasm` features.");
panic!("This is not indented to compile for `python` feature.");
}
23 changes: 10 additions & 13 deletions src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ impl Decoder {
}
}

#[cfg(all(
any(test, feature = "benchmarking"),
not(any(feature = "python", feature = "wasm"))
))]
#[cfg(all(any(test, feature = "benchmarking"), not(feature = "python")))]
pub fn set_sparse_threshold(&mut self, value: u32) {
for block_decoder in self.block_decoders.iter_mut() {
block_decoder.set_sparse_threshold(value);
Expand Down Expand Up @@ -97,7 +94,7 @@ impl Decoder {
Some(result)
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
pub fn add_new_packet(&mut self, packet: EncodingPacket) {
let block_number = packet.payload_id.source_block_number() as usize;
if self.blocks[block_number].is_none() {
Expand All @@ -106,7 +103,7 @@ impl Decoder {
}
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
pub fn get_result(&self) -> Option<Vec<u8>> {
for block in self.blocks.iter() {
if block.is_none() {
Expand Down Expand Up @@ -349,14 +346,14 @@ impl SourceBlockDecoder {
#[cfg(feature = "std")]
#[cfg(test)]
mod codec_tests {
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use crate::Decoder;
use crate::SourceBlockEncoder;
use crate::SourceBlockEncodingPlan;
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use crate::{Encoder, EncoderBuilder};
use crate::{ObjectTransmissionInformation, SourceBlockDecoder};
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use rand::seq::SliceRandom;
use rand::Rng;
use std::{
Expand All @@ -368,19 +365,19 @@ mod codec_tests {
vec::Vec,
};

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn random_erasure_dense() {
random_erasure(99_999);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn random_erasure_sparse() {
random_erasure(0);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
fn random_erasure(sparse_threshold: u32) {
let elements: usize = rand::thread_rng().gen_range(1..1_000_000);
let mut data: Vec<u8> = vec![0; elements];
Expand Down Expand Up @@ -413,7 +410,7 @@ mod codec_tests {
assert_eq!(result.unwrap(), data);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn sub_block_erasure() {
let elements: usize = 10_000;
Expand Down
14 changes: 7 additions & 7 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ mod tests {
use crate::systematic_constants::{
calculate_p1, num_ldpc_symbols, systematic_index, MAX_SOURCE_SYMBOLS_PER_BLOCK,
};
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use crate::{Encoder, EncoderBuilder, EncodingPacket, ObjectTransmissionInformation};
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
use std::collections::HashSet;

const SYMBOL_SIZE: usize = 4;
Expand Down Expand Up @@ -555,7 +555,7 @@ mod tests {
}
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn test_builder() {
let data = vec![0, 1, 2, 3];
Expand All @@ -565,7 +565,7 @@ mod tests {
assert_eq!(builder.build(&data), encoder);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn padding_constraint_exact() {
let packet_size: u16 = 1024;
Expand All @@ -574,7 +574,7 @@ mod tests {
padding_constraint(packet_size, padding_size, data_size);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn padding_constraint_42_bytes() {
let packet_size: u16 = 1024;
Expand All @@ -583,7 +583,7 @@ mod tests {
padding_constraint(packet_size, padding_size, data_size);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
fn padding_constraint(packet_size: u16, padding_size: usize, data_size: usize) {
let data = gen_test_data(data_size);
let encoder = Encoder::with_defaults(&data, packet_size);
Expand All @@ -604,7 +604,7 @@ mod tests {
assert_eq!(data[..], padded_data[..data_size]);
}

#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
#[test]
fn unique_blocks() {
let data = gen_test_data(120);
Expand Down
10 changes: 2 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ mod sparse_vec;
mod symbol;
mod systematic_constants;
mod util;
#[cfg(feature = "wasm")]
mod wasm;

pub use crate::base::partition;
pub use crate::base::EncodingPacket;
pub use crate::base::ObjectTransmissionInformation;
pub use crate::base::PayloadId;
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
pub use crate::decoder::Decoder;
pub use crate::decoder::SourceBlockDecoder;
pub use crate::encoder::calculate_block_offsets;
#[cfg(not(any(feature = "python", feature = "wasm")))]
#[cfg(not(feature = "python"))]
pub use crate::encoder::Encoder;
pub use crate::encoder::EncoderBuilder;
pub use crate::encoder::SourceBlockEncoder;
Expand All @@ -57,10 +55,6 @@ pub use crate::python::Decoder;
#[cfg(feature = "python")]
pub use crate::python::Encoder;
pub use crate::systematic_constants::extended_source_block_symbols;
#[cfg(feature = "wasm")]
pub use crate::wasm::Decoder as WasmDecoder;
#[cfg(feature = "wasm")]
pub use crate::wasm::Encoder as WasmEncoder;

#[cfg(feature = "benchmarking")]
pub use crate::constraint_matrix::generate_constraint_matrix;
Expand Down
55 changes: 0 additions & 55 deletions src/wasm.rs

This file was deleted.

0 comments on commit 36d8fe8

Please sign in to comment.