Function serde_dhall::from_str
source · [−]pub fn from_str(s: &str) -> Deserializer<'_, NoAnnot>
Expand description
Deserialize a value from a string of Dhall text.
This returns a Deserializer
object. Call the parse()
method to get the deserialized
value, or use other Deserializer
methods to control the deserialization process.
Imports will be resolved relative to the current directory.
Example
use serde::Deserialize;
// We use serde's derive feature
#[derive(Deserialize)]
struct Point {
x: u64,
y: u64,
}
// Some Dhall data
let data = "{ x = 1, y = 1 + 1 } : { x: Natural, y: Natural }";
// Parse the Dhall string as a Point.
let point: Point = serde_dhall::from_str(data).parse()?;
assert_eq!(point.x, 1);
assert_eq!(point.y, 2);