1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use teo_teon::types::enum_variant::EnumVariant;
use teo_teon::Value;
use teo_result::Error;
use teo_teon::types::option_variant::OptionVariant;
use crate::action::Action;
use crate::object::Object;

impl TryFrom<&Object> for Action {

    type Error = Error;

    fn try_from(value: &Object) -> std::result::Result<Self, Self::Error> {
        let teon: Value = value.try_into()?;
        let enum_variant: OptionVariant = teon.try_into()?;
        let int = enum_variant.value;
        Ok(Action(int as u32))
    }
}

impl TryFrom<Object> for Action {

    type Error = Error;

    fn try_from(ref value: Object) -> std::result::Result<Self, Self::Error> {
        let teon: Value = value.try_into()?;
        let enum_variant: OptionVariant = teon.try_into()?;
        let int = enum_variant.value;
        Ok(Action(int as u32))
    }
}

impl TryFrom<&Value> for Action {

    type Error = Error;

    fn try_from(value: &Value) -> std::result::Result<Self, Self::Error> {
        let enum_variant: &OptionVariant = value.try_into()?;
        let int = enum_variant.value;
        Ok(Action(int as u32))
    }
}