Skip to content

Commit 1db5b00

Browse files
committed
Rename misleading serde feature to iter-ext
The `serde` feature flag was misleading: the serde crate is an unconditional dependency, and the feature only gated the `iter_ext` module (par_map/try_par_map). Rename it to `iter-ext` to accurately reflect what it controls. Also fix inaccurate doc comments on run_bytes/try_run_bytes that referenced the non-existent serde feature gate.
1 parent f3129d9 commit 1db5b00

7 files changed

Lines changed: 14 additions & 15 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
features: ["--all-features", "--no-default-features --features serde,codec-pot"]
20+
features: ["--all-features", "--no-default-features --features iter-ext,codec-pot"]
2121

2222
steps:
2323
- uses: actions/checkout@v4
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
strategy:
3333
matrix:
34-
features: ["--all-features", "--no-default-features --features serde,macros,codec-pot"]
34+
features: ["--all-features", "--no-default-features --features iter-ext,macros,codec-pot"]
3535

3636
steps:
3737
- uses: actions/checkout@v4

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ readme = "README.md"
1111
keywords = ["webworker", "parallelism", "wasm"]
1212

1313
[workspace.dependencies]
14-
wasmworker = { version = "0.3", path = ".", features = ["serde", "macros"] }
14+
wasmworker = { version = "0.3", path = ".", features = ["iter-ext", "macros"] }
1515
wasmworker-proc-macro = { version = "0.3", path = "proc-macro" }
1616

1717
[package]
@@ -64,8 +64,8 @@ version = "0.3"
6464
wasmworker-proc-macro = { workspace = true }
6565

6666
[features]
67-
default = ["serde", "codec-postcard"]
68-
serde = []
67+
default = ["iter-ext", "codec-postcard"]
68+
iter-ext = []
6969
codec-postcard = ["dep:postcard"]
7070
codec-pot = ["dep:pot"]
7171
macros = ["wasmworker-proc-macro"]

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ Enable the `macros` feature to get access to the `#[webworker_fn]` and `#[webwor
3232
wasmworker = { version = "0.3", features = ["macros"] }
3333
```
3434

35-
The `wasmworker` crate comes with a default feature called `serde`, which allows running any function on a web worker under the following two conditions:
36-
1. The function takes a single argument, which implements `serde::Serialize + serde::Deserialize<'de>`.
37-
2. The return type implements `serde::Serialize + serde::Deserialize<'de>`.
35+
Function arguments and return types must implement `serde::Serialize + serde::Deserialize<'de>`.
36+
Alternatively, functions with the type `fn(Box<[u8]>) -> Box<[u8]>` can be used via `run_bytes()` for manual serialization.
3837

39-
Without the `serde` feature, only functions with the type `fn(Box<[u8]>) -> Box<[u8]>` can be run on a worker.
40-
This is useful for users that do not want a direct serde dependency. Internally, the library always uses serde, though.
38+
The `iter-ext` feature (enabled by default) adds the `par_map` and `try_par_map` iterator extensions for convenient parallel map operations on the default worker pool.
4139

4240
#### Serialization codec
4341
By default, `wasmworker` uses [postcard](https://crates.io/crates/postcard) for internal serialization.
@@ -48,7 +46,7 @@ Note that pot has significantly higher serialization overhead and larger output
4846

4947
```toml
5048
[dependencies]
51-
wasmworker = { version = "0.3", default-features = false, features = ["serde", "macros", "codec-pot"] }
49+
wasmworker = { version = "0.3", default-features = false, features = ["iter-ext", "macros", "codec-pot"] }
5250
```
5351

5452
You can then start using the library without further setup.

src/func.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct WebWorkerFn<T, R> {
1313
/// The worker will automatically add the `__webworker_` prefix.
1414
pub(crate) name: &'static str,
1515
/// The original function, which can be used as a fallback.
16+
#[cfg_attr(not(feature = "iter-ext"), allow(dead_code))]
1617
pub(crate) func: fn(T) -> R,
1718
}
1819

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub mod convert;
118118
pub mod error;
119119
pub mod func;
120120
mod global;
121-
#[cfg(feature = "serde")]
121+
#[cfg(feature = "iter-ext")]
122122
pub mod iter_ext;
123123
pub mod pool;
124124
mod webworker;

src/pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl WebWorkerPool {
318318

319319
/// This function can outsource a task on a [`WebWorkerPool`] which has `Box<[u8]>` both as input and output.
320320
/// (De)serialization of values needs to be handled by the caller.
321-
/// For more convenient access, make sure the `serde` feature is enabled and use [`WebWorkerPool::run`].
321+
/// For more convenient access, use [`WebWorkerPool::run`] instead.
322322
///
323323
/// The `func`: [`WebWorkerFn`] argument should normally be instantiated using the [`crate::webworker!`] macro.
324324
/// This ensures type safety and that the function is correctly exposed to the worker.

src/webworker/worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl WebWorker {
295295

296296
/// This function can outsource a task on a [`WebWorker`] which has `Box<[u8]>` both as input and output.
297297
/// (De)serialization of values needs to be handled by the caller.
298-
/// For more convenient access, make sure the `serde` feature is enabled and use [`WebWorker::run`].
298+
/// For more convenient access, use [`WebWorker::run`] instead.
299299
///
300300
/// The `func`: [`WebWorkerFn`] argument should normally be instantiated using the [`crate::webworker!`] macro.
301301
/// This ensures type safety and that the function is correctly exposed to the worker.
@@ -318,7 +318,7 @@ impl WebWorker {
318318
/// This function differs from [`WebWorker::run_bytes`] by returning early if the given task limit is reached.
319319
/// In this case a [`Full`] error is returned.
320320
/// (De)serialization of values needs to be handled by the caller.
321-
/// For more convenient access, make sure the `serde` feature is enabled and use [`WebWorker::try_run`].
321+
/// For more convenient access, use [`WebWorker::try_run`] instead.
322322
///
323323
/// The `func`: [`WebWorkerFn`] argument should normally be instantiated using the [`crate::webworker!`] macro.
324324
/// This ensures type safety and that the function is correctly exposed to the worker.

0 commit comments

Comments
 (0)