matter_codec/tag.rs
1//! Matter TLV tag forms.
2//!
3//! All five tag forms from the Matter Core Specification §A.2 are
4//! represented here. The wire format has separate 2-byte / 4-byte
5//! sub-variants for `CommonProfile`/`ImplicitProfile` and 6-byte /
6//! 8-byte sub-variants for `FullyQualified`; the public enum collapses
7//! those under a single variant per form, and the writer picks the
8//! minimum-width sub-variant from the value.
9
10/// A Matter TLV tag.
11///
12/// The enum is marked `#[non_exhaustive]` so adding hypothetical future
13/// variants is not a breaking change for downstream `match` expressions.
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
15#[non_exhaustive]
16pub enum Tag {
17 /// No tag bytes follow the control octet.
18 Anonymous,
19
20 /// One tag byte follows, carrying the context-specific tag number.
21 Context(u8),
22
23 /// A common-profile tag number. The writer emits 2 bytes if the value
24 /// fits in `u16`, otherwise 4 bytes.
25 CommonProfile(u32),
26
27 /// An implicit-profile tag number. The writer emits 2 bytes if the
28 /// value fits in `u16`, otherwise 4 bytes.
29 ImplicitProfile(u32),
30
31 /// A fully-qualified tag. Vendor and profile are always 2 bytes each
32 /// on the wire; the writer emits 2 bytes for `tag` if it fits in
33 /// `u16`, otherwise 4 bytes.
34 FullyQualified {
35 /// 16-bit vendor identifier.
36 vendor: u16,
37 /// 16-bit profile identifier within the vendor.
38 profile: u16,
39 /// Tag number within the profile.
40 tag: u32,
41 },
42}