Expand description
serde::Serialize
implementation for Valuable
types.
Valuable provides object-safe value inspection. Use cases include passing structured data to trait objects and object-safe serialization.
This crate provides a bridge between valuable
and the serde
serialization ecosystem. Using Serializable
allows any type
that implements valuable
’s Valuable
trait to be serialized by any
serde::ser::Serializer
.
§Examples
use valuable::Valuable;
use valuable_serde::Serializable;
#[derive(Valuable)]
struct Point {
x: i32,
y: i32,
}
let point = Point { x: 1, y: 2 };
let value = Serializable::new(&point);
assert_eq!(
serde_json::to_string(&value).unwrap(),
r#"{"x":1,"y":2}"#,
);