pub struct ThreadDataset { /* private fields */ }Expand description
A Thread operational dataset (Thread TLV bytes) used to provision a
device onto a Thread network. The caller obtains it from a border
router (e.g. ot-ctl dataset active -x, hex-decoded).
This is not Matter TLV. Thread’s operational dataset uses its own
flat TLV encoding: each element is type(1 byte), length(1 byte),
value(length bytes), walked from offset 0 with no outer container.
Debug is hand-written to redact bytes (renders only the length):
the dataset contains the Thread Network Key (TLV type 0x04) and PSKc
— secrets that must never land in logs via a stray {:?}. Mirrors
WiFiCredentials’ redacted Debug in state_machine::commissioner.
Implementations§
Source§impl ThreadDataset
impl ThreadDataset
Sourcepub fn new(bytes: Vec<u8>) -> Result<Self, ThreadDatasetError>
pub fn new(bytes: Vec<u8>) -> Result<Self, ThreadDatasetError>
Wrap and validate an operational dataset.
Validates that the dataset is non-empty, within the Thread spec’s
254-byte maximum, consists of well-formed TLVs (every TLV’s
declared length fits within the remaining buffer), and contains
an Extended PAN ID TLV (type 0x02, length 8).
§Errors
ThreadDatasetError::Emptyifbytesis empty.ThreadDatasetError::TooLargeifbytesexceeds 254 bytes.ThreadDatasetError::Malformedif the bytes are not well-formed Thread TLVs (a TLV’s length overruns the buffer).ThreadDatasetError::NoExtPanIdif no Extended PAN ID TLV (type 2, len 8) is present.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Raw dataset bytes (the opaque octet-string for
AddOrUpdateThreadNetwork).
Sourcepub fn ext_pan_id(&self) -> [u8; 8]
pub fn ext_pan_id(&self) -> [u8; 8]
Extended PAN ID (Thread dataset TLV type 2, 8 bytes) — the
ConnectNetwork network_id.
Captured once during ThreadDataset::new, which only ever
constructs a value after locating exactly this TLV.
Trait Implementations§
Source§impl Clone for ThreadDataset
impl Clone for ThreadDataset
Source§fn clone(&self) -> ThreadDataset
fn clone(&self) -> ThreadDataset
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more