from_value

Function from_value 

Source
pub fn from_value<'facet, T: Facet<'facet>>(
    value: Value,
) -> Result<T, ValueError>
Expand description

Deserialize a Value into any type implementing Facet.

This is the main entry point for converting a dynamic Value into a typed Rust value.

§Example

use facet::Facet;
use facet_value::{Value, from_value};

#[derive(Debug, Facet, PartialEq)]
struct Point {
    x: i32,
    y: i32,
}

let value = facet_value::value!({"x": 10, "y": 20});
let point: Point = from_value(value).unwrap();
assert_eq!(point, Point { x: 10, y: 20 });