[−][src]Module sval::serde
Integration between sval
and serde
.
Add the serde
feature to your Cargo.toml
to enable this module:
[dependencies.sval]
features = ["serde"]
In no-std environments, serde
support can be enabled using the serde_no_std
feature
instead:
[dependencies.sval]
features = ["serde_no_std"]
From sval
to serde
A type that implements sval::Value
can be converted into
a type that implements serde::Serialize
:
let my_serialize = sval::serde::to_serialize(my_value);
When using serde_no_std
, there are some limitations on what kinds of sval::Value
s you
can convert into serde::Serialize
s:
- Any type that uses
value::Stream::map_key_begin
,value::Stream::map_value_begin
, orvalue::Stream::seq_elem_begin
would require buffering, so will return an error instead in no-std environments.
From serde
to sval
A type that implements serde::Serialize
can be converted into
a type that implements sval::Value
:
let my_value = sval::serde::to_value(my_serialize);
Functions
serialize | Serialize a |
stream | |
to_serialize | |
to_value |