ezsp/frame/parameters/configuration/
read_attribute.rs1use le_stream::{FromLeStream, ToLeStream};
4use num_traits::FromPrimitive;
5
6use crate::Error;
7use crate::ember::Status;
8use crate::types::ByteSizedVec;
9
10crate::frame::parameters::frame!(
11 0x0108,
12 { endpoint: u8, cluster: u16, attribute_id: u16, mask: u8, manufacturer_code: u16 },
13 impl {
14 impl Command {
15 #[must_use]
17 pub const fn new(
18 endpoint: u8,
19 cluster: u16,
20 attribute_id: u16,
21 mask: u8,
22 manufacturer_code: u16,
23 ) -> Self {
24 Self {
25 endpoint,
26 cluster,
27 attribute_id,
28 mask,
29 manufacturer_code,
30 }
31 }
32 }
33 },
34 { status: u8, payload: Attribute } => Configuration(configuration)::ReadAttribute,
35 impl {
36 impl TryFrom<Response> for Attribute {
38 type Error = Error;
39
40 fn try_from(response: Response) -> Result<Self, Self::Error> {
41 match Status::from_u8(response.status).ok_or(response.status) {
42 Ok(Status::Success) => Ok(response.payload),
43 other => Err(other.into()),
44 }
45 }
46 }
47 }
48);
49
50#[derive(Clone, Debug, Eq, PartialEq, FromLeStream, ToLeStream)]
52pub struct Attribute {
53 data_type: u8,
54 data: ByteSizedVec<u8>,
55}
56
57impl Attribute {
58 #[must_use]
60 pub const fn data_type(&self) -> u8 {
61 self.data_type
62 }
63
64 #[must_use]
66 pub fn data(&self) -> &[u8] {
67 self.data.as_ref()
68 }
69}