Home

serde

Serde is a Rust framework for serializing and deserializing data structures. It provides a generic, efficient way to convert Rust data to and from various data formats, enabling the same types to be used across different interchanges such as JSON, YAML, TOML, CBOR, MessagePack, and more. The design separates the data model from the wire format, allowing formats to be swapped with no changes to the core data definitions.

The core of Serde consists of two traits: Serialize and Deserialize. Types implement these traits to enable

Customization and flexibility are supported through a variety of attributes on struct and enum fields. These

Serde is widely used in the Rust ecosystem for configuration, data exchange in APIs, and persistence. It

conversion
to
and
from
data
formats.
Implementations
can
be
written
manually
or
generated
automatically
through
derive
macros
(#[derive(Serialize,
Deserialize)])
provided
by
the
serde_derive
crate,
commonly
used
via
feature
flags.
The
actual
format-specific
serialization
and
deserialization
are
carried
out
by
separate
crates
(for
example,
serde_json,
serde_yaml,
serde_toml,
serde_cbor,
serde_bincode)
that
implement
the
Serializer
and
Deserializer
traits
for
their
respective
formats.
include
renaming
fields,
skipping
values,
providing
defaults,
using
with
to
customize
serialization
logic
for
particular
fields,
and
flatten
to
merge
nested
structures.
Serde
relies
on
compile-time
code
generation
and
a
Visitor-based
deserialization
approach,
avoiding
runtime
reflection.
is
an
open-source
project
available
on
crates.io
and
hosted
on
GitHub,
with
dual
licensing
under
MIT
and
Apache-2.0.