Expand description
TLV Record Parsing
Provides parsing utilities for TLV (Type-Length-Value) encoded records from LANCE stream data.
§Record Format
Each record in a LANCE stream follows the TLV format:
+--------+--------+------------------+
| Type | Length | Value (payload) |
| 1 byte | 4 bytes| variable |
+--------+--------+------------------+- Type: Record type identifier (1 byte)
- Length: Payload length in bytes (4 bytes, big-endian)
- Value: Record payload (variable length)
§Example
use lnc_client::{RecordIterator, Record, RecordType};
use bytes::Bytes;
fn process_records(data: Bytes) {
for result in RecordIterator::new(data) {
match result {
Ok(record) => {
println!("Type: {:?}, Length: {}", record.record_type, record.payload.len());
}
Err(e) => {
eprintln!("Parse error: {}", e);
break;
}
}
}
}Structs§
- Record
- A parsed TLV record
- Record
Iterator - Iterator over TLV records in a byte buffer
- Record
Parser Config - Configuration for record parsing
Enums§
- Record
Parse Error - Error type for record parsing
- Record
Type - Record type identifiers
Constants§
- TLV_
HEADER_ SIZE - TLV header size in bytes (1 byte type + 4 bytes length)
Functions§
- encode_
record - Encode a record to TLV format
- encode_
record_ with_ type - Encode a record with custom type byte
- parse_
record - Parse a single record from a byte buffer
- parse_
records - Parse all records from a byte buffer