moondlt

    Bounded, portable AUTOSAR DLT v1 log codec and stream processing

    dlt
    automotive
    binary
    wasm
    streaming
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    7 hours ago
    Downloads
    4

    No dependencies

    #MoonDLT

    MoonDLT 是以 MoonBit 实现的 DLT v1 二进制日志编解码与流处理库。它让运行在 Wasm、JavaScript 和原生环境中的工具读取 ECU 应用日志,提取带类型的参数,并将选中的记录按标准格式交给其他 DLT 工具。

    核心面向已经产生的 .dlt 文件和 DLT 消息字节流,采用明确的长度、参数数目和缓存上限。读取器不依赖 libdlt、C/C++ FFI、车辆硬件或常驻守护进程。

    维护者为 HYF-ai2006,项目仓库为 HYF-ai2006/MoonDLT,Mooncakes 包名为 HYF-ai2006/moondlt。参赛说明见 PROPOSAL.md,功能差异证据见 docs/DIFFERENTIATION.md,实际发布及 CI 状态见 docs/SUBMISSION_STATUS.md。

    添加依赖:

    moon add HYF-ai2006/moondlt@0.1.0

    最近一次本地检查修复记录见 2026-11-24 自查,逐项测试与规模数据见 本地验证记录。

    #能处理什么

    • DLT v1 标准头、ECU/session/timestamp 可选字段、扩展头和小端/大端载荷。
    • Storage .dlt、Network、Serial 三种显式封装;保留原始载荷,按需解码。
    • Verbose 布尔、8/16/32/64 位有符号与无符号整数、32/64 位浮点、ASCII/UTF-8 字符串、原始字节参数。
    • 独立的高级参数 API 保留 VARI 名称/单位、FIXP 缩放与同类数值数组;JSON 交换把 64 位整数作为十进制字符串、浮点作为 IEEE 位模式保留。
    • 任意分片输入、严格的结束检查、带上限的 Storage/Serial 损坏恢复。
    • 应用、上下文、ECU、日志等级和存储时间过滤;有界头字段表达式、字节偏移索引、提取、确定性合并和重新封装。
    • 应用显式注册的 nonverbose 固定布局字典;未注册载荷仍可按原样转交。
    • 使用 UInt64 偏移和宿主 read_at 回调扫描大型记录,只读取头或所选载荷;有界窗口缓存、计数器连续性和时间分桶可按需使用。
    • 可保存为 JSON 的 SourceCatalog 元数据侧文件;默认 open 重新核对全部记录头,再用于查询。
    • 常用控制服务的被动编解码;函数不建立连接或向设备发送命令。

    详细范围与限制以 兼容性清单 和生成接口 pkg.generated.mbti 为准。项目定位是 DLT v1 常用互操作子集,不宣称通过 AUTOSAR 全协议认证,也不实现 DLT v2、完整 FIBEX XML 或车载诊断服务栈。

    #本地运行

    需要 MoonBit 工具链;文件命令行工具需要 Node.js 22 或更新版本。项目核心只依赖 MoonBit 标准库。

    moon check --target all --deny-warn moon test --target wasm --deny-warn moon test --target wasm-gc --deny-warn moon test --target js --deny-warn moon run cmd/demo --target js moon fmt --check

    原生测试还需要可用的 C 编译器。在本次 Windows 环境中,原生构建尝试因缺少 MSVC 工具链而未完成;这不等同于原生运行验证通过。安装相应构建工具后可执行 moon test --target native --deny-warn。更详细的 API 用法见 docs/USAGE.md。

    示例把真实编码的 Storage 记录按每块 7 字节送入读取器,再解码类型参数并通过索引提取原始记录。

    let decoded = @dlt.decode(file_bytes[:])
    let original_payload = decoded.message.payload
    let parameters = decoded.message.arguments()
    let encoded = @dlt.encode(decoded.message)

    在自己的 moon.pkg 中导入本地模块:

    import {
    "HYF-ai2006/moondlt" @dlt,
    }

    流式使用时,为读取器提供不超过缓存上限的分片,并在输入完成后调用 finish():

    let stream = @dlt.StreamDecoder::new()
    let first = stream.feed(chunk_a[:])
    let second = stream.feed(chunk_b[:])
    stream.finish()

    feed 失败会把读取器置于失败状态;再次使用前需要 reset()。recover=true 只允许 Storage/Serial,跳过字节数显式返回;不能把恢复结果当作“日志完整”。

    #直接处理文件

    Node 宿主只提供文件 I/O,协议解析、查询和选取都由 MoonBit 完成。命令自动构建 JS 适配器,使用 UInt64/BigInt 偏移按需读取,不把整份文件装入内存。

    node scripts/moondlt.mjs inspect fixtures/pydlt-0.3.5-storage.dlt --filter 'apid == "APP"' --limit 2 node scripts/moondlt.mjs extract input.dlt selected.dlt --filter 'level <= 3' python scripts/test_file_cli.py

    inspect 只读取消息头;extract 原样复制匹配记录,拒绝覆盖已有输出。文件命令当前限定 Storage 封装和最多一百万条扫描记录,摘要最多一万条;完整的库接口仍支持另外两种封装。输入文件必须在操作期间保持稳定。

    一次运行所有本地检查并保存证据:python scripts/validate.py。Windows 缺少 MSVC 时原生运行测试会明确记录为未运行;其他目标仍逐一测试。实际结果见 docs/LOCAL_VALIDATION.json。

    #独立互操作验证

    验证脚本使用独立 Python 包 pydlt 0.3.5,而不是另写一个相同逻辑的参考解析器。该包仅用于开发验证,不是运行时依赖。

    python -m pip install --target work/pydeps pydlt==0.3.5 python scripts/interop.py python scripts/test_interop_random.py

    脚本先检查提交的确定性黄金文件,再构建 MoonBit JS 可执行文件,比较两个方向的类型值和完整字节:pydlt 编码 → MoonDLT 解码;MoonDLT 编码 → pydlt 解码。覆盖 54 个向量,包括三种封装、所有头部可选字段组合、两种字节序、64 位边界、中文与补充平面字符、空字符串和空原始字节。结果与局限见 docs/VALIDATION.md。

    固定随机种子脚本另检查 192 条独立记录,包含空参数、随机整数、有限正常/次正规浮点及 Unicode/BOM。MoonBit 从解码后的类型值重新构造记录,比较原始字节;这不会扩大高级类型的互操作承诺。

    #代码规模

    python scripts/count_loc.py python scripts/count_loc.py --json

    脚本分别报告核心、测试、示例工具,排除构建目录、工作目录和自动生成接口;严格有效行另排除注释、空行及只含结构符号的行。比赛组织方可能采用不同的统计口径。当前数字应以脚本实际运行输出为准。

    #工程结构

    文件职责
    types.mbt、bytes.mbt公共类型、资源上限、边界检查与字节基础操作
    codec.mbt、stream.mbtv1 封装编解码、分片处理、显式恢复、重新封装
    verbose.mbt带类型的常用 verbose 参数
    verbose_parameters.mbt、verbose_json.mbt名称/单位、固定点、数值数组和保留整数精度的 JSON 交换
    verbose_selection.mbt数组坐标、区域提取、重塑及受检类型访问
    message_json.mbt保留原始载荷的消息 JSON 信封、严格头字段解析
    dictionary.mbt应用注册的 nonverbose 固定布局
    query.mbt过滤与有界表达式、索引、无损提取和合并
    source.mbt、timeline.mbt大偏移随机访问与窗口缓存、连续性事件与时间分桶
    catalog.mbt可持久化源目录、默认逐头核验和按需载荷读取
    control.mbt常用控制请求/响应的被动编解码
    cmd/demo、cmd/interop、cmd/node使用示例、外部互操作桥接和真实文件消费者
    fixtures、scripts独立黄金样本、验证与规模统计

    #来源与维护

    代码使用公开协议结构独立实现。成熟 DLT 实现用于设计对照与互操作验证;未把 COVESA 或其他库的源码复制进工程。AI 辅助生成和修改已披露,维护者仍需理解协议边界、审核实现并承担发布责任。授权和具体来源见 THIRD_PARTY.md。

    项目采用 Apache License 2.0,详见 LICENSE。

    DltError

    pub(all) suberror DltError {
    Invalid(Int, String)
    Truncated(Int, String)
    Unsupported(Int, String)
    Limit(Int, String)
    }

    Stable categories, with byte offsets relative to the current message/input.

    DltError::describe

    fn DltError::describe(self : DltError) -> String

    Argument

    pub(all) enum Argument {
    Boolean(Bool)
    Signed(Int, Int64)
    Unsigned(Int, UInt64)
    Floating(Int, Double)
    Text(TextEncoding, String)
    Raw(Bytes)
    } derive(Eq,
    Debug
    )

    Scalar verbose parameters supported by the v1 common profile. Widths are bits, integers accept 8/16/32/64, floating accepts 32/64.

    Argument::as_bool

    fn Argument::as_bool(self : Argument) -> Bool raise DltError

    Argument::as_double

    fn Argument::as_double(self : Argument, allow_lossy? : Bool) -> Double raise DltError

    Convert for numerical analysis. By default integers outside the portable JavaScript safe-integer interval fail rather than silently losing precision.

    Argument::as_int64

    fn Argument::as_int64(self : Argument) -> Int64 raise DltError

    Extract an exact signed value; unsigned values above Int64::MAX fail.

    Argument::as_raw

    fn Argument::as_raw(self : Argument) -> Bytes raise DltError

    Argument::as_text

    fn Argument::as_text(self : Argument) -> String raise DltError

    Argument::as_uint64

    fn Argument::as_uint64(self : Argument) -> UInt64 raise DltError

    Extract an exact unsigned value; negative signed values fail.

    Argument::from_json

    fn Argument::from_json(json :
    Json
    , limits? : Limits) -> Argument raise DltError

    Parse the tagged JSON form and validate width, range, text and byte limits.

    Argument::to_json

    JSON interchange keeps integer decimal strings and IEEE floating-point bits. JavaScript consumers never have to represent a 64-bit integer as Number.

    ContinuityConfig

    pub(all) struct ContinuityConfig {
    max_streams : Int
    max_forward_gap : Int
    wrap_previous_min : UInt
    wrap_current_max : UInt
    } derive(Eq,
    Debug
    )

    ContinuityConfig::default

    ContinuityEvent

    pub(all) enum ContinuityEvent {
    First
    SessionChanged(UInt?, UInt?)
    RepeatedCounter(Int)
    CounterGap(Int, Int, Int)
    CounterJump(Int, Int)
    TimestampWrapped(UInt, UInt)
    TimestampBackwards(UInt, UInt)
    ReceptionBackwards(UInt64, UInt64)
    } derive(Eq,
    Debug
    )

    Continuity analysis assumes messages arrive in capture order within each key. Counter gaps indicate missing counter values, not a proven packet-loss count.

    ContinuityObservation

    pub(all) struct ContinuityObservation {
    key : StreamKey
    events : Array[ContinuityEvent]
    extended_timestamp : UInt64?
    stream_messages : UInt64
    } derive(Eq,
    Debug
    )

    ContinuityTracker

    pub struct ContinuityTracker {
    config : ContinuityConfig
    states : Map[String, TimelineState]
    order : Array[String]
    total : UInt64
    }

    ContinuityTracker::new

    ContinuityTracker::observe

    ContinuityTracker::reset

    fn ContinuityTracker::reset(self : ContinuityTracker) -> Unit

    ContinuityTracker::stream_count

    fn ContinuityTracker::stream_count(self : ContinuityTracker) -> Int

    ContinuityTracker::summaries

    ContinuityTracker::total_messages

    fn ContinuityTracker::total_messages(self : ContinuityTracker) -> UInt64

    ControlRequest

    pub(all) enum ControlRequest {
    SetLogLevel(String, String, Int, String)
    SetTraceStatus(String, String, Int, String)
    GetLogInfo(Int, String, String, String)
    GetDefaultLogLevel
    StoreConfiguration
    ResetConfiguration
    SetDefaultLogLevel(Int, String)
    SetDefaultTraceStatus(Int, String)
    GetSoftwareVersion
    Unknown(UInt, Bytes)
    } derive(Eq,
    Debug
    )

    Passive codec for DLT v1 control services. It never opens a connection or sends requests. Unknown service bodies remain available without interpretation. Per-context services accept -1 to select the configured default (0xff). Services that set the default itself require a concrete level/status.

    ControlRequest::service_id

    fn ControlRequest::service_id(self : ControlRequest) -> UInt

    ControlResponse

    pub(all) struct ControlResponse {
    service_id : UInt
    status : Int
    data : Bytes
    } derive(Eq,
    Debug
    )

    ControlResponse::default_log_level

    fn ControlResponse::default_log_level(self : ControlResponse) -> Int raise DltError

    ControlResponse::software_version

    fn ControlResponse::software_version(self : ControlResponse, endian : Endian, maximum_bytes? : Int) -> String raise DltError

    Decoded

    pub(all) struct Decoded {
    message : Message
    consumed : Int
    } derive(Eq,
    Debug
    )

    Dictionary

    pub struct Dictionary {
    schemas : Array[NonVerboseSchema]
    capacity : Int
    maximum_fields : Int
    }

    Registration and lookups are bounded linear scans, appropriate for small embedded application dictionaries. Registered field lists are copied.

    Dictionary::contains

    fn Dictionary::contains(self : Dictionary, key : SchemaKey) -> Bool

    Dictionary::decode

    fn Dictionary::decode(self : Dictionary, message : Message) -> Array[NamedValue] raise DltError

    Dictionary::encode

    fn Dictionary::encode(self : Dictionary, key : SchemaKey, values : ArrayView[NamedValue], endian : Endian) -> Bytes raise DltError

    Encode only the nonverbose payload, including its four-byte message ID. Field order, names and units must match the registered schema exactly.

    Dictionary::from_json

    fn Dictionary::from_json(value :
    Json
    , capacity? : Int, maximum_fields? : Int) -> Dictionary raise DltError

    Decode a parsed JSON value. Callers may choose their JSON parser and I/O. Unknown properties, duplicate keys at registration, invalid widths and ambiguous layouts fail explicitly rather than changing interpretation.

    Dictionary::length

    fn Dictionary::length(self : Dictionary) -> Int

    Dictionary::lookup

    fn Dictionary::lookup(self : Dictionary, key : SchemaKey) -> NonVerboseSchema?

    Dictionary::new

    fn Dictionary::new(capacity? : Int, maximum_fields? : Int) -> Dictionary raise DltError

    Dictionary::register

    fn Dictionary::register(self : Dictionary, schema : NonVerboseSchema) -> Unit raise DltError

    Dictionary::remove

    fn Dictionary::remove(self : Dictionary, key : SchemaKey) -> Bool

    Dictionary::to_json

    Portable schema representation, with explicit version and 32-bit numeric IDs. Field order and schema registration order are preserved in arrays.

    Endian

    pub(all) enum Endian {
    Little
    Big
    } derive(Eq,
    Debug
    )

    ExpressionLimits

    pub(all) struct ExpressionLimits {
    input_bytes : Int
    tokens : Int
    depth : Int
    nodes : Int
    } derive(Eq,
    Debug
    )

    ExpressionLimits::default

    ExtendedHeader

    pub(all) struct ExtendedHeader {
    verbose : Bool
    message_type : Int
    subtype : Int
    argument_count : Int
    application : String
    context : String
    } derive(Eq,
    Debug
    )

    message_type: 0 log, 1 application trace, 2 network trace, 3 control. subtype is the corresponding four-bit log level/trace/control code.

    FieldKind

    pub(all) enum FieldKind {
    Flag
    SignedInteger(Int)
    UnsignedInteger(Int)
    FloatNumber(Int)
    FixedText(TextEncoding, Int)
    FixedBytes(Int)
    } derive(Eq,
    Debug
    )

    An application-owned nonverbose layout. These are fixed-width wire fields; there is no inference from bytes and no claim of FIBEX XML compatibility.

    FieldKind::byte_width

    fn FieldKind::byte_width(self : FieldKind) -> Int raise DltError

    Filter

    pub(all) struct Filter {
    ecus : Array[String]?
    applications : Array[String]?
    contexts : Array[String]?
    message_types : Array[Int]?
    maximum_log_level : Int?
    minimum_time : UInt64?
    maximum_time : UInt64?
    verbose : Bool?
    } derive(Eq,
    Debug
    )

    Inclusive wall-clock range, in microseconds since Unix epoch. An absent criterion matches everything. An explicit empty list matches nothing.

    Filter::all

    fn Filter::all() -> Filter

    Filter::matches

    fn Filter::matches(self : Filter, message : Message) -> Bool raise DltError

    Filter::validate

    fn Filter::validate(self : Filter) -> Unit raise DltError

    FilterExpr

    pub(all) enum FilterExpr {
    Constant(Bool)
    Compare(HeaderField, Relation, HeaderValue)
    Conjunction(FilterExpr, FilterExpr)
    Disjunction(FilterExpr, FilterExpr)
    Negation(FilterExpr)
    } derive(Eq,
    Debug
    )

    A small header query language, not a general-purpose expression evaluator. Missing fields make comparisons false, including !=; ! negates that result.

    FilterExpr::matches

    fn FilterExpr::matches(self : FilterExpr, message : Message, limits? : ExpressionLimits) -> Bool raise DltError

    Evaluation also bounds manually constructed ASTs, not just parsed input.

    FilterExpr::parse

    fn FilterExpr::parse(input : String, limits? : ExpressionLimits) -> FilterExpr raise DltError

    Grammar: || (lowest), &&, !, parentheses, comparisons, true and false. Example: apid == "APP" && level <= 4 && !(counter == 0).

    FixedPoint

    pub(all) struct FixedPoint {
    quantization : Float
    offset : Int64
    } derive(Eq,
    Debug
    )

    FIXP descriptor: logical = stored * quantization + offset. The wire quantization is binary32; offset is signed32 for <=32-bit values, signed64 for 64-bit values. Integer storage stays exact in ParameterValue.

    Framing

    pub(all) enum Framing {
    Network
    Storage
    Serial
    } derive(Eq,
    Debug
    )

    pub(all) struct Header {
    endian : Endian
    counter : Int
    ecu : String?
    session : UInt?
    timestamp : UInt?
    extended : ExtendedHeader?
    } derive(Eq,
    Debug
    )

    Header numeric optional fields always use network byte order on the wire. endian applies only to the payload type words and values.

    Header::from_json

    fn Header::from_json(json :
    Json
    , limits? : Limits) -> Header raise DltError

    Header::new

    fn Header::new(counter? : Int, endian? : Endian) -> Header

    Header::to_json

    Header::wire_size

    fn Header::wire_size(self : Header) -> Int

    Size of the standard and optional extended headers, excluding storage/serial.

    HeaderField

    pub(all) enum HeaderField {
    Ecu
    StorageEcu
    Application
    Context
    MessageType
    LogLevel
    Counter
    Session
    Timestamp
    WallTime
    Verbosity
    } derive(Eq,
    Debug
    )

    Header-only selectors. WallTime is storage Unix microseconds; Timestamp is the ECU's 0.1-ms uptime field, a different clock domain.

    HeaderValue

    pub(all) enum HeaderValue {
    TextValue(String)
    NumberValue(UInt64)
    BoolValue(Bool)
    } derive(Eq,
    Debug
    )

    IndexEntry

    pub(all) struct IndexEntry {
    offset : Int
    length : Int
    storage : StorageHeader?
    header : Header
    } derive(Eq,
    Debug
    )

    IndexedSource

    pub struct IndexedSource {
    source : Source
    catalog : SourceCatalog
    }

    IndexedSource::length

    fn IndexedSource::length(self : IndexedSource) -> Int

    IndexedSource::query

    fn IndexedSource::query(self : IndexedSource, filter : Filter, maximum? : Int) -> Array[Int] raise DltError

    IndexedSource::read

    fn IndexedSource::read(self : IndexedSource, index : Int, limits? : Limits) -> Message raise DltError

    IndexedSource::select

    fn IndexedSource::select(self : IndexedSource, filter : Filter, maximum? : Int, payload_budget? : Int, limits? : Limits) -> Array[Message] raise DltError

    Queries metadata first, then loads only matching payloads. Explicit maximum and cumulative payload budgets bound the materialized result.

    IndexedSource::visit_range

    fn IndexedSource::visit_range(self : IndexedSource, start : Int, end : Int, visit : (Message) -> Bool raise DltError, limits? : Limits) -> Int raise DltError

    Reads an ordered half-open record interval without decoding unrelated records.

    Limits

    pub(all) struct Limits {
    message_bytes : Int
    buffered_bytes : Int
    arguments : Int
    string_bytes : Int
    resync_bytes : Int
    } derive(Eq,
    Debug
    )

    Limits::default

    fn Limits::default() -> Limits

    Message

    pub(all) struct Message {
    storage : StorageHeader?
    header : Header
    payload : Bytes
    } derive(Eq,
    Debug
    )

    Payload is preserved exactly; decoding verbose arguments is an explicit step.

    Message::arguments

    fn Message::arguments(self : Message, limits? : Limits) -> Array[Argument] raise DltError

    Message::control_request

    fn Message::control_request(self : Message) -> ControlRequest raise DltError

    Message::control_response

    fn Message::control_response(self : Message) -> ControlResponse raise DltError

    Message::effective_ecu

    fn Message::effective_ecu(self : Message) -> String?

    Message::from_json

    fn Message::from_json(json :
    Json
    , limits? : Limits) -> Message raise DltError

    Message::new

    fn Message::new(header : Header, payload : Bytes, storage? : StorageHeader) -> Message

    Message::nonverbose_id

    fn Message::nonverbose_id(self : Message) -> UInt raise DltError

    Message::parameters

    fn Message::parameters(self : Message, limits? : Limits) -> Array[VerboseParameter] raise DltError

    Message::schema_key

    fn Message::schema_key(self : Message) -> SchemaKey raise DltError

    Message::storage_microseconds

    fn Message::storage_microseconds(self : Message) -> UInt64? raise DltError

    Message::stream_key

    fn Message::stream_key(self : Message) -> StreamKey

    Message::to_json

    Portable message envelope: wire payload bytes remain hexadecimal so unknown types and signaling-NaN payload bits survive a JSON round trip unchanged.

    Message::with_arguments

    fn Message::with_arguments(header : Header, args : Array[Argument], storage? : StorageHeader, limits? : Limits) -> Message raise DltError

    Build a verbose message, deriving NOAR from the actual parameter array.

    Message::with_parameters

    fn Message::with_parameters(header : Header, parameters : Array[VerboseParameter], storage? : StorageHeader, limits? : Limits) -> Message raise DltError

    NamedValue

    pub(all) struct NamedValue {
    name : String
    unit : String?
    value : Argument
    } derive(Eq,
    Debug
    )

    NonVerboseSchema

    pub(all) struct NonVerboseSchema {
    key : SchemaKey
    fields : Array[SchemaField]
    } derive(Eq,
    Debug
    )

    NonVerboseSchema::payload_length

    fn NonVerboseSchema::payload_length(self : NonVerboseSchema) -> Int raise DltError

    NumericType

    pub(all) enum NumericType {
    Bool8
    IntValue(Int)
    UIntValue(Int)
    FloatValue(Int)
    } derive(Eq,
    Debug
    )

    A homogeneous DLT numeric array element descriptor.

    ParameterValue

    pub(all) enum ParameterValue {
    Scalar(Argument)
    NumericArray(NumericType, Array[Int], Array[Argument])
    } derive(Eq,
    Debug
    )

    Dimensions follow the wire order; values are stored flat without transposition. Array storage is row-major according to the producer's dimension convention.

    Relation

    pub(all) enum Relation {
    EqualTo
    NotEqualTo
    LessThan
    LessOrEqual
    GreaterThan
    GreaterOrEqual
    } derive(Eq,
    Debug
    )

    SchemaField

    pub(all) struct SchemaField {
    name : String
    kind : FieldKind
    unit : String?
    } derive(Eq,
    Debug
    )

    SchemaKey

    pub(all) struct SchemaKey {
    application : String
    context : String
    message_id : UInt
    } derive(Eq,
    Debug
    )

    Source

    pub struct Source {
    size : UInt64
    read_at : (UInt64, Int) -> Bytes raise DltError
    }

    Stable random-access input. The callback returns exactly the requested bytes. Offsets use UInt64, allowing large recordings with small in-memory windows.

    Source::catalog

    fn Source::catalog(self : Source, framing? : Framing, limits? : Limits, max_entries? : Int) -> Array[SourceEntry] raise DltError

    Builds a bounded catalog; for unbounded recordings prefer visit or next_entry.

    Source::copy_selected

    fn Source::copy_selected(self : Source, select : (SourceEntry) -> Bool, emit : (Bytes) -> Unit raise DltError, framing? : Framing, limits? : Limits, max_entries? : UInt64) -> UInt64 raise DltError

    Copies selected records in original order without decoding payload arguments. Sink effects are incremental: an error cannot roll back earlier emissions.

    Source::from_bytes

    fn Source::from_bytes(bytes : Bytes) -> Source

    Source::new

    fn Source::new(size : UInt64, read_at : (UInt64, Int) -> Bytes raise DltError) -> Source

    Source::read_entry

    fn Source::read_entry(self : Source, entry : SourceEntry, limits? : Limits) -> Message raise DltError

    Confirms the referenced entry against the source before returning its bytes. The caller must still keep a callback-backed source immutable between reads.

    Source::signature

    fn Source::signature(self : Source, sample_bytes? : Int) -> SourceSignature raise DltError

    Source::size

    fn Source::size(self : Source) -> UInt64

    Source::verify

    fn Source::verify(self : Source, check? : (Message) -> Unit raise DltError, framing? : Framing, limits? : Limits, max_entries? : UInt64) -> UInt64 raise DltError

    Validates the complete source message-by-message. Payload validity can be checked by passing a verifier, e.g. a verbose parameter decoder.

    Source::visit

    fn Source::visit(self : Source, visit : (SourceEntry) -> Bool raise DltError, framing? : Framing, limits? : Limits, max_entries? : UInt64) -> UInt64 raise DltError

    Visits selected metadata records without buffering the whole recording. Returning false stops immediately; no future source data will be requested.

    SourceCatalog

    pub struct SourceCatalog {
    signature : SourceSignature
    framing : Framing
    records : Array[SourceEntry]
    }

    SourceCatalog::build

    fn SourceCatalog::build(source : Source, framing? : Framing, limits? : Limits, max_entries? : Int, sample_bytes? : Int) -> SourceCatalog raise DltError

    Materializes only a bounded metadata sidecar. Payload bytes are never retained.

    SourceCatalog::containing

    fn SourceCatalog::containing(self : SourceCatalog, offset : UInt64) -> Int?

    Returns the record whose framed byte range contains offset using binary search.

    SourceCatalog::entry

    fn SourceCatalog::entry(self : SourceCatalog, index : Int) -> SourceEntry raise DltError

    SourceCatalog::from_json

    fn SourceCatalog::from_json(json :
    Json
    , limits? : Limits, max_entries? : Int) -> SourceCatalog raise DltError

    Untrusted sidecars are checked for contiguous coverage, length arithmetic, header validity, framing consistency, and caller-specified entry limits.

    SourceCatalog::length

    fn SourceCatalog::length(self : SourceCatalog) -> Int

    SourceCatalog::open

    fn SourceCatalog::open(self : SourceCatalog, source : Source, limits? : Limits) -> IndexedSource raise DltError

    Verifies every indexed header against the source before trusting metadata queries. Payload bytes are not scanned; each selected read validates again.

    SourceCatalog::open_trusted

    fn SourceCatalog::open_trusted(self : SourceCatalog, source : Source) -> IndexedSource raise DltError

    Fast path for caller-trusted, previously verified sidecars only. Sampled identity cannot prove that sidecar headers describe the source correctly. Queries can omit records if the caller supplies altered metadata here.

    SourceCatalog::query

    fn SourceCatalog::query(self : SourceCatalog, filter : Filter, maximum? : Int) -> Array[Int] raise DltError

    SourceCatalog::source_signature

    fn SourceCatalog::source_signature(self : SourceCatalog) -> SourceSignature

    SourceCatalog::to_json

    SourceCursor

    pub struct SourceCursor {
    source : Source
    framing : Framing
    limits : Limits
    max_entries : UInt64
    offset : UInt64
    count : UInt64
    header_bytes_read : UInt64
    }

    Sequential metadata iterator with explicit I/O and entry limits. Each call reads a framing prefix followed by only the optional header bytes.

    SourceCursor::entry_count

    fn SourceCursor::entry_count(self : SourceCursor) -> UInt64

    SourceCursor::header_bytes_read

    fn SourceCursor::header_bytes_read(self : SourceCursor) -> UInt64

    SourceCursor::new

    fn SourceCursor::new(source : Source, framing? : Framing, limits? : Limits, max_entries? : UInt64, start? : UInt64) -> SourceCursor raise DltError

    SourceCursor::next_entry

    fn SourceCursor::next_entry(self : SourceCursor) -> SourceEntry? raise DltError

    SourceCursor::position

    fn SourceCursor::position(self : SourceCursor) -> UInt64

    SourceEntry

    pub(all) struct SourceEntry {
    offset : UInt64
    length : Int
    framing : Framing
    storage : StorageHeader?
    header : Header
    payload_offset : UInt64
    payload_length : Int
    } derive(Eq,
    Debug
    )

    Index metadata does not imply that verbose payloads have been validated.

    SourceSignature

    pub(all) struct SourceSignature {
    size : UInt64
    sample_bytes : Int
    head : UInt64
    tail : UInt64
    } derive(Eq,
    Debug
    )

    Noncryptographic sampled identity detects accidental stale-sidecar reuse. It is not an integrity proof; source callbacks must provide an immutable file.

    StorageHeader

    pub(all) struct StorageHeader {
    seconds : UInt
    microseconds : UInt
    ecu : String
    } derive(Eq,
    Debug
    )

    StorageHeader::time_microseconds

    fn StorageHeader::time_microseconds(self : StorageHeader) -> UInt64 raise DltError

    StreamBatch

    pub(all) struct StreamBatch {
    messages : Array[Message]
    skipped : Int
    } derive(Eq,
    Debug
    )

    StreamDecoder

    pub struct StreamDecoder {
    framing : Framing
    limits : Limits
    recover : Bool
    pending : Bytes
    total_input : UInt64
    total_messages : UInt64
    total_skipped : UInt64
    consecutive_skipped : Int
    closed : Bool
    failed : Bool
    }

    Bounded incremental framing. A failing feed poisons the decoder until reset; this avoids silently delivering only a prefix of an unsuccessful batch.

    StreamDecoder::buffered_bytes

    fn StreamDecoder::buffered_bytes(self : StreamDecoder) -> Int

    StreamDecoder::discard_tail

    fn StreamDecoder::discard_tail(self : StreamDecoder) -> Int raise DltError

    StreamDecoder::feed

    fn StreamDecoder::feed(self : StreamDecoder, chunk : BytesView) -> StreamBatch raise DltError

    Maximum accepted chunk plus pending bytes is limits.buffered_bytes. No callback or socket is owned by the decoder, so backpressure stays explicit.

    StreamDecoder::finish

    fn StreamDecoder::finish(self : StreamDecoder) -> Unit raise DltError

    Strict end-of-input: even in recovery mode, a partial candidate is an error. Call discard_tail only when the caller intentionally accepts data loss.

    StreamDecoder::input_bytes

    fn StreamDecoder::input_bytes(self : StreamDecoder) -> UInt64

    StreamDecoder::is_failed

    fn StreamDecoder::is_failed(self : StreamDecoder) -> Bool

    StreamDecoder::message_count

    fn StreamDecoder::message_count(self : StreamDecoder) -> UInt64

    StreamDecoder::new

    fn StreamDecoder::new(framing? : Framing, limits? : Limits, recover? : Bool) -> StreamDecoder raise DltError

    StreamDecoder::reset

    fn StreamDecoder::reset(self : StreamDecoder) -> Unit

    StreamDecoder::skipped_bytes

    fn StreamDecoder::skipped_bytes(self : StreamDecoder) -> UInt64

    StreamKey

    pub(all) struct StreamKey {
    ecu : String
    application : String
    context : String
    } derive(Eq,
    Debug
    )

    StreamSummary

    pub(all) struct StreamSummary {
    key : StreamKey
    messages : UInt64
    missing_counter_values : UInt64
    repeated_counters : UInt64
    counter_jumps : UInt64
    clock_backwards : UInt64
    timestamp_wraps : UInt64
    last_counter : Int
    last_session : UInt?
    last_timestamp : UInt?
    } derive(Eq,
    Debug
    )

    StreamTranscoder

    pub struct StreamTranscoder {
    decoder : StreamDecoder
    output : Framing
    select : (Message) -> Bool
    transform : (Message) -> Message raise DltError
    emit : (Bytes) -> Unit raise DltError
    emitted_messages : UInt64
    emitted_bytes : UInt64
    failed : Bool
    }

    Callback based transcode holds at most one output chunk; emit can implement a file, a Web Worker message, or a caller-controlled ring buffer.

    StreamTranscoder::feed

    fn StreamTranscoder::feed(self : StreamTranscoder, bytes : BytesView) -> Int raise DltError

    StreamTranscoder::finish

    fn StreamTranscoder::finish(self : StreamTranscoder) -> Unit raise DltError

    StreamTranscoder::message_count

    fn StreamTranscoder::message_count(self : StreamTranscoder) -> UInt64

    StreamTranscoder::new

    fn StreamTranscoder::new(input : Framing, output : Framing, emit : (Bytes) -> Unit raise DltError, select? : (Message) -> Bool, transform? : (Message) -> Message raise DltError, limits? : Limits) -> StreamTranscoder raise DltError

    StreamTranscoder::output_bytes

    fn StreamTranscoder::output_bytes(self : StreamTranscoder) -> UInt64

    TextEncoding

    pub(all) enum TextEncoding {
    Ascii
    Utf8
    } derive(Eq,
    Debug
    )

    Character encoding of a verbose DLT string (SCOD field).

    TimeBucket

    pub(all) struct TimeBucket {
    window : TimeWindow
    messages : UInt64
    payload_bytes : UInt64
    min_counter : Int
    max_counter : Int
    } derive(Eq,
    Debug
    )

    TimeHistogram

    pub struct TimeHistogram {
    origin : UInt64
    width : UInt64
    max_buckets : Int
    buckets : Map[UInt64, TimeBucket]
    }

    Bounded tumbling windows for streaming log-volume visualization. Input order is irrelevant; results are sorted by bucket start and missing storage times fail.

    TimeHistogram::add

    fn TimeHistogram::add(self : TimeHistogram, message : Message) -> Unit raise DltError

    TimeHistogram::buckets

    TimeHistogram::clear

    fn TimeHistogram::clear(self : TimeHistogram) -> Unit

    TimeHistogram::new

    fn TimeHistogram::new(width_microseconds : UInt64, origin? : UInt64, max_buckets? : Int) -> TimeHistogram raise DltError

    TimeWindow

    pub(all) struct TimeWindow {
    start : UInt64
    end : UInt64
    } derive(Eq,
    Debug
    )

    Receive-time windows use integer microseconds to avoid floating rounding.

    TimeWindow::contains

    fn TimeWindow::contains(self : TimeWindow, time : UInt64) -> Bool

    TimeWindow::intersect

    fn TimeWindow::intersect(self : TimeWindow, other : TimeWindow) -> TimeWindow?

    TimeWindow::new

    fn TimeWindow::new(start : UInt64, end : UInt64) -> TimeWindow raise DltError

    TimelineState

    type TimelineState

    VariableInfo

    pub(all) struct VariableInfo {
    name : String
    unit : String?
    } derive(Eq,
    Debug
    )

    Optional VARI names; numeric parameters carry a unit as well as a name. Text, raw and Boolean parameters have a name only (unit must be None).

    VerboseParameter

    pub(all) struct VerboseParameter {
    value : ParameterValue
    variable : VariableInfo?
    scaling : FixedPoint?
    } derive(Eq,
    Debug
    )

    Advanced verbose parameter, preserving variable metadata and array dimensions. This deliberately excludes trace-info, structs and 128-bit data.

    VerboseParameter::array

    fn VerboseParameter::array(element_type : NumericType, dimensions : Array[Int], values : Array[Argument], variable? : VariableInfo, scaling? : FixedPoint) -> VerboseParameter

    VerboseParameter::at

    fn VerboseParameter::at(self : VerboseParameter, indices : Array[Int], limits? : Limits) -> Argument raise DltError

    Read an array element using zero-based C-order coordinates. Scalar parameters accept an empty coordinate list only.

    VerboseParameter::from_json

    VerboseParameter::logical_values

    fn VerboseParameter::logical_values(self : VerboseParameter) -> Array[Double] raise DltError

    Approximate logical numeric values; exact raw integers remain in value. Values beyond Double's integer precision are intentionally not rounded in APIs that return Argument or JSON decimal strings.

    VerboseParameter::reshape

    fn VerboseParameter::reshape(self : VerboseParameter, dimensions : Array[Int], limits? : Limits) -> VerboseParameter raise DltError

    Change dimensions without changing data order or the number of elements.

    VerboseParameter::scalar

    fn VerboseParameter::scalar(argument : Argument, variable? : VariableInfo, scaling? : FixedPoint) -> VerboseParameter

    VerboseParameter::section

    fn VerboseParameter::section(self : VerboseParameter, starts : Array[Int], counts : Array[Int], steps? : Array[Int], limits? : Limits) -> VerboseParameter raise DltError

    Return a rectangular strided section with the same type, VARI and FIXP. Each count is positive, steps are positive, and axes are never transposed.

    VerboseParameter::to_json

    WindowSource

    pub struct WindowSource {
    backing : Source
    window_bytes : Int
    start : UInt64
    window : Bytes
    reads : UInt64
    hits : UInt64
    }

    Small read-through cache for high-latency callback sources. It owns one window and never requests beyond the backing source; large requests bypass the cache.

    WindowSource::as_source

    fn WindowSource::as_source(self : WindowSource) -> Source

    WindowSource::backing_reads

    fn WindowSource::backing_reads(self : WindowSource) -> UInt64

    WindowSource::cache_hits

    fn WindowSource::cache_hits(self : WindowSource) -> UInt64

    WindowSource::invalidate

    fn WindowSource::invalidate(self : WindowSource) -> Unit

    WindowSource::new

    fn WindowSource::new(backing : Source, window_bytes? : Int) -> WindowSource raise DltError

    WindowSource::read

    fn WindowSource::read(self : WindowSource, offset : UInt64, length : Int) -> Bytes raise DltError

    build_index

    fn build_index(data : BytesView, framing? : Framing, limits? : Limits, max_entries? : Int) -> Array[IndexEntry] raise DltError

    Index a complete framed input. No resynchronization or silent skipping occurs. The input byte buffer must remain unchanged while the index is in use.

    control_request_message

    fn control_request_message(request : ControlRequest, header : Header, storage? : StorageHeader) -> Message raise DltError

    control_response_message

    fn control_response_message(response : ControlResponse, header : Header, storage? : StorageHeader) -> Message raise DltError

    copy_indexed

    fn copy_indexed(data : BytesView, entries : ArrayView[IndexEntry], framing? : Framing, limits? : Limits, maximum_bytes? : Int) -> Bytes raise DltError

    Copy selected framed records without normalizing their binary representation.

    decode

    fn decode(data : BytesView, framing? : Framing, limits? : Limits) -> Decoded raise DltError

    Decodes exactly one framed message and reports its length. Remaining bytes belong to the caller; use decode_exact for a standalone datagram.

    decode_all

    fn decode_all(data : BytesView, framing? : Framing, limits? : Limits, max_messages? : Int) -> Array[Message] raise DltError

    Validates every framing boundary without attempting to guess payload types.

    decode_arguments

    fn decode_arguments(data : BytesView, count : Int, endian : Endian, limits? : Limits) -> Array[Argument] raise DltError

    Decode exactly count scalar parameters and require complete consumption. Unsupported compound types are rejected; the outer Message retains raw bytes.

    decode_control_request

    fn decode_control_request(data : BytesView, endian : Endian) -> ControlRequest raise DltError

    decode_control_response

    fn decode_control_response(data : BytesView, endian : Endian) -> ControlResponse raise DltError

    Generic responses preserve service-specific status values and the full body. GetLogInfo responses use special status values 3..9, so status is not reduced to a success/failure Boolean. Its nested application list is kept raw.

    decode_exact

    fn decode_exact(data : BytesView, framing? : Framing, limits? : Limits) -> Message raise DltError

    decode_parameters

    fn decode_parameters(data : BytesView, count : Int, endian : Endian, limits? : Limits) -> Array[VerboseParameter] raise DltError

    encode

    fn encode(message : Message, framing? : Framing, limits? : Limits) -> Bytes raise DltError

    Deterministic writer. Framing conversion is explicit: storage framing requires a reception timestamp; network/serial framing omits that storage metadata.

    encode_all

    fn encode_all(messages : ArrayView[Message], framing? : Framing, limits? : Limits, max_bytes? : Int) -> Bytes raise DltError

    encode_arguments

    fn encode_arguments(args : Array[Argument], endian : Endian, limits? : Limits) -> Bytes raise DltError

    Encode the DLT v1 scalar verbose profile. All lengths include a string's NUL. Type words and payload numbers follow HTYP.MSBF, unlike header fields.

    encode_control_request

    fn encode_control_request(request : ControlRequest, endian : Endian) -> Bytes raise DltError

    encode_control_response

    fn encode_control_response(response : ControlResponse, endian : Endian) -> Bytes raise DltError

    encode_messages

    fn encode_messages(messages : ArrayView[Message], framing? : Framing, limits? : Limits, maximum_bytes? : Int) -> Bytes raise DltError

    encode_parameters

    fn encode_parameters(parameters : Array[VerboseParameter], endian : Endian, limits? : Limits) -> Bytes raise DltError

    extract_indexed

    fn extract_indexed(data : BytesView, entries : ArrayView[IndexEntry], framing? : Framing, limits? : Limits) -> Array[Message] raise DltError

    Revalidate index entries against the source to catch stale metadata/ranges.

    filter_messages

    fn filter_messages(messages : ArrayView[Message], filter : Filter, limit? : Int) -> Array[Message] raise DltError

    framing_name

    fn framing_name(framing : Framing) -> String

    hex_decode

    fn hex_decode(text : String) -> Bytes raise DltError

    hex_encode

    fn hex_encode(bytes : BytesView) -> String

    merge_messages

    fn merge_messages(streams : ArrayView[Array[Message]], maximum_messages? : Int) -> Array[Message] raise DltError

    Sort a bounded collection by storage time, retaining input order on ties. ECU uptime is deliberately never compared with Unix wall-clock timestamps.

    parse_framing

    fn parse_framing(name : String) -> Framing raise DltError

    query_expression

    fn query_expression(entries : ArrayView[IndexEntry], expression : FilterExpr, limit? : Int, expression_limits? : ExpressionLimits) -> Array[IndexEntry] raise DltError

    query_index

    fn query_index(entries : ArrayView[IndexEntry], filter : Filter, limit? : Int) -> Array[IndexEntry] raise DltError

    Results retain source order. A zero result limit performs no scan.

    software_version_response

    fn software_version_response(version : String, endian : Endian) -> ControlResponse raise DltError