Provides abstractions for working with TLV-encoded data
Data that may appear as part of a TLV record should implement [TlvEncode] and
[TlvDecode]. Types that represent a whole TLV record should implement [Tlv]
in addition to [TlvEncode] and [TlvDecode]
At the core of the library are the three traits [Tlv], [TlvEncode], and
[TlvDecode].
[Tlv] should be implemented on types that represent a TLV
record. In other words, types that, in their encoded form, start with a type
and a length.
[TlvEncode] and [TlvDecode] are used for types that can be encoded/decoded
and may appear in TLV records. All types implementing [Tlv] should also
implement [TlvEncode] and [TlvDecode].
To ease implementing these traits, a derive macro Tlv is made available.
Simply derive it on an enum to automatically implement [TlvEncode] and
[TlvDecode]. On structs, an attribute must be present to set the type ID of
the TLV that this struct represents. [Tlv] will also be implemented on
structs. Deriving [TlvEncode] and [TlvDecode] on structs without [Tlv] is
not currently supported.
Please note that this library is under active development and the API is not stable.
Example
Here is a quick example of how the library may be used:
use ;
use ;