doip_definitions/doip_payload/
action_code.rs1use crate::error::{Error, Result};
2
3#[cfg_attr(feature = "python-bindings", pyo3::pyclass(eq, eq_int))]
8#[derive(Clone, Copy, Debug, PartialEq)]
9pub enum ActionCode {
10 NoFurtherActionRequired = 0x00,
12
13 ReservedByIso13400_01 = 0x01,
15
16 ReservedByIso13400_02 = 0x02,
18
19 ReservedByIso13400_03 = 0x03,
21
22 ReservedByIso13400_04 = 0x04,
24
25 ReservedByIso13400_05 = 0x05,
27
28 ReservedByIso13400_06 = 0x06,
30
31 ReservedByIso13400_07 = 0x07,
33
34 ReservedByIso13400_08 = 0x08,
36
37 ReservedByIso13400_09 = 0x09,
39
40 ReservedByIso13400_0A = 0x0A,
42
43 ReservedByIso13400_0B = 0x0B,
45
46 ReservedByIso13400_0C = 0x0C,
48
49 ReservedByIso13400_0D = 0x0D,
51
52 ReservedByIso13400_0E = 0x0E,
54
55 ReservedByIso13400_0F = 0x0F,
57
58 RoutingActivationRequired = 0x10,
60}
61
62impl TryFrom<&u8> for ActionCode {
63 type Error = Error;
64
65 fn try_from(value: &u8) -> Result<Self> {
66 let val = *value;
67
68 match val {
69 v if v == ActionCode::NoFurtherActionRequired as u8 => {
70 Ok(ActionCode::NoFurtherActionRequired)
71 }
72 v if v == ActionCode::ReservedByIso13400_01 as u8 => {
73 Ok(ActionCode::ReservedByIso13400_01)
74 }
75 v if v == ActionCode::ReservedByIso13400_02 as u8 => {
76 Ok(ActionCode::ReservedByIso13400_02)
77 }
78 v if v == ActionCode::ReservedByIso13400_03 as u8 => {
79 Ok(ActionCode::ReservedByIso13400_03)
80 }
81 v if v == ActionCode::ReservedByIso13400_04 as u8 => {
82 Ok(ActionCode::ReservedByIso13400_04)
83 }
84 v if v == ActionCode::ReservedByIso13400_05 as u8 => {
85 Ok(ActionCode::ReservedByIso13400_05)
86 }
87 v if v == ActionCode::ReservedByIso13400_06 as u8 => {
88 Ok(ActionCode::ReservedByIso13400_06)
89 }
90 v if v == ActionCode::ReservedByIso13400_07 as u8 => {
91 Ok(ActionCode::ReservedByIso13400_07)
92 }
93 v if v == ActionCode::ReservedByIso13400_08 as u8 => {
94 Ok(ActionCode::ReservedByIso13400_08)
95 }
96 v if v == ActionCode::ReservedByIso13400_09 as u8 => {
97 Ok(ActionCode::ReservedByIso13400_09)
98 }
99 v if v == ActionCode::ReservedByIso13400_0A as u8 => {
100 Ok(ActionCode::ReservedByIso13400_0A)
101 }
102 v if v == ActionCode::ReservedByIso13400_0B as u8 => {
103 Ok(ActionCode::ReservedByIso13400_0B)
104 }
105 v if v == ActionCode::ReservedByIso13400_0C as u8 => {
106 Ok(ActionCode::ReservedByIso13400_0C)
107 }
108 v if v == ActionCode::ReservedByIso13400_0D as u8 => {
109 Ok(ActionCode::ReservedByIso13400_0D)
110 }
111 v if v == ActionCode::ReservedByIso13400_0E as u8 => {
112 Ok(ActionCode::ReservedByIso13400_0E)
113 }
114 v if v == ActionCode::ReservedByIso13400_0F as u8 => {
115 Ok(ActionCode::ReservedByIso13400_0F)
116 }
117 v if v == ActionCode::RoutingActivationRequired as u8 => {
118 Ok(ActionCode::RoutingActivationRequired)
119 }
120 v => Err(Error::InvalidActionCode { value: v }),
121 }
122 }
123}
124
125impl From<ActionCode> for u8 {
126 fn from(value: ActionCode) -> Self {
127 value as u8
128 }
129}