Skip to main content

Crate matter_codec

Crate matter_codec 

Source
Expand description

Matter TLV (Tag-Length-Value) encoding and decoding.

This is Milestone 1 of the matter-rust roadmap.

§Scope

Phases 1-4 (complete, shipping as matter-codec 0.1.0): all scalar element types, UTF-8 and octet strings, every tag form (anonymous, context, common profile, implicit profile, fully-qualified), and containers (structure, array, list) with recursive tree-builder decoding and a 32-level depth limit. Verified by spec test vectors, a proptest round-trip property, and a cargo-fuzz target.

§Usage

use matter_codec::{Tag, TlvWriter};
let mut bytes = Vec::new();
let mut writer = TlvWriter::new(&mut bytes);
writer.put_bool(Tag::Anonymous, true)?;
assert_eq!(bytes, [0x09]);

Re-exports§

pub use error::Error;
pub use error::Result;
pub use reader::ContainerKind;
pub use reader::Element;
pub use reader::ElementRef;
pub use reader::ElementSpan;
pub use reader::TlvReader;
pub use reader::MAX_DEPTH;
pub use tag::Tag;
pub use value::Value;
pub use value::ValueRef;
pub use writer::TlvWriter;

Modules§

error
Error type for matter-codec.
reader
Streaming TLV decoder.
tag
Matter TLV tag forms.
value
Matter TLV element values.
writer
Streaming TLV encoder. Appends to a caller-provided Vec<u8>.