Deser是一个Rust序列化库项目,由作者于2022年启动,代表了对现有Serde库的替代性探索1。该项目采用完全不同的架构来解决Serde的设计局限,核心差异在于Deser使用格式驱动的事件模型,而Serde采用类型驱动的访问者模式1。
Deser的设计目标针对Sentry Relay在处理大量不可信JSON时遇到的问题1。该库通过格式驱动而非类型驱动的反序列化方式、避免栈递归以及支持更多自描述格式,旨在改进Serde的已知问题1。具体而言,Deser解决了Serde的三个核心设计问题:统一的trait集合、固定数据模型信息损失、以及调用栈递归1。
在支持的格式方面,Deser覆盖了JSON、JSONC、JSON5、HJSON、YAML 1.1/1.2、TOML、XML、CBOR、MessagePack、CSV/TSV等多种格式1。在性能表现上存在权衡:JSON反序列化比serde_json慢10%,编译后二进制大小增加2.3倍1。
A new experimental Rust serialization library called Deser has emerged as an alternative approach to the widely-used Serde framework 1. Launched in 2022, the project addresses fundamental architectural limitations in Serde's design by employing a format-driven event model rather than Serde's type-driven visitor pattern 1. The library was developed in response to challenges encountered by Sentry Relay when processing large volumes of untrusted JSON data 1.
Deser distinguishes itself through several key design innovations 1. Rather than relying on stack recursion, the new library implements a different approach to handle nested data structures 1. The project supports a substantially broader range of serialization formats compared to Serde, including JSON, JSONC, JSON5, HJSON, YAML 1.1 and 1.2, TOML, XML, CBOR, MessagePack, and CSV/TSV 1. These enhancements aim to resolve three core design challenges inherent in Serde: the reliance on a unified trait collection, information loss due to fixed data models, and recursive call stack overhead 1.
Performance and resource considerations reveal trade-offs in Deser's architecture 1. JSON deserialization operations run approximately 10% slower compared to serde_json, while compiled binaries increase in size by 2.3 times 1. Despite these trade-offs, the project maintains user experience considerations while attempting to improve upon Serde's recognized limitations 1.
评论
还没有评论,欢迎留下第一条。