| Crates.io | openworkers-serde-v8 |
| lib.rs | openworkers-serde-v8 |
| version | 0.2.0 |
| created_at | 2026-01-17 11:54:02.776899+00 |
| updated_at | 2026-01-17 18:41:32.659194+00 |
| description | Rust to V8 serialization and deserialization for OpenWorkers |
| homepage | |
| repository | https://github.com/openworkers/serde-v8 |
| max_upload_size | |
| id | 2050303 |
| size | 154,353 |
Author: Aaron O'Mullan aaron.omullan@gmail.com
Serde support for encoding/decoding (rusty_)v8 values.
Broadly serde_v8 aims to provide an expressive but ~maximally efficient
encoding layer to biject rust & v8/js values. It's a core component of deno's
op-layer and is used to encode/decode all non-buffer values.
Original issue: denoland/deno#9540
serde_v8 fits naturally into the serde ecosystem, so if you've already used
serde or serde_json, serde_v8's API should be very familiar.
serde_v8 exposes two key-functions:
to_v8: maps rust->v8, similar to serde_json::to_string, ...from_v8: maps v8->rust, similar to serde_json::from_str, ...Whilst serde_v8 is compatible with serde_json::Value it's important to keep
in mind that serde_json::Value is essentially a loosely-typed value (think
nested HashMaps), so when writing ops we recommend directly using rust
structs/tuples or primitives, since mapping to serde_json::Value will add
extra overhead and result in slower ops.
I also recommend avoiding unnecessary "wrappers", if your op takes a single-keyed struct, consider unwrapping that as a plain value unless you plan to add fields in the near-future.
Instead of returning "nothing" via Ok(json!({})), change your return type to
rust's unit type () and returning Ok(()), serde_v8 will efficiently encode
that as a JS null.
serde_json (should be mostly
interchangeable)Payload type that's deserializable by itself (holds scope &
value).unwrap()s