Trait serde_dhall::ToDhall
source · [−]pub trait ToDhall: Sealed { }
Expand description
A data structure that can be serialized from a Dhall expression.
This is automatically implemented for any type that serde can serialize. In fact, this trait cannot be implemented manually. To implement it for your type, use serde’s derive mechanism.
Example
use serde::Serialize;
// Use serde's derive
#[derive(Serialize)]
struct Point {
x: u64,
y: u64,
}
// Convert a Point to a Dhall string.
let point = Point { x: 0, y: 0 };
let point_str = serde_dhall::serialize(&point).to_string()?;
assert_eq!(point_str, "{ x = 0, y = 0 }".to_string());