3 ms·
Thanks for finding that bug! In a way, Serde itself is all about extracting the metadata of a type and handling validation issues. However this is metadata is
by erickt 10y ago
Thanks for finding that bug!
In a way, Serde itself is all about extracting the metadata of a type and handling validation issues. However this is metadata is currently not exposed to end users. It's something I've thought about doing, but I haven't had a driving use case to help come up with a proper API for it. I don't think it'd be that hard to implement once we actually have a clear idea on what we want.
The code Serde generates though typically optimizes down into nearly the same code as a hand written serializer and deserializer. On my laptop, serde_json [1] serializes a particular micro-benchmark [2] that serializes as fast as a hand rolled serializer (416MB/s vs 414MB/s). In comparison, rapidjson serializes the same structure in 432MB/s. I didn't write a hand written deserializer, but serde_json is comparable to rapidjson (193MB/s vs 182MB/s).
So it may be fast enough that you might be able to just implement whatever you want by just using Serde directly without having to generate parsers.
[1]: https://github.com/serde-rs/json https://github.com/serde-rs/json
[2]: https://github.com/serde-rs/json/blob/master/json_tests/benches/bench_json.rs https://github.com/serde-rs/json/blob/master/json_tests/benc...
[3]: https://github.com/erickt/rust-serialization-benchmarks/tree/master/c%2B%2B https://github.com/erickt/rust-serialization-benchmarks/tree...