serde support for V8's ValueSerializer format (used by Node.js/Deno's Serialization API) so you can easily send data between Rust & JS without resorting to JSON or non-native encoders/decoders.
Supports format versions 13-16 (Node.js v8.x+ and any Deno version that supports ValueSerializer). Serialization outputs version 15 (Node.js v18+) by default, but this can be configured.
serialize function (backed by DefaultSerializer) uses to serialize typed arrays. When serializing in JS, you must create a blank serializer:
// ❌ - won't work with `serde_v8vs`
import { serialize } from 'node:v8';
const bytes = serialize(new Uint8Array([ 1, 2, 3 ]));// ✅ - will work everywhere
import { Serializer } from 'node:v8';
function compatSerialize(value: any): Uint8Array {
const serializer = new Serializer();
serializer.writeHeader();
serializer.writeValue(value);
return serializer.releaseBuffer();
}
const bytes = compatSerialize(new Uint8Array([ 1, 2, 3 ]));serde_bytesjiff- Supports
jiff::Timestamp, requires Cargo feature v0.2:features = [ "jiff-0_2" ]
- Supports
chrono- Supports
chrono::DateTime<Utc>, requires Cargo feature v0.4:features = [ "chrono-0_4" ]
- Supports