1#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23 ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26pub const ID: ClusterId = 0x0752;
28
29pub const REVISION: u16 = 1;
32
33pub const PICS: &str = "JFDS";
35
36pub const FEATURES: &[Feature] = &[];
38
39pub mod attribute {
41 use crate::im::AttributeId;
42
43 pub const ANCHOR_ROOT_CA: AttributeId = 0x00;
45 pub const ANCHOR_NODE_ID: AttributeId = 0x01;
47 pub const ANCHOR_VENDOR_ID: AttributeId = 0x02;
49 pub const FRIENDLY_NAME: AttributeId = 0x03;
51 pub const GROUP_KEY_SET_LIST: AttributeId = 0x04;
53 pub const GROUP_LIST: AttributeId = 0x05;
55 pub const NODE_LIST: AttributeId = 0x06;
57 pub const ADMIN_LIST: AttributeId = 0x07;
59 pub const STATUS: AttributeId = 0x08;
61 pub const ENDPOINT_GROUP_ID_LIST: AttributeId = 0x09;
63 pub const ENDPOINT_BINDING_LIST: AttributeId = 0x0A;
65 pub const NODE_KEY_SET_LIST: AttributeId = 0x0B;
67 pub const NODE_ACL_LIST: AttributeId = 0x0C;
69 pub const NODE_ENDPOINT_LIST: AttributeId = 0x0D;
71}
72
73pub mod command {
75 use crate::im::CommandId;
76
77 pub const ADD_KEY_SET: CommandId = 0x00;
79 pub const UPDATE_KEY_SET: CommandId = 0x01;
81 pub const REMOVE_KEY_SET: CommandId = 0x02;
83 pub const ADD_GROUP: CommandId = 0x03;
85 pub const UPDATE_GROUP: CommandId = 0x04;
87 pub const REMOVE_GROUP: CommandId = 0x05;
89 pub const ADD_ADMIN: CommandId = 0x06;
91 pub const UPDATE_ADMIN: CommandId = 0x07;
93 pub const REMOVE_ADMIN: CommandId = 0x08;
95 pub const ADD_PENDING_NODE: CommandId = 0x09;
97 pub const REFRESH_NODE: CommandId = 0x0A;
99 pub const UPDATE_NODE: CommandId = 0x0B;
101 pub const REMOVE_NODE: CommandId = 0x0C;
103 pub const UPDATE_ENDPOINT_FOR_NODE: CommandId = 0x0D;
105 pub const ADD_GROUP_ID_TO_ENDPOINT_FOR_NODE: CommandId = 0x0E;
107 pub const REMOVE_GROUP_ID_FROM_ENDPOINT_FOR_NODE: CommandId = 0x0F;
109 pub const ADD_BINDING_TO_ENDPOINT_FOR_NODE: CommandId = 0x10;
111 pub const REMOVE_BINDING_FROM_ENDPOINT_FOR_NODE: CommandId = 0x11;
113 pub const ADD_ACL_TO_NODE: CommandId = 0x12;
115 pub const REMOVE_ACL_FROM_NODE: CommandId = 0x13;
117}
118
119#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
121#[repr(u8)]
122pub enum DatastoreAccessControlEntryAuthModeEnum {
123 PASE = 1,
125 CASE = 2,
127 Group = 3,
129}
130
131impl DatastoreAccessControlEntryAuthModeEnum {
132 #[must_use]
134 pub const fn from_value(value: u8) -> Option<Self> {
135 match value {
136 1 => Some(Self::PASE),
137 2 => Some(Self::CASE),
138 3 => Some(Self::Group),
139 _ => None,
140 }
141 }
142
143 #[must_use]
145 pub const fn value(self) -> u8 {
146 self as u8
147 }
148}
149
150impl ToTlv for DatastoreAccessControlEntryAuthModeEnum {
151 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
152 self.value().to_tlv(w, tag)
153 }
154}
155
156impl<'a> FromTlv<'a> for DatastoreAccessControlEntryAuthModeEnum {
157 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
158 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
159 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
160 }
161}
162
163#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
165#[repr(u8)]
166pub enum DatastoreAccessControlEntryPrivilegeEnum {
167 View = 1,
169 Operate = 3,
171 Manage = 4,
173 Administer = 5,
175}
176
177impl DatastoreAccessControlEntryPrivilegeEnum {
178 #[must_use]
180 pub const fn from_value(value: u8) -> Option<Self> {
181 match value {
182 1 => Some(Self::View),
183 3 => Some(Self::Operate),
184 4 => Some(Self::Manage),
185 5 => Some(Self::Administer),
186 _ => None,
187 }
188 }
189
190 #[must_use]
192 pub const fn value(self) -> u8 {
193 self as u8
194 }
195}
196
197impl ToTlv for DatastoreAccessControlEntryPrivilegeEnum {
198 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
199 self.value().to_tlv(w, tag)
200 }
201}
202
203impl<'a> FromTlv<'a> for DatastoreAccessControlEntryPrivilegeEnum {
204 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
205 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
206 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
207 }
208}
209
210#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
212#[repr(u8)]
213pub enum DatastoreGroupKeyMulticastPolicyEnum {
214 PerGroupID = 0,
216 AllNodes = 1,
218}
219
220impl DatastoreGroupKeyMulticastPolicyEnum {
221 #[must_use]
223 pub const fn from_value(value: u8) -> Option<Self> {
224 match value {
225 0 => Some(Self::PerGroupID),
226 1 => Some(Self::AllNodes),
227 _ => None,
228 }
229 }
230
231 #[must_use]
233 pub const fn value(self) -> u8 {
234 self as u8
235 }
236}
237
238impl ToTlv for DatastoreGroupKeyMulticastPolicyEnum {
239 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
240 self.value().to_tlv(w, tag)
241 }
242}
243
244impl<'a> FromTlv<'a> for DatastoreGroupKeyMulticastPolicyEnum {
245 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
246 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
247 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
248 }
249}
250
251#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
253#[repr(u8)]
254pub enum DatastoreGroupKeySecurityPolicyEnum {
255 TrustFirst = 0,
257}
258
259impl DatastoreGroupKeySecurityPolicyEnum {
260 #[must_use]
262 pub const fn from_value(value: u8) -> Option<Self> {
263 match value {
264 0 => Some(Self::TrustFirst),
265 _ => None,
266 }
267 }
268
269 #[must_use]
271 pub const fn value(self) -> u8 {
272 self as u8
273 }
274}
275
276impl ToTlv for DatastoreGroupKeySecurityPolicyEnum {
277 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
278 self.value().to_tlv(w, tag)
279 }
280}
281
282impl<'a> FromTlv<'a> for DatastoreGroupKeySecurityPolicyEnum {
283 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
284 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
285 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
286 }
287}
288
289#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
291#[repr(u8)]
292pub enum DatastoreStateEnum {
293 Pending = 0,
295 Committed = 1,
297 DeletePending = 2,
299 CommitFailed = 3,
301}
302
303impl DatastoreStateEnum {
304 #[must_use]
306 pub const fn from_value(value: u8) -> Option<Self> {
307 match value {
308 0 => Some(Self::Pending),
309 1 => Some(Self::Committed),
310 2 => Some(Self::DeletePending),
311 3 => Some(Self::CommitFailed),
312 _ => None,
313 }
314 }
315
316 #[must_use]
318 pub const fn value(self) -> u8 {
319 self as u8
320 }
321}
322
323impl ToTlv for DatastoreStateEnum {
324 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
325 self.value().to_tlv(w, tag)
326 }
327}
328
329impl<'a> FromTlv<'a> for DatastoreStateEnum {
330 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
331 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
332 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
333 }
334}
335
336#[derive(Debug, Clone, Copy, PartialEq)]
338pub struct DatastoreACLEntryStruct<'a> {
339 pub node_id: crate::msg::NodeId,
341 pub list_id: u16,
343 pub acl_entry: DatastoreAccessControlEntryStruct<'a>,
345 pub status_entry: DatastoreStatusEntryStruct,
347}
348
349impl<'a> ToTlv for DatastoreACLEntryStruct<'a> {
350 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
351 w.start_structure(tag)?;
352 self.node_id.to_tlv(w, Tag::Context(0))?;
353 self.list_id.to_tlv(w, Tag::Context(1))?;
354 self.acl_entry.to_tlv(w, Tag::Context(2))?;
355 self.status_entry.to_tlv(w, Tag::Context(3))?;
356 w.end_container()
357 }
358}
359
360impl<'a> FromTlv<'a> for DatastoreACLEntryStruct<'a> {
361 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
362 if element.value.container() != Some(ContainerKind::Structure) {
363 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
364 }
365 let mut node_id = None;
366 let mut list_id = None;
367 let mut acl_entry = None;
368 let mut status_entry = None;
369 loop {
370 let Some(field) = reader.next_element()? else {
371 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
372 };
373 if field.value == Value::EndOfContainer {
374 break;
375 }
376 match field.tag.context() {
377 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
378 Some(1) => list_id = Some(<u16>::from_tlv(reader, &field)?),
379 Some(2) => {
380 acl_entry = Some(<DatastoreAccessControlEntryStruct<'a>>::from_tlv(
381 reader, &field,
382 )?)
383 }
384 Some(3) => {
385 status_entry = Some(<DatastoreStatusEntryStruct>::from_tlv(reader, &field)?)
386 }
387 _ => reader.skip_value(&field)?,
391 }
392 }
393 Ok(Self {
394 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
395 list_id: list_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
396 acl_entry: acl_entry.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
397 status_entry: status_entry.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
398 })
399 }
400}
401
402#[derive(Debug, Clone, Copy, PartialEq)]
404pub struct DatastoreAccessControlEntryStruct<'a> {
405 pub privilege: DatastoreAccessControlEntryPrivilegeEnum,
407 pub auth_mode: DatastoreAccessControlEntryAuthModeEnum,
409 pub subjects: Nullable<TlvList<'a, u64>>,
411 pub targets: Nullable<TlvList<'a, DatastoreAccessControlTargetStruct>>,
413}
414
415impl<'a> ToTlv for DatastoreAccessControlEntryStruct<'a> {
416 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
417 w.start_structure(tag)?;
418 self.privilege.to_tlv(w, Tag::Context(1))?;
419 self.auth_mode.to_tlv(w, Tag::Context(2))?;
420 self.subjects.to_tlv(w, Tag::Context(3))?;
421 self.targets.to_tlv(w, Tag::Context(4))?;
422 w.end_container()
423 }
424}
425
426impl<'a> FromTlv<'a> for DatastoreAccessControlEntryStruct<'a> {
427 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
428 if element.value.container() != Some(ContainerKind::Structure) {
429 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
430 }
431 let mut privilege = None;
432 let mut auth_mode = None;
433 let mut subjects = None;
434 let mut targets = None;
435 loop {
436 let Some(field) = reader.next_element()? else {
437 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
438 };
439 if field.value == Value::EndOfContainer {
440 break;
441 }
442 match field.tag.context() {
443 Some(1) => {
444 privilege = Some(<DatastoreAccessControlEntryPrivilegeEnum>::from_tlv(
445 reader, &field,
446 )?)
447 }
448 Some(2) => {
449 auth_mode = Some(<DatastoreAccessControlEntryAuthModeEnum>::from_tlv(
450 reader, &field,
451 )?)
452 }
453 Some(3) => subjects = Some(<Nullable<TlvList<'a, u64>>>::from_tlv(reader, &field)?),
454 Some(4) => {
455 targets = Some(
456 <Nullable<TlvList<'a, DatastoreAccessControlTargetStruct>>>::from_tlv(
457 reader, &field,
458 )?,
459 )
460 }
461 _ => reader.skip_value(&field)?,
465 }
466 }
467 Ok(Self {
468 privilege: privilege.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
469 auth_mode: auth_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
470 subjects: subjects.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
471 targets: targets.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
472 })
473 }
474}
475
476#[derive(Debug, Clone, Copy, PartialEq)]
478pub struct DatastoreAccessControlTargetStruct {
479 pub cluster: Nullable<u32>,
481 pub endpoint: Nullable<u16>,
483 pub device_type: Nullable<u32>,
485}
486
487impl ToTlv for DatastoreAccessControlTargetStruct {
488 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
489 w.start_structure(tag)?;
490 self.cluster.to_tlv(w, Tag::Context(0))?;
491 self.endpoint.to_tlv(w, Tag::Context(1))?;
492 self.device_type.to_tlv(w, Tag::Context(2))?;
493 w.end_container()
494 }
495}
496
497impl<'a> FromTlv<'a> for DatastoreAccessControlTargetStruct {
498 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
499 if element.value.container() != Some(ContainerKind::Structure) {
500 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
501 }
502 let mut cluster = None;
503 let mut endpoint = None;
504 let mut device_type = None;
505 loop {
506 let Some(field) = reader.next_element()? else {
507 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
508 };
509 if field.value == Value::EndOfContainer {
510 break;
511 }
512 match field.tag.context() {
513 Some(0) => cluster = Some(<Nullable<u32>>::from_tlv(reader, &field)?),
514 Some(1) => endpoint = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
515 Some(2) => device_type = Some(<Nullable<u32>>::from_tlv(reader, &field)?),
516 _ => reader.skip_value(&field)?,
520 }
521 }
522 Ok(Self {
523 cluster: cluster.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
524 endpoint: endpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
525 device_type: device_type.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
526 })
527 }
528}
529
530#[derive(Debug, Clone, Copy, PartialEq)]
532pub struct DatastoreAdministratorInformationEntryStruct<'a> {
533 pub node_id: crate::msg::NodeId,
535 pub friendly_name: &'a str,
537 pub vendor_id: crate::msg::VendorId,
539 pub icac: &'a [u8],
541}
542
543impl<'a> ToTlv for DatastoreAdministratorInformationEntryStruct<'a> {
544 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
545 w.start_structure(tag)?;
546 self.node_id.to_tlv(w, Tag::Context(0))?;
547 self.friendly_name.to_tlv(w, Tag::Context(1))?;
548 self.vendor_id.to_tlv(w, Tag::Context(2))?;
549 self.icac.to_tlv(w, Tag::Context(3))?;
550 w.end_container()
551 }
552}
553
554impl<'a> FromTlv<'a> for DatastoreAdministratorInformationEntryStruct<'a> {
555 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
556 if element.value.container() != Some(ContainerKind::Structure) {
557 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
558 }
559 let mut node_id = None;
560 let mut friendly_name = None;
561 let mut vendor_id = None;
562 let mut icac = None;
563 loop {
564 let Some(field) = reader.next_element()? else {
565 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
566 };
567 if field.value == Value::EndOfContainer {
568 break;
569 }
570 match field.tag.context() {
571 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
572 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
573 Some(2) => vendor_id = Some(<crate::msg::VendorId>::from_tlv(reader, &field)?),
574 Some(3) => icac = Some(<&'a [u8]>::from_tlv(reader, &field)?),
575 _ => reader.skip_value(&field)?,
579 }
580 }
581 Ok(Self {
582 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
583 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
584 vendor_id: vendor_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
585 icac: icac.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
586 })
587 }
588}
589
590#[derive(Debug, Clone, Copy, PartialEq)]
592pub struct DatastoreBindingTargetStruct {
593 pub node: Option<crate::msg::NodeId>,
595 pub group: Option<crate::msg::GroupId>,
597 pub endpoint: Option<u16>,
599 pub cluster: Option<u32>,
601}
602
603impl ToTlv for DatastoreBindingTargetStruct {
604 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
605 w.start_structure(tag)?;
606 if let Some(value) = &self.node {
607 value.to_tlv(w, Tag::Context(1))?;
608 }
609 if let Some(value) = &self.group {
610 value.to_tlv(w, Tag::Context(2))?;
611 }
612 if let Some(value) = &self.endpoint {
613 value.to_tlv(w, Tag::Context(3))?;
614 }
615 if let Some(value) = &self.cluster {
616 value.to_tlv(w, Tag::Context(4))?;
617 }
618 w.end_container()
619 }
620}
621
622impl<'a> FromTlv<'a> for DatastoreBindingTargetStruct {
623 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
624 if element.value.container() != Some(ContainerKind::Structure) {
625 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
626 }
627 let mut node = None;
628 let mut group = None;
629 let mut endpoint = None;
630 let mut cluster = None;
631 loop {
632 let Some(field) = reader.next_element()? else {
633 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
634 };
635 if field.value == Value::EndOfContainer {
636 break;
637 }
638 match field.tag.context() {
639 Some(1) => node = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
640 Some(2) => group = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
641 Some(3) => endpoint = Some(<u16>::from_tlv(reader, &field)?),
642 Some(4) => cluster = Some(<u32>::from_tlv(reader, &field)?),
643 _ => reader.skip_value(&field)?,
647 }
648 }
649 Ok(Self {
650 node,
651 group,
652 endpoint,
653 cluster,
654 })
655 }
656}
657
658#[derive(Debug, Clone, Copy, PartialEq)]
660pub struct DatastoreEndpointBindingEntryStruct {
661 pub node_id: crate::msg::NodeId,
663 pub endpoint_id: u16,
665 pub list_id: u16,
667 pub binding: DatastoreBindingTargetStruct,
669 pub status_entry: DatastoreStatusEntryStruct,
671}
672
673impl ToTlv for DatastoreEndpointBindingEntryStruct {
674 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
675 w.start_structure(tag)?;
676 self.node_id.to_tlv(w, Tag::Context(0))?;
677 self.endpoint_id.to_tlv(w, Tag::Context(1))?;
678 self.list_id.to_tlv(w, Tag::Context(2))?;
679 self.binding.to_tlv(w, Tag::Context(3))?;
680 self.status_entry.to_tlv(w, Tag::Context(4))?;
681 w.end_container()
682 }
683}
684
685impl<'a> FromTlv<'a> for DatastoreEndpointBindingEntryStruct {
686 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
687 if element.value.container() != Some(ContainerKind::Structure) {
688 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
689 }
690 let mut node_id = None;
691 let mut endpoint_id = None;
692 let mut list_id = None;
693 let mut binding = None;
694 let mut status_entry = None;
695 loop {
696 let Some(field) = reader.next_element()? else {
697 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
698 };
699 if field.value == Value::EndOfContainer {
700 break;
701 }
702 match field.tag.context() {
703 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
704 Some(1) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
705 Some(2) => list_id = Some(<u16>::from_tlv(reader, &field)?),
706 Some(3) => {
707 binding = Some(<DatastoreBindingTargetStruct>::from_tlv(reader, &field)?)
708 }
709 Some(4) => {
710 status_entry = Some(<DatastoreStatusEntryStruct>::from_tlv(reader, &field)?)
711 }
712 _ => reader.skip_value(&field)?,
716 }
717 }
718 Ok(Self {
719 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
720 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
721 list_id: list_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
722 binding: binding.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
723 status_entry: status_entry.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
724 })
725 }
726}
727
728#[derive(Debug, Clone, Copy, PartialEq)]
730pub struct DatastoreEndpointEntryStruct<'a> {
731 pub endpoint_id: u16,
733 pub node_id: crate::msg::NodeId,
735 pub friendly_name: &'a str,
737}
738
739impl<'a> ToTlv for DatastoreEndpointEntryStruct<'a> {
740 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
741 w.start_structure(tag)?;
742 self.endpoint_id.to_tlv(w, Tag::Context(0))?;
743 self.node_id.to_tlv(w, Tag::Context(1))?;
744 self.friendly_name.to_tlv(w, Tag::Context(2))?;
745 w.end_container()
746 }
747}
748
749impl<'a> FromTlv<'a> for DatastoreEndpointEntryStruct<'a> {
750 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
751 if element.value.container() != Some(ContainerKind::Structure) {
752 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
753 }
754 let mut endpoint_id = None;
755 let mut node_id = None;
756 let mut friendly_name = None;
757 loop {
758 let Some(field) = reader.next_element()? else {
759 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
760 };
761 if field.value == Value::EndOfContainer {
762 break;
763 }
764 match field.tag.context() {
765 Some(0) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
766 Some(1) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
767 Some(2) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
768 _ => reader.skip_value(&field)?,
772 }
773 }
774 Ok(Self {
775 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
776 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
777 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
778 })
779 }
780}
781
782#[derive(Debug, Clone, Copy, PartialEq)]
784pub struct DatastoreEndpointGroupIDEntryStruct {
785 pub node_id: crate::msg::NodeId,
787 pub endpoint_id: u16,
789 pub group_id: crate::msg::GroupId,
791 pub status_entry: DatastoreStatusEntryStruct,
793}
794
795impl ToTlv for DatastoreEndpointGroupIDEntryStruct {
796 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
797 w.start_structure(tag)?;
798 self.node_id.to_tlv(w, Tag::Context(0))?;
799 self.endpoint_id.to_tlv(w, Tag::Context(1))?;
800 self.group_id.to_tlv(w, Tag::Context(2))?;
801 self.status_entry.to_tlv(w, Tag::Context(3))?;
802 w.end_container()
803 }
804}
805
806impl<'a> FromTlv<'a> for DatastoreEndpointGroupIDEntryStruct {
807 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
808 if element.value.container() != Some(ContainerKind::Structure) {
809 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
810 }
811 let mut node_id = None;
812 let mut endpoint_id = None;
813 let mut group_id = None;
814 let mut status_entry = None;
815 loop {
816 let Some(field) = reader.next_element()? else {
817 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
818 };
819 if field.value == Value::EndOfContainer {
820 break;
821 }
822 match field.tag.context() {
823 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
824 Some(1) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
825 Some(2) => group_id = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
826 Some(3) => {
827 status_entry = Some(<DatastoreStatusEntryStruct>::from_tlv(reader, &field)?)
828 }
829 _ => reader.skip_value(&field)?,
833 }
834 }
835 Ok(Self {
836 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
837 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
838 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
839 status_entry: status_entry.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
840 })
841 }
842}
843
844#[derive(Debug, Clone, Copy, PartialEq)]
846pub struct DatastoreGroupInformationEntryStruct<'a> {
847 pub group_id: u64,
849 pub friendly_name: &'a str,
851 pub group_key_set_id: Nullable<u16>,
853 pub group_cat: Nullable<u16>,
855 pub group_cat_version: Nullable<u16>,
857 pub group_permission: DatastoreAccessControlEntryPrivilegeEnum,
859}
860
861impl<'a> ToTlv for DatastoreGroupInformationEntryStruct<'a> {
862 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
863 w.start_structure(tag)?;
864 self.group_id.to_tlv(w, Tag::Context(0))?;
865 self.friendly_name.to_tlv(w, Tag::Context(1))?;
866 self.group_key_set_id.to_tlv(w, Tag::Context(2))?;
867 self.group_cat.to_tlv(w, Tag::Context(3))?;
868 self.group_cat_version.to_tlv(w, Tag::Context(4))?;
869 self.group_permission.to_tlv(w, Tag::Context(5))?;
870 w.end_container()
871 }
872}
873
874impl<'a> FromTlv<'a> for DatastoreGroupInformationEntryStruct<'a> {
875 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
876 if element.value.container() != Some(ContainerKind::Structure) {
877 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
878 }
879 let mut group_id = None;
880 let mut friendly_name = None;
881 let mut group_key_set_id = None;
882 let mut group_cat = None;
883 let mut group_cat_version = None;
884 let mut group_permission = None;
885 loop {
886 let Some(field) = reader.next_element()? else {
887 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
888 };
889 if field.value == Value::EndOfContainer {
890 break;
891 }
892 match field.tag.context() {
893 Some(0) => group_id = Some(<u64>::from_tlv(reader, &field)?),
894 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
895 Some(2) => group_key_set_id = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
896 Some(3) => group_cat = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
897 Some(4) => group_cat_version = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
898 Some(5) => {
899 group_permission = Some(<DatastoreAccessControlEntryPrivilegeEnum>::from_tlv(
900 reader, &field,
901 )?)
902 }
903 _ => reader.skip_value(&field)?,
907 }
908 }
909 Ok(Self {
910 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
911 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
912 group_key_set_id: group_key_set_id
913 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
914 group_cat: group_cat.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
915 group_cat_version: group_cat_version
916 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
917 group_permission: group_permission
918 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
919 })
920 }
921}
922
923#[derive(Debug, Clone, Copy, PartialEq)]
925pub struct DatastoreGroupKeySetStruct<'a> {
926 pub group_key_set_id: u16,
928 pub group_key_security_policy: DatastoreGroupKeySecurityPolicyEnum,
930 pub epoch_key0: Nullable<&'a [u8]>,
932 pub epoch_start_time0: Nullable<u64>,
934 pub epoch_key1: Nullable<&'a [u8]>,
936 pub epoch_start_time1: Nullable<u64>,
938 pub epoch_key2: Nullable<&'a [u8]>,
940 pub epoch_start_time2: Nullable<u64>,
942 pub group_key_multicast_policy: Option<DatastoreGroupKeyMulticastPolicyEnum>,
944}
945
946impl<'a> ToTlv for DatastoreGroupKeySetStruct<'a> {
947 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
948 w.start_structure(tag)?;
949 self.group_key_set_id.to_tlv(w, Tag::Context(0))?;
950 self.group_key_security_policy.to_tlv(w, Tag::Context(1))?;
951 self.epoch_key0.to_tlv(w, Tag::Context(2))?;
952 self.epoch_start_time0.to_tlv(w, Tag::Context(3))?;
953 self.epoch_key1.to_tlv(w, Tag::Context(4))?;
954 self.epoch_start_time1.to_tlv(w, Tag::Context(5))?;
955 self.epoch_key2.to_tlv(w, Tag::Context(6))?;
956 self.epoch_start_time2.to_tlv(w, Tag::Context(7))?;
957 if let Some(value) = &self.group_key_multicast_policy {
958 value.to_tlv(w, Tag::Context(8))?;
959 }
960 w.end_container()
961 }
962}
963
964impl<'a> FromTlv<'a> for DatastoreGroupKeySetStruct<'a> {
965 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
966 if element.value.container() != Some(ContainerKind::Structure) {
967 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
968 }
969 let mut group_key_set_id = None;
970 let mut group_key_security_policy = None;
971 let mut epoch_key0 = None;
972 let mut epoch_start_time0 = None;
973 let mut epoch_key1 = None;
974 let mut epoch_start_time1 = None;
975 let mut epoch_key2 = None;
976 let mut epoch_start_time2 = None;
977 let mut group_key_multicast_policy = None;
978 loop {
979 let Some(field) = reader.next_element()? else {
980 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
981 };
982 if field.value == Value::EndOfContainer {
983 break;
984 }
985 match field.tag.context() {
986 Some(0) => group_key_set_id = Some(<u16>::from_tlv(reader, &field)?),
987 Some(1) => {
988 group_key_security_policy = Some(
989 <DatastoreGroupKeySecurityPolicyEnum>::from_tlv(reader, &field)?,
990 )
991 }
992 Some(2) => epoch_key0 = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
993 Some(3) => epoch_start_time0 = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
994 Some(4) => epoch_key1 = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
995 Some(5) => epoch_start_time1 = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
996 Some(6) => epoch_key2 = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
997 Some(7) => epoch_start_time2 = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
998 Some(8) => {
999 group_key_multicast_policy = Some(
1000 <DatastoreGroupKeyMulticastPolicyEnum>::from_tlv(reader, &field)?,
1001 )
1002 }
1003 _ => reader.skip_value(&field)?,
1007 }
1008 }
1009 Ok(Self {
1010 group_key_set_id: group_key_set_id
1011 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1012 group_key_security_policy: group_key_security_policy
1013 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1014 epoch_key0: epoch_key0.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1015 epoch_start_time0: epoch_start_time0
1016 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1017 epoch_key1: epoch_key1.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1018 epoch_start_time1: epoch_start_time1
1019 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1020 epoch_key2: epoch_key2.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1021 epoch_start_time2: epoch_start_time2
1022 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1023 group_key_multicast_policy,
1024 })
1025 }
1026}
1027
1028#[derive(Debug, Clone, Copy, PartialEq)]
1030pub struct DatastoreNodeInformationEntryStruct<'a> {
1031 pub node_id: crate::msg::NodeId,
1033 pub friendly_name: &'a str,
1035 pub commissioning_status_entry: DatastoreStatusEntryStruct,
1037}
1038
1039impl<'a> ToTlv for DatastoreNodeInformationEntryStruct<'a> {
1040 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1041 w.start_structure(tag)?;
1042 self.node_id.to_tlv(w, Tag::Context(0))?;
1043 self.friendly_name.to_tlv(w, Tag::Context(1))?;
1044 self.commissioning_status_entry.to_tlv(w, Tag::Context(2))?;
1045 w.end_container()
1046 }
1047}
1048
1049impl<'a> FromTlv<'a> for DatastoreNodeInformationEntryStruct<'a> {
1050 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1051 if element.value.container() != Some(ContainerKind::Structure) {
1052 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1053 }
1054 let mut node_id = None;
1055 let mut friendly_name = None;
1056 let mut commissioning_status_entry = None;
1057 loop {
1058 let Some(field) = reader.next_element()? else {
1059 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1060 };
1061 if field.value == Value::EndOfContainer {
1062 break;
1063 }
1064 match field.tag.context() {
1065 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1066 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1067 Some(2) => {
1068 commissioning_status_entry =
1069 Some(<DatastoreStatusEntryStruct>::from_tlv(reader, &field)?)
1070 }
1071 _ => reader.skip_value(&field)?,
1075 }
1076 }
1077 Ok(Self {
1078 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1079 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1080 commissioning_status_entry: commissioning_status_entry
1081 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1082 })
1083 }
1084}
1085
1086#[derive(Debug, Clone, Copy, PartialEq)]
1088pub struct DatastoreNodeKeySetEntryStruct {
1089 pub node_id: crate::msg::NodeId,
1091 pub group_key_set_id: u16,
1093 pub status_entry: DatastoreStatusEntryStruct,
1095}
1096
1097impl ToTlv for DatastoreNodeKeySetEntryStruct {
1098 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1099 w.start_structure(tag)?;
1100 self.node_id.to_tlv(w, Tag::Context(0))?;
1101 self.group_key_set_id.to_tlv(w, Tag::Context(1))?;
1102 self.status_entry.to_tlv(w, Tag::Context(2))?;
1103 w.end_container()
1104 }
1105}
1106
1107impl<'a> FromTlv<'a> for DatastoreNodeKeySetEntryStruct {
1108 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1109 if element.value.container() != Some(ContainerKind::Structure) {
1110 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1111 }
1112 let mut node_id = None;
1113 let mut group_key_set_id = None;
1114 let mut status_entry = None;
1115 loop {
1116 let Some(field) = reader.next_element()? else {
1117 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1118 };
1119 if field.value == Value::EndOfContainer {
1120 break;
1121 }
1122 match field.tag.context() {
1123 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1124 Some(1) => group_key_set_id = Some(<u16>::from_tlv(reader, &field)?),
1125 Some(2) => {
1126 status_entry = Some(<DatastoreStatusEntryStruct>::from_tlv(reader, &field)?)
1127 }
1128 _ => reader.skip_value(&field)?,
1132 }
1133 }
1134 Ok(Self {
1135 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1136 group_key_set_id: group_key_set_id
1137 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1138 status_entry: status_entry.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1139 })
1140 }
1141}
1142
1143#[derive(Debug, Clone, Copy, PartialEq)]
1145pub struct DatastoreStatusEntryStruct {
1146 pub state: DatastoreStateEnum,
1148 pub update_timestamp: u32,
1150 pub failure_code: u8,
1152}
1153
1154impl ToTlv for DatastoreStatusEntryStruct {
1155 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1156 w.start_structure(tag)?;
1157 self.state.to_tlv(w, Tag::Context(0))?;
1158 self.update_timestamp.to_tlv(w, Tag::Context(1))?;
1159 self.failure_code.to_tlv(w, Tag::Context(2))?;
1160 w.end_container()
1161 }
1162}
1163
1164impl<'a> FromTlv<'a> for DatastoreStatusEntryStruct {
1165 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1166 if element.value.container() != Some(ContainerKind::Structure) {
1167 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1168 }
1169 let mut state = None;
1170 let mut update_timestamp = None;
1171 let mut failure_code = None;
1172 loop {
1173 let Some(field) = reader.next_element()? else {
1174 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1175 };
1176 if field.value == Value::EndOfContainer {
1177 break;
1178 }
1179 match field.tag.context() {
1180 Some(0) => state = Some(<DatastoreStateEnum>::from_tlv(reader, &field)?),
1181 Some(1) => update_timestamp = Some(<u32>::from_tlv(reader, &field)?),
1182 Some(2) => failure_code = Some(<u8>::from_tlv(reader, &field)?),
1183 _ => reader.skip_value(&field)?,
1187 }
1188 }
1189 Ok(Self {
1190 state: state.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1191 update_timestamp: update_timestamp
1192 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1193 failure_code: failure_code.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1194 })
1195 }
1196}
1197
1198#[derive(Debug, Clone, Copy, PartialEq)]
1200pub struct AddKeySetFields<'a> {
1201 pub group_key_set: DatastoreGroupKeySetStruct<'a>,
1203}
1204
1205impl<'a> ToTlv for AddKeySetFields<'a> {
1206 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1207 w.start_structure(tag)?;
1208 self.group_key_set.to_tlv(w, Tag::Context(0))?;
1209 w.end_container()
1210 }
1211}
1212
1213impl<'a> FromTlv<'a> for AddKeySetFields<'a> {
1214 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1215 if element.value.container() != Some(ContainerKind::Structure) {
1216 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1217 }
1218 let mut group_key_set = None;
1219 loop {
1220 let Some(field) = reader.next_element()? else {
1221 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1222 };
1223 if field.value == Value::EndOfContainer {
1224 break;
1225 }
1226 match field.tag.context() {
1227 Some(0) => {
1228 group_key_set =
1229 Some(<DatastoreGroupKeySetStruct<'a>>::from_tlv(reader, &field)?)
1230 }
1231 _ => reader.skip_value(&field)?,
1235 }
1236 }
1237 Ok(Self {
1238 group_key_set: group_key_set.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1239 })
1240 }
1241}
1242
1243#[derive(Debug, Clone, Copy, PartialEq)]
1245pub struct UpdateKeySetFields<'a> {
1246 pub group_key_set: DatastoreGroupKeySetStruct<'a>,
1248}
1249
1250impl<'a> ToTlv for UpdateKeySetFields<'a> {
1251 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1252 w.start_structure(tag)?;
1253 self.group_key_set.to_tlv(w, Tag::Context(0))?;
1254 w.end_container()
1255 }
1256}
1257
1258impl<'a> FromTlv<'a> for UpdateKeySetFields<'a> {
1259 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1260 if element.value.container() != Some(ContainerKind::Structure) {
1261 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1262 }
1263 let mut group_key_set = None;
1264 loop {
1265 let Some(field) = reader.next_element()? else {
1266 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1267 };
1268 if field.value == Value::EndOfContainer {
1269 break;
1270 }
1271 match field.tag.context() {
1272 Some(0) => {
1273 group_key_set =
1274 Some(<DatastoreGroupKeySetStruct<'a>>::from_tlv(reader, &field)?)
1275 }
1276 _ => reader.skip_value(&field)?,
1280 }
1281 }
1282 Ok(Self {
1283 group_key_set: group_key_set.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1284 })
1285 }
1286}
1287
1288#[derive(Debug, Clone, Copy, PartialEq)]
1290pub struct RemoveKeySetFields {
1291 pub group_key_set_id: u16,
1293}
1294
1295impl ToTlv for RemoveKeySetFields {
1296 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1297 w.start_structure(tag)?;
1298 self.group_key_set_id.to_tlv(w, Tag::Context(0))?;
1299 w.end_container()
1300 }
1301}
1302
1303impl<'a> FromTlv<'a> for RemoveKeySetFields {
1304 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1305 if element.value.container() != Some(ContainerKind::Structure) {
1306 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1307 }
1308 let mut group_key_set_id = None;
1309 loop {
1310 let Some(field) = reader.next_element()? else {
1311 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1312 };
1313 if field.value == Value::EndOfContainer {
1314 break;
1315 }
1316 match field.tag.context() {
1317 Some(0) => group_key_set_id = Some(<u16>::from_tlv(reader, &field)?),
1318 _ => reader.skip_value(&field)?,
1322 }
1323 }
1324 Ok(Self {
1325 group_key_set_id: group_key_set_id
1326 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1327 })
1328 }
1329}
1330
1331#[derive(Debug, Clone, Copy, PartialEq)]
1333pub struct AddGroupFields<'a> {
1334 pub group_id: crate::msg::GroupId,
1336 pub friendly_name: &'a str,
1338 pub group_key_set_id: Nullable<u16>,
1340 pub group_cat: Nullable<u16>,
1342 pub group_cat_version: Nullable<u16>,
1344 pub group_permission: DatastoreAccessControlEntryPrivilegeEnum,
1346}
1347
1348impl<'a> ToTlv for AddGroupFields<'a> {
1349 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1350 w.start_structure(tag)?;
1351 self.group_id.to_tlv(w, Tag::Context(0))?;
1352 self.friendly_name.to_tlv(w, Tag::Context(1))?;
1353 self.group_key_set_id.to_tlv(w, Tag::Context(2))?;
1354 self.group_cat.to_tlv(w, Tag::Context(3))?;
1355 self.group_cat_version.to_tlv(w, Tag::Context(4))?;
1356 self.group_permission.to_tlv(w, Tag::Context(5))?;
1357 w.end_container()
1358 }
1359}
1360
1361impl<'a> FromTlv<'a> for AddGroupFields<'a> {
1362 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1363 if element.value.container() != Some(ContainerKind::Structure) {
1364 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1365 }
1366 let mut group_id = None;
1367 let mut friendly_name = None;
1368 let mut group_key_set_id = None;
1369 let mut group_cat = None;
1370 let mut group_cat_version = None;
1371 let mut group_permission = None;
1372 loop {
1373 let Some(field) = reader.next_element()? else {
1374 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1375 };
1376 if field.value == Value::EndOfContainer {
1377 break;
1378 }
1379 match field.tag.context() {
1380 Some(0) => group_id = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
1381 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1382 Some(2) => group_key_set_id = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1383 Some(3) => group_cat = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1384 Some(4) => group_cat_version = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1385 Some(5) => {
1386 group_permission = Some(<DatastoreAccessControlEntryPrivilegeEnum>::from_tlv(
1387 reader, &field,
1388 )?)
1389 }
1390 _ => reader.skip_value(&field)?,
1394 }
1395 }
1396 Ok(Self {
1397 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1398 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1399 group_key_set_id: group_key_set_id
1400 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1401 group_cat: group_cat.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1402 group_cat_version: group_cat_version
1403 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1404 group_permission: group_permission
1405 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1406 })
1407 }
1408}
1409
1410#[derive(Debug, Clone, Copy, PartialEq)]
1412pub struct UpdateGroupFields<'a> {
1413 pub group_id: crate::msg::GroupId,
1415 pub friendly_name: Nullable<&'a str>,
1417 pub group_key_set_id: Nullable<u16>,
1419 pub group_cat: Nullable<u16>,
1421 pub group_cat_version: Nullable<u16>,
1423 pub group_permission: Nullable<DatastoreAccessControlEntryPrivilegeEnum>,
1425}
1426
1427impl<'a> ToTlv for UpdateGroupFields<'a> {
1428 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1429 w.start_structure(tag)?;
1430 self.group_id.to_tlv(w, Tag::Context(0))?;
1431 self.friendly_name.to_tlv(w, Tag::Context(1))?;
1432 self.group_key_set_id.to_tlv(w, Tag::Context(2))?;
1433 self.group_cat.to_tlv(w, Tag::Context(3))?;
1434 self.group_cat_version.to_tlv(w, Tag::Context(4))?;
1435 self.group_permission.to_tlv(w, Tag::Context(5))?;
1436 w.end_container()
1437 }
1438}
1439
1440impl<'a> FromTlv<'a> for UpdateGroupFields<'a> {
1441 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1442 if element.value.container() != Some(ContainerKind::Structure) {
1443 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1444 }
1445 let mut group_id = None;
1446 let mut friendly_name = None;
1447 let mut group_key_set_id = None;
1448 let mut group_cat = None;
1449 let mut group_cat_version = None;
1450 let mut group_permission = None;
1451 loop {
1452 let Some(field) = reader.next_element()? else {
1453 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1454 };
1455 if field.value == Value::EndOfContainer {
1456 break;
1457 }
1458 match field.tag.context() {
1459 Some(0) => group_id = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
1460 Some(1) => friendly_name = Some(<Nullable<&'a str>>::from_tlv(reader, &field)?),
1461 Some(2) => group_key_set_id = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1462 Some(3) => group_cat = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1463 Some(4) => group_cat_version = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1464 Some(5) => {
1465 group_permission = Some(
1466 <Nullable<DatastoreAccessControlEntryPrivilegeEnum>>::from_tlv(
1467 reader, &field,
1468 )?,
1469 )
1470 }
1471 _ => reader.skip_value(&field)?,
1475 }
1476 }
1477 Ok(Self {
1478 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1479 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1480 group_key_set_id: group_key_set_id
1481 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1482 group_cat: group_cat.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1483 group_cat_version: group_cat_version
1484 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1485 group_permission: group_permission
1486 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1487 })
1488 }
1489}
1490
1491#[derive(Debug, Clone, Copy, PartialEq)]
1493pub struct RemoveGroupFields {
1494 pub group_id: crate::msg::GroupId,
1496}
1497
1498impl ToTlv for RemoveGroupFields {
1499 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1500 w.start_structure(tag)?;
1501 self.group_id.to_tlv(w, Tag::Context(0))?;
1502 w.end_container()
1503 }
1504}
1505
1506impl<'a> FromTlv<'a> for RemoveGroupFields {
1507 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1508 if element.value.container() != Some(ContainerKind::Structure) {
1509 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1510 }
1511 let mut group_id = None;
1512 loop {
1513 let Some(field) = reader.next_element()? else {
1514 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1515 };
1516 if field.value == Value::EndOfContainer {
1517 break;
1518 }
1519 match field.tag.context() {
1520 Some(0) => group_id = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
1521 _ => reader.skip_value(&field)?,
1525 }
1526 }
1527 Ok(Self {
1528 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1529 })
1530 }
1531}
1532
1533#[derive(Debug, Clone, Copy, PartialEq)]
1535pub struct AddAdminFields<'a> {
1536 pub node_id: crate::msg::NodeId,
1538 pub friendly_name: &'a str,
1540 pub vendor_id: crate::msg::VendorId,
1542 pub icac: &'a [u8],
1544}
1545
1546impl<'a> ToTlv for AddAdminFields<'a> {
1547 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1548 w.start_structure(tag)?;
1549 self.node_id.to_tlv(w, Tag::Context(0))?;
1550 self.friendly_name.to_tlv(w, Tag::Context(1))?;
1551 self.vendor_id.to_tlv(w, Tag::Context(2))?;
1552 self.icac.to_tlv(w, Tag::Context(3))?;
1553 w.end_container()
1554 }
1555}
1556
1557impl<'a> FromTlv<'a> for AddAdminFields<'a> {
1558 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1559 if element.value.container() != Some(ContainerKind::Structure) {
1560 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1561 }
1562 let mut node_id = None;
1563 let mut friendly_name = None;
1564 let mut vendor_id = None;
1565 let mut icac = None;
1566 loop {
1567 let Some(field) = reader.next_element()? else {
1568 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1569 };
1570 if field.value == Value::EndOfContainer {
1571 break;
1572 }
1573 match field.tag.context() {
1574 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1575 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1576 Some(2) => vendor_id = Some(<crate::msg::VendorId>::from_tlv(reader, &field)?),
1577 Some(3) => icac = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1578 _ => reader.skip_value(&field)?,
1582 }
1583 }
1584 Ok(Self {
1585 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1586 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1587 vendor_id: vendor_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1588 icac: icac.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1589 })
1590 }
1591}
1592
1593#[derive(Debug, Clone, Copy, PartialEq)]
1595pub struct UpdateAdminFields<'a> {
1596 pub node_id: crate::msg::NodeId,
1598 pub friendly_name: Option<&'a str>,
1600 pub icac: Option<&'a [u8]>,
1602}
1603
1604impl<'a> ToTlv for UpdateAdminFields<'a> {
1605 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1606 w.start_structure(tag)?;
1607 self.node_id.to_tlv(w, Tag::Context(0))?;
1608 if let Some(value) = &self.friendly_name {
1609 value.to_tlv(w, Tag::Context(1))?;
1610 }
1611 if let Some(value) = &self.icac {
1612 value.to_tlv(w, Tag::Context(2))?;
1613 }
1614 w.end_container()
1615 }
1616}
1617
1618impl<'a> FromTlv<'a> for UpdateAdminFields<'a> {
1619 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1620 if element.value.container() != Some(ContainerKind::Structure) {
1621 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1622 }
1623 let mut node_id = None;
1624 let mut friendly_name = None;
1625 let mut icac = None;
1626 loop {
1627 let Some(field) = reader.next_element()? else {
1628 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1629 };
1630 if field.value == Value::EndOfContainer {
1631 break;
1632 }
1633 match field.tag.context() {
1634 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1635 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1636 Some(2) => icac = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1637 _ => reader.skip_value(&field)?,
1641 }
1642 }
1643 Ok(Self {
1644 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1645 friendly_name,
1646 icac,
1647 })
1648 }
1649}
1650
1651#[derive(Debug, Clone, Copy, PartialEq)]
1653pub struct RemoveAdminFields {
1654 pub node_id: crate::msg::NodeId,
1656}
1657
1658impl ToTlv for RemoveAdminFields {
1659 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1660 w.start_structure(tag)?;
1661 self.node_id.to_tlv(w, Tag::Context(0))?;
1662 w.end_container()
1663 }
1664}
1665
1666impl<'a> FromTlv<'a> for RemoveAdminFields {
1667 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1668 if element.value.container() != Some(ContainerKind::Structure) {
1669 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1670 }
1671 let mut node_id = None;
1672 loop {
1673 let Some(field) = reader.next_element()? else {
1674 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1675 };
1676 if field.value == Value::EndOfContainer {
1677 break;
1678 }
1679 match field.tag.context() {
1680 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1681 _ => reader.skip_value(&field)?,
1685 }
1686 }
1687 Ok(Self {
1688 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1689 })
1690 }
1691}
1692
1693#[derive(Debug, Clone, Copy, PartialEq)]
1695pub struct AddPendingNodeFields<'a> {
1696 pub node_id: crate::msg::NodeId,
1698 pub friendly_name: &'a str,
1700}
1701
1702impl<'a> ToTlv for AddPendingNodeFields<'a> {
1703 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1704 w.start_structure(tag)?;
1705 self.node_id.to_tlv(w, Tag::Context(0))?;
1706 self.friendly_name.to_tlv(w, Tag::Context(1))?;
1707 w.end_container()
1708 }
1709}
1710
1711impl<'a> FromTlv<'a> for AddPendingNodeFields<'a> {
1712 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1713 if element.value.container() != Some(ContainerKind::Structure) {
1714 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1715 }
1716 let mut node_id = None;
1717 let mut friendly_name = None;
1718 loop {
1719 let Some(field) = reader.next_element()? else {
1720 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1721 };
1722 if field.value == Value::EndOfContainer {
1723 break;
1724 }
1725 match field.tag.context() {
1726 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1727 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1728 _ => reader.skip_value(&field)?,
1732 }
1733 }
1734 Ok(Self {
1735 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1736 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1737 })
1738 }
1739}
1740
1741#[derive(Debug, Clone, Copy, PartialEq)]
1743pub struct RefreshNodeFields {
1744 pub node_id: crate::msg::NodeId,
1746}
1747
1748impl ToTlv for RefreshNodeFields {
1749 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1750 w.start_structure(tag)?;
1751 self.node_id.to_tlv(w, Tag::Context(0))?;
1752 w.end_container()
1753 }
1754}
1755
1756impl<'a> FromTlv<'a> for RefreshNodeFields {
1757 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1758 if element.value.container() != Some(ContainerKind::Structure) {
1759 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1760 }
1761 let mut node_id = None;
1762 loop {
1763 let Some(field) = reader.next_element()? else {
1764 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1765 };
1766 if field.value == Value::EndOfContainer {
1767 break;
1768 }
1769 match field.tag.context() {
1770 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1771 _ => reader.skip_value(&field)?,
1775 }
1776 }
1777 Ok(Self {
1778 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1779 })
1780 }
1781}
1782
1783#[derive(Debug, Clone, Copy, PartialEq)]
1785pub struct UpdateNodeFields<'a> {
1786 pub node_id: crate::msg::NodeId,
1788 pub friendly_name: &'a str,
1790}
1791
1792impl<'a> ToTlv for UpdateNodeFields<'a> {
1793 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1794 w.start_structure(tag)?;
1795 self.node_id.to_tlv(w, Tag::Context(0))?;
1796 self.friendly_name.to_tlv(w, Tag::Context(1))?;
1797 w.end_container()
1798 }
1799}
1800
1801impl<'a> FromTlv<'a> for UpdateNodeFields<'a> {
1802 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1803 if element.value.container() != Some(ContainerKind::Structure) {
1804 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1805 }
1806 let mut node_id = None;
1807 let mut friendly_name = None;
1808 loop {
1809 let Some(field) = reader.next_element()? else {
1810 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1811 };
1812 if field.value == Value::EndOfContainer {
1813 break;
1814 }
1815 match field.tag.context() {
1816 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1817 Some(1) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1818 _ => reader.skip_value(&field)?,
1822 }
1823 }
1824 Ok(Self {
1825 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1826 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1827 })
1828 }
1829}
1830
1831#[derive(Debug, Clone, Copy, PartialEq)]
1833pub struct RemoveNodeFields {
1834 pub node_id: crate::msg::NodeId,
1836}
1837
1838impl ToTlv for RemoveNodeFields {
1839 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1840 w.start_structure(tag)?;
1841 self.node_id.to_tlv(w, Tag::Context(0))?;
1842 w.end_container()
1843 }
1844}
1845
1846impl<'a> FromTlv<'a> for RemoveNodeFields {
1847 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1848 if element.value.container() != Some(ContainerKind::Structure) {
1849 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1850 }
1851 let mut node_id = None;
1852 loop {
1853 let Some(field) = reader.next_element()? else {
1854 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1855 };
1856 if field.value == Value::EndOfContainer {
1857 break;
1858 }
1859 match field.tag.context() {
1860 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1861 _ => reader.skip_value(&field)?,
1865 }
1866 }
1867 Ok(Self {
1868 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1869 })
1870 }
1871}
1872
1873#[derive(Debug, Clone, Copy, PartialEq)]
1875pub struct UpdateEndpointForNodeFields<'a> {
1876 pub endpoint_id: u16,
1878 pub node_id: crate::msg::NodeId,
1880 pub friendly_name: &'a str,
1882}
1883
1884impl<'a> ToTlv for UpdateEndpointForNodeFields<'a> {
1885 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1886 w.start_structure(tag)?;
1887 self.endpoint_id.to_tlv(w, Tag::Context(0))?;
1888 self.node_id.to_tlv(w, Tag::Context(1))?;
1889 self.friendly_name.to_tlv(w, Tag::Context(2))?;
1890 w.end_container()
1891 }
1892}
1893
1894impl<'a> FromTlv<'a> for UpdateEndpointForNodeFields<'a> {
1895 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1896 if element.value.container() != Some(ContainerKind::Structure) {
1897 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1898 }
1899 let mut endpoint_id = None;
1900 let mut node_id = None;
1901 let mut friendly_name = None;
1902 loop {
1903 let Some(field) = reader.next_element()? else {
1904 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1905 };
1906 if field.value == Value::EndOfContainer {
1907 break;
1908 }
1909 match field.tag.context() {
1910 Some(0) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
1911 Some(1) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1912 Some(2) => friendly_name = Some(<&'a str>::from_tlv(reader, &field)?),
1913 _ => reader.skip_value(&field)?,
1917 }
1918 }
1919 Ok(Self {
1920 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1921 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1922 friendly_name: friendly_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1923 })
1924 }
1925}
1926
1927#[derive(Debug, Clone, Copy, PartialEq)]
1929pub struct AddGroupIDToEndpointForNodeFields {
1930 pub node_id: crate::msg::NodeId,
1932 pub endpoint_id: u16,
1934 pub group_id: crate::msg::GroupId,
1936}
1937
1938impl ToTlv for AddGroupIDToEndpointForNodeFields {
1939 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1940 w.start_structure(tag)?;
1941 self.node_id.to_tlv(w, Tag::Context(0))?;
1942 self.endpoint_id.to_tlv(w, Tag::Context(1))?;
1943 self.group_id.to_tlv(w, Tag::Context(2))?;
1944 w.end_container()
1945 }
1946}
1947
1948impl<'a> FromTlv<'a> for AddGroupIDToEndpointForNodeFields {
1949 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1950 if element.value.container() != Some(ContainerKind::Structure) {
1951 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1952 }
1953 let mut node_id = None;
1954 let mut endpoint_id = None;
1955 let mut group_id = None;
1956 loop {
1957 let Some(field) = reader.next_element()? else {
1958 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1959 };
1960 if field.value == Value::EndOfContainer {
1961 break;
1962 }
1963 match field.tag.context() {
1964 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
1965 Some(1) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
1966 Some(2) => group_id = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
1967 _ => reader.skip_value(&field)?,
1971 }
1972 }
1973 Ok(Self {
1974 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1975 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1976 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1977 })
1978 }
1979}
1980
1981#[derive(Debug, Clone, Copy, PartialEq)]
1983pub struct RemoveGroupIDFromEndpointForNodeFields {
1984 pub node_id: crate::msg::NodeId,
1986 pub endpoint_id: u16,
1988 pub group_id: crate::msg::GroupId,
1990}
1991
1992impl ToTlv for RemoveGroupIDFromEndpointForNodeFields {
1993 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1994 w.start_structure(tag)?;
1995 self.node_id.to_tlv(w, Tag::Context(0))?;
1996 self.endpoint_id.to_tlv(w, Tag::Context(1))?;
1997 self.group_id.to_tlv(w, Tag::Context(2))?;
1998 w.end_container()
1999 }
2000}
2001
2002impl<'a> FromTlv<'a> for RemoveGroupIDFromEndpointForNodeFields {
2003 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
2004 if element.value.container() != Some(ContainerKind::Structure) {
2005 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
2006 }
2007 let mut node_id = None;
2008 let mut endpoint_id = None;
2009 let mut group_id = None;
2010 loop {
2011 let Some(field) = reader.next_element()? else {
2012 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
2013 };
2014 if field.value == Value::EndOfContainer {
2015 break;
2016 }
2017 match field.tag.context() {
2018 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
2019 Some(1) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
2020 Some(2) => group_id = Some(<crate::msg::GroupId>::from_tlv(reader, &field)?),
2021 _ => reader.skip_value(&field)?,
2025 }
2026 }
2027 Ok(Self {
2028 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2029 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2030 group_id: group_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2031 })
2032 }
2033}
2034
2035#[derive(Debug, Clone, Copy, PartialEq)]
2037pub struct AddBindingToEndpointForNodeFields {
2038 pub node_id: crate::msg::NodeId,
2040 pub endpoint_id: u16,
2042 pub binding: DatastoreBindingTargetStruct,
2044}
2045
2046impl ToTlv for AddBindingToEndpointForNodeFields {
2047 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
2048 w.start_structure(tag)?;
2049 self.node_id.to_tlv(w, Tag::Context(0))?;
2050 self.endpoint_id.to_tlv(w, Tag::Context(1))?;
2051 self.binding.to_tlv(w, Tag::Context(2))?;
2052 w.end_container()
2053 }
2054}
2055
2056impl<'a> FromTlv<'a> for AddBindingToEndpointForNodeFields {
2057 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
2058 if element.value.container() != Some(ContainerKind::Structure) {
2059 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
2060 }
2061 let mut node_id = None;
2062 let mut endpoint_id = None;
2063 let mut binding = None;
2064 loop {
2065 let Some(field) = reader.next_element()? else {
2066 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
2067 };
2068 if field.value == Value::EndOfContainer {
2069 break;
2070 }
2071 match field.tag.context() {
2072 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
2073 Some(1) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
2074 Some(2) => {
2075 binding = Some(<DatastoreBindingTargetStruct>::from_tlv(reader, &field)?)
2076 }
2077 _ => reader.skip_value(&field)?,
2081 }
2082 }
2083 Ok(Self {
2084 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2085 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2086 binding: binding.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2087 })
2088 }
2089}
2090
2091#[derive(Debug, Clone, Copy, PartialEq)]
2093pub struct RemoveBindingFromEndpointForNodeFields {
2094 pub list_id: u16,
2096 pub endpoint_id: u16,
2098 pub node_id: crate::msg::NodeId,
2100}
2101
2102impl ToTlv for RemoveBindingFromEndpointForNodeFields {
2103 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
2104 w.start_structure(tag)?;
2105 self.list_id.to_tlv(w, Tag::Context(0))?;
2106 self.endpoint_id.to_tlv(w, Tag::Context(1))?;
2107 self.node_id.to_tlv(w, Tag::Context(2))?;
2108 w.end_container()
2109 }
2110}
2111
2112impl<'a> FromTlv<'a> for RemoveBindingFromEndpointForNodeFields {
2113 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
2114 if element.value.container() != Some(ContainerKind::Structure) {
2115 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
2116 }
2117 let mut list_id = None;
2118 let mut endpoint_id = None;
2119 let mut node_id = None;
2120 loop {
2121 let Some(field) = reader.next_element()? else {
2122 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
2123 };
2124 if field.value == Value::EndOfContainer {
2125 break;
2126 }
2127 match field.tag.context() {
2128 Some(0) => list_id = Some(<u16>::from_tlv(reader, &field)?),
2129 Some(1) => endpoint_id = Some(<u16>::from_tlv(reader, &field)?),
2130 Some(2) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
2131 _ => reader.skip_value(&field)?,
2135 }
2136 }
2137 Ok(Self {
2138 list_id: list_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2139 endpoint_id: endpoint_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2140 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2141 })
2142 }
2143}
2144
2145#[derive(Debug, Clone, Copy, PartialEq)]
2147pub struct AddACLToNodeFields<'a> {
2148 pub node_id: crate::msg::NodeId,
2150 pub acl_entry: DatastoreAccessControlEntryStruct<'a>,
2152}
2153
2154impl<'a> ToTlv for AddACLToNodeFields<'a> {
2155 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
2156 w.start_structure(tag)?;
2157 self.node_id.to_tlv(w, Tag::Context(0))?;
2158 self.acl_entry.to_tlv(w, Tag::Context(1))?;
2159 w.end_container()
2160 }
2161}
2162
2163impl<'a> FromTlv<'a> for AddACLToNodeFields<'a> {
2164 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
2165 if element.value.container() != Some(ContainerKind::Structure) {
2166 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
2167 }
2168 let mut node_id = None;
2169 let mut acl_entry = None;
2170 loop {
2171 let Some(field) = reader.next_element()? else {
2172 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
2173 };
2174 if field.value == Value::EndOfContainer {
2175 break;
2176 }
2177 match field.tag.context() {
2178 Some(0) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
2179 Some(1) => {
2180 acl_entry = Some(<DatastoreAccessControlEntryStruct<'a>>::from_tlv(
2181 reader, &field,
2182 )?)
2183 }
2184 _ => reader.skip_value(&field)?,
2188 }
2189 }
2190 Ok(Self {
2191 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2192 acl_entry: acl_entry.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2193 })
2194 }
2195}
2196
2197#[derive(Debug, Clone, Copy, PartialEq)]
2199pub struct RemoveACLFromNodeFields {
2200 pub list_id: u16,
2202 pub node_id: crate::msg::NodeId,
2204}
2205
2206impl ToTlv for RemoveACLFromNodeFields {
2207 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
2208 w.start_structure(tag)?;
2209 self.list_id.to_tlv(w, Tag::Context(0))?;
2210 self.node_id.to_tlv(w, Tag::Context(1))?;
2211 w.end_container()
2212 }
2213}
2214
2215impl<'a> FromTlv<'a> for RemoveACLFromNodeFields {
2216 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
2217 if element.value.container() != Some(ContainerKind::Structure) {
2218 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
2219 }
2220 let mut list_id = None;
2221 let mut node_id = None;
2222 loop {
2223 let Some(field) = reader.next_element()? else {
2224 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
2225 };
2226 if field.value == Value::EndOfContainer {
2227 break;
2228 }
2229 match field.tag.context() {
2230 Some(0) => list_id = Some(<u16>::from_tlv(reader, &field)?),
2231 Some(1) => node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
2232 _ => reader.skip_value(&field)?,
2236 }
2237 }
2238 Ok(Self {
2239 list_id: list_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2240 node_id: node_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2241 })
2242 }
2243}
2244
2245pub const ATTRIBUTES: &[Attribute] = &[
2247 Attribute {
2248 id: 0x0000,
2249 name: "AnchorRootCA",
2250 kind: "octstr",
2251 access: Access::read_only(Privilege::Administer),
2252 qualities: AttributeQualities::NON_VOLATILE,
2253 reporting: Reporting::OnChange,
2254 conform: Conform::MANDATORY,
2255 },
2256 Attribute {
2257 id: 0x0001,
2258 name: "AnchorNodeID",
2259 kind: "node-id",
2260 access: Access::read_only(Privilege::Administer),
2261 qualities: AttributeQualities::NON_VOLATILE,
2262 reporting: Reporting::OnChange,
2263 conform: Conform::MANDATORY,
2264 },
2265 Attribute {
2266 id: 0x0002,
2267 name: "AnchorVendorID",
2268 kind: "vendor-id",
2269 access: Access::read_only(Privilege::Administer),
2270 qualities: AttributeQualities::NON_VOLATILE,
2271 reporting: Reporting::OnChange,
2272 conform: Conform::MANDATORY,
2273 },
2274 Attribute {
2275 id: 0x0003,
2276 name: "FriendlyName",
2277 kind: "string",
2278 access: Access::read_only(Privilege::Administer),
2279 qualities: AttributeQualities::NON_VOLATILE,
2280 reporting: Reporting::OnChange,
2281 conform: Conform::MANDATORY,
2282 },
2283 Attribute {
2284 id: 0x0004,
2285 name: "GroupKeySetList",
2286 kind: "list[DatastoreGroupKeySetStruct]",
2287 access: Access::read_only(Privilege::Administer),
2288 qualities: AttributeQualities::NON_VOLATILE,
2289 reporting: Reporting::OnChange,
2290 conform: Conform::MANDATORY,
2291 },
2292 Attribute {
2293 id: 0x0005,
2294 name: "GroupList",
2295 kind: "list[DatastoreGroupInformationEntryStruct]",
2296 access: Access::read_only(Privilege::Administer),
2297 qualities: AttributeQualities::NON_VOLATILE,
2298 reporting: Reporting::OnChange,
2299 conform: Conform::MANDATORY,
2300 },
2301 Attribute {
2302 id: 0x0006,
2303 name: "NodeList",
2304 kind: "list[DatastoreNodeInformationEntryStruct]",
2305 access: Access::read_only(Privilege::Administer),
2306 qualities: AttributeQualities::NON_VOLATILE,
2307 reporting: Reporting::OnChange,
2308 conform: Conform::MANDATORY,
2309 },
2310 Attribute {
2311 id: 0x0007,
2312 name: "AdminList",
2313 kind: "list[DatastoreAdministratorInformationEntryStruct]",
2314 access: Access::read_only(Privilege::Administer),
2315 qualities: AttributeQualities::NON_VOLATILE,
2316 reporting: Reporting::OnChange,
2317 conform: Conform::MANDATORY,
2318 },
2319 Attribute {
2320 id: 0x0008,
2321 name: "Status",
2322 kind: "DatastoreStatusEntryStruct",
2323 access: Access::read_only(Privilege::Administer),
2324 qualities: AttributeQualities::NON_VOLATILE,
2325 reporting: Reporting::OnChange,
2326 conform: Conform::MANDATORY,
2327 },
2328 Attribute {
2329 id: 0x0009,
2330 name: "EndpointGroupIDList",
2331 kind: "list[DatastoreEndpointGroupIDEntryStruct]",
2332 access: Access::read_only(Privilege::Administer),
2333 qualities: AttributeQualities::NON_VOLATILE,
2334 reporting: Reporting::OnChange,
2335 conform: Conform::MANDATORY,
2336 },
2337 Attribute {
2338 id: 0x000A,
2339 name: "EndpointBindingList",
2340 kind: "list[DatastoreEndpointBindingEntryStruct]",
2341 access: Access::read_only(Privilege::Administer),
2342 qualities: AttributeQualities::NON_VOLATILE,
2343 reporting: Reporting::OnChange,
2344 conform: Conform::MANDATORY,
2345 },
2346 Attribute {
2347 id: 0x000B,
2348 name: "NodeKeySetList",
2349 kind: "list[DatastoreNodeKeySetEntryStruct]",
2350 access: Access::read_only(Privilege::Administer),
2351 qualities: AttributeQualities::NON_VOLATILE,
2352 reporting: Reporting::OnChange,
2353 conform: Conform::MANDATORY,
2354 },
2355 Attribute {
2356 id: 0x000C,
2357 name: "NodeACLList",
2358 kind: "list[DatastoreACLEntryStruct]",
2359 access: Access::read_only(Privilege::Administer),
2360 qualities: AttributeQualities::NON_VOLATILE,
2361 reporting: Reporting::OnChange,
2362 conform: Conform::MANDATORY,
2363 },
2364 Attribute {
2365 id: 0x000D,
2366 name: "NodeEndpointList",
2367 kind: "list[DatastoreEndpointEntryStruct]",
2368 access: Access::read_only(Privilege::Administer),
2369 qualities: AttributeQualities::NON_VOLATILE,
2370 reporting: Reporting::OnChange,
2371 conform: Conform::MANDATORY,
2372 },
2373];
2374
2375pub const COMMANDS: &[Command] = &[
2377 Command {
2378 id: 0x00,
2379 name: "AddKeySet",
2380 to_server: true,
2381 response: None,
2382 access: Access::invoke(Privilege::Administer),
2383 conform: Conform::MANDATORY,
2384 },
2385 Command {
2386 id: 0x01,
2387 name: "UpdateKeySet",
2388 to_server: true,
2389 response: None,
2390 access: Access::invoke(Privilege::Administer),
2391 conform: Conform::MANDATORY,
2392 },
2393 Command {
2394 id: 0x02,
2395 name: "RemoveKeySet",
2396 to_server: true,
2397 response: None,
2398 access: Access::invoke(Privilege::Administer),
2399 conform: Conform::MANDATORY,
2400 },
2401 Command {
2402 id: 0x03,
2403 name: "AddGroup",
2404 to_server: true,
2405 response: None,
2406 access: Access::invoke(Privilege::Administer),
2407 conform: Conform::MANDATORY,
2408 },
2409 Command {
2410 id: 0x04,
2411 name: "UpdateGroup",
2412 to_server: true,
2413 response: None,
2414 access: Access::invoke(Privilege::Administer),
2415 conform: Conform::MANDATORY,
2416 },
2417 Command {
2418 id: 0x05,
2419 name: "RemoveGroup",
2420 to_server: true,
2421 response: None,
2422 access: Access::invoke(Privilege::Administer),
2423 conform: Conform::MANDATORY,
2424 },
2425 Command {
2426 id: 0x06,
2427 name: "AddAdmin",
2428 to_server: true,
2429 response: None,
2430 access: Access::invoke(Privilege::Administer),
2431 conform: Conform::MANDATORY,
2432 },
2433 Command {
2434 id: 0x07,
2435 name: "UpdateAdmin",
2436 to_server: true,
2437 response: None,
2438 access: Access::invoke(Privilege::Administer),
2439 conform: Conform::MANDATORY,
2440 },
2441 Command {
2442 id: 0x08,
2443 name: "RemoveAdmin",
2444 to_server: true,
2445 response: None,
2446 access: Access::invoke(Privilege::Administer),
2447 conform: Conform::MANDATORY,
2448 },
2449 Command {
2450 id: 0x09,
2451 name: "AddPendingNode",
2452 to_server: true,
2453 response: None,
2454 access: Access::invoke(Privilege::Administer),
2455 conform: Conform::MANDATORY,
2456 },
2457 Command {
2458 id: 0x0A,
2459 name: "RefreshNode",
2460 to_server: true,
2461 response: None,
2462 access: Access::invoke(Privilege::Administer),
2463 conform: Conform::MANDATORY,
2464 },
2465 Command {
2466 id: 0x0B,
2467 name: "UpdateNode",
2468 to_server: true,
2469 response: None,
2470 access: Access::invoke(Privilege::Administer),
2471 conform: Conform::MANDATORY,
2472 },
2473 Command {
2474 id: 0x0C,
2475 name: "RemoveNode",
2476 to_server: true,
2477 response: None,
2478 access: Access::invoke(Privilege::Administer),
2479 conform: Conform::MANDATORY,
2480 },
2481 Command {
2482 id: 0x0D,
2483 name: "UpdateEndpointForNode",
2484 to_server: true,
2485 response: None,
2486 access: Access::invoke(Privilege::Administer),
2487 conform: Conform::MANDATORY,
2488 },
2489 Command {
2490 id: 0x0E,
2491 name: "AddGroupIDToEndpointForNode",
2492 to_server: true,
2493 response: None,
2494 access: Access::invoke(Privilege::Administer),
2495 conform: Conform::MANDATORY,
2496 },
2497 Command {
2498 id: 0x0F,
2499 name: "RemoveGroupIDFromEndpointForNode",
2500 to_server: true,
2501 response: None,
2502 access: Access::invoke(Privilege::Administer),
2503 conform: Conform::MANDATORY,
2504 },
2505 Command {
2506 id: 0x10,
2507 name: "AddBindingToEndpointForNode",
2508 to_server: true,
2509 response: None,
2510 access: Access::invoke(Privilege::Administer),
2511 conform: Conform::MANDATORY,
2512 },
2513 Command {
2514 id: 0x11,
2515 name: "RemoveBindingFromEndpointForNode",
2516 to_server: true,
2517 response: None,
2518 access: Access::invoke(Privilege::Administer),
2519 conform: Conform::MANDATORY,
2520 },
2521 Command {
2522 id: 0x12,
2523 name: "AddACLToNode",
2524 to_server: true,
2525 response: None,
2526 access: Access::invoke(Privilege::Administer),
2527 conform: Conform::MANDATORY,
2528 },
2529 Command {
2530 id: 0x13,
2531 name: "RemoveACLFromNode",
2532 to_server: true,
2533 response: None,
2534 access: Access::invoke(Privilege::Administer),
2535 conform: Conform::MANDATORY,
2536 },
2537];
2538
2539pub const EVENTS: &[Event] = &[];
2541
2542pub const CLUSTER: Cluster = Cluster {
2544 id: ID,
2545 name: "Joint Fabric Datastore",
2546 revision: REVISION,
2547 pics: "JFDS",
2548 derived_from: None,
2549 features: FEATURES,
2550 attributes: ATTRIBUTES,
2551 commands: COMMANDS,
2552 events: EVENTS,
2553};