Skip to main content

Module record

Module record 

Source
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
RecordIterator
Iterator over TLV records in a byte buffer
RecordParserConfig
Configuration for record parsing

Enums§

RecordParseError
Error type for record parsing
RecordType
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