teo_runtime/value/convert/into/
struct_object.rs1use crate::r#struct;
2use teo_result::Error;
3use crate::value::Value;
4
5impl<'a> TryFrom<&'a Value> for &'a r#struct::Object {
6
7 type Error = Error;
8
9 fn try_from(value: &'a Value) -> std::result::Result<Self, Self::Error> {
10 match value.as_struct_object() {
11 Some(o) => Ok(o),
12 None => Err(Error::new(format!("object is not struct object: {:?}", value)))
13 }
14 }
15}
16
17impl TryFrom<&Value> for r#struct::Object {
18
19 type Error = Error;
20
21 fn try_from(value: &Value) -> std::result::Result<Self, Self::Error> {
22 match value.as_struct_object() {
23 Some(o) => Ok(o.clone()),
24 None => Err(Error::new(format!("object is not struct object: {:?}", value)))
25 }
26 }
27}
28
29impl TryFrom<Value> for r#struct::Object {
30
31 type Error = Error;
32
33 fn try_from(value: Value) -> std::result::Result<Self, Self::Error> {
34 match value.as_struct_object() {
35 Some(o) => Ok(o.clone()),
36 None => Err(Error::new(format!("object is not struct object: {:?}", value)))
37 }
38 }
39}