use num_traits::FromPrimitive;
use crate::Error;
use crate::error::ValueError;
use crate::ezsp::{Status, decision, policy};
crate::frame::parameters::frame!(
0x0056,
{ policy_id: u8 },
impl {
impl Command {
#[must_use]
pub fn new(policy_id: policy::Id) -> Self {
Self {
policy_id: policy_id.into(),
}
}
}
},
{ status: u8, decision_id: u8 } => Configuration(configuration)::GetPolicy,
impl {
impl TryFrom<Response> for decision::Id {
type Error = Error;
fn try_from(response: Response) -> Result<Self, Self::Error> {
match Status::from_u8(response.status).ok_or(response.status) {
Ok(Status::Success) => Self::from_u8(response.decision_id)
.ok_or_else(|| ValueError::DecisionId(response.decision_id).into()),
other => Err(other.into()),
}
}
}
}
);