Crate vtx_format

Crate vtx_format 

Source
Expand description

vtx-format:统一定义 .vtx 包格式(编码/解码)。

§v1

  • Header: 4 bytes = b"VTX\x01"
  • Payload: WebAssembly Component bytes

§v2

  • Header: 4 bytes = b"VTX\x02"
  • Metadata length: 4 bytes (u32 little-endian)
  • Metadata: UTF-8 JSON bytes (length = metadata length)
  • Payload: WebAssembly Component bytes

Structs§

DecodedVtx

Enums§

VtxFormatError

Constants§

VTX_MAGIC_V1
VTX_MAGIC_V2
VTX_PREFIX
VTX_VERSION_V1
VTX_VERSION_V2

Functions§

decode
解码:返回 (version, component_bytes_slice),对 v2 会跳过 metadata。
decode_with_metadata
解码并返回 metadata(仅 v2);v1 的 metadata 为 None。
encode_v1
编码 v1:VTX_MAGIC_V1 + component bytes
encode_v2
编码 v2:VTX_MAGIC_V2 + metadata_len(u32 LE) + metadata_json + component bytes

Type Aliases§

DecodeWithMetadataResult