Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

Crateserde

source ·
Expand description

Serde

Serde is a framework forserializing anddeserializing Rust datastructures efficiently and generically.

The Serde ecosystem consists of data structures that know how to serializeand deserialize themselves along with data formats that know how toserialize and deserialize other things. Serde provides the layer by whichthese two groups interact with each other, allowing any supported datastructure to be serialized and deserialized using any supported data format.

See the Serde websitehttps://serde.rs/ for additional documentation andusage examples.

Design

Where many other languages rely on runtime reflection for serializing data,Serde is instead built on Rust’s powerful trait system. A data structurethat knows how to serialize and deserialize itself is one that implementsSerde’sSerialize andDeserialize traits (or uses Serde’s deriveattribute to automatically generate implementations at compile time). Thisavoids any overhead of reflection or runtime type information. In fact inmany situations the interaction between data structure and data format canbe completely optimized away by the Rust compiler, leaving Serdeserialization to perform the same speed as a handwritten serializer for thespecific selection of data structure and data format.

Data formats

The following is a partial list of data formats that have been implementedfor Serde by the community.

  • JSON, the ubiquitous JavaScript Object Notation used by many HTTP APIs.
  • Postcard, a no_std and embedded-systems friendly compact binary format.
  • CBOR, a Concise Binary Object Representation designed for small messagesize without the need for version negotiation.
  • YAML, a self-proclaimed human-friendly configuration language that ain’tmarkup language.
  • MessagePack, an efficient binary format that resembles a compact JSON.
  • TOML, a minimal configuration format used byCargo.
  • Pickle, a format common in the Python world.
  • RON, a Rusty Object Notation.
  • BSON, the data storage and network transfer format used by MongoDB.
  • Avro, a binary format used within Apache Hadoop, with support for schemadefinition.
  • JSON5, a superset of JSON including some productions from ES5.
  • URL query strings, in the x-www-form-urlencoded format.
  • Starlark, the format used for describing build targets by the Bazel andBuck build systems.(serialization only)
  • Envy, a way to deserialize environment variables into Rust structs.(deserialization only)
  • Envy Store, a way to deserializeAWS Parameter Store parameters intoRust structs.(deserialization only)
  • S-expressions, the textual representation of code and data used by theLisp language family.
  • D-Bus’s binary wire format.
  • FlexBuffers, the schemaless cousin of Google’s FlatBuffers zero-copyserialization format.
  • Bencode, a simple binary format used in the BitTorrent protocol.
  • Token streams, for processing Rust procedural macro input.(deserialization only)
  • DynamoDB Items, the format used byrusoto_dynamodb to transfer data toand from DynamoDB.
  • Hjson, a syntax extension to JSON designed around human reading andediting.(deserialization only)

Modules

  • Generic data structure deserialization framework.
  • Generic data structure serialization framework.

Macros

Traits

  • Adata structure that can be deserialized from any data format supportedby Serde.
  • Adata format that can deserialize any data structure supported bySerde.
  • Adata structure that can be serialized into any data format supportedby Serde.
  • Adata format that can serialize any data structure supported by Serde.

Derive Macros

  • Derive macro available if serde is built withfeatures = ["derive"].
  • Derive macro available if serde is built withfeatures = ["derive"].

[8]ページ先頭

©2009-2025 Movatter.jp