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