Documentation
¶
Index ¶
- Constants
- func CompressLz4BlockArray(data []byte) ([]byte, error)
- func DecodeIndexedObjectSelf(d *codec.Decoder, value interface{})
- func DecodeMsgpack(data []byte, out interface{}) error
- func DecompressLz4BlockArray(data []byte) ([]byte, error)
- func EncodeIndexedMsgpack(v codec.Selfer) ([]byte, error)
- func EncodeIndexedObjectSelf(e *codec.Encoder, value interface{})
- func EncodeMsgpack(v interface{}) ([]byte, error)
- func ReadArrayHeader(data []byte, pos *int64) int64
- func ReadArrayHeaderStrict(data []byte, pos *int64) (int64, error)
- func ReadBin(data []byte, pos *int64) ([]byte, error)
- func ReadExtHeader(data []byte, pos *int64, expectedType int8) (int64, error)
- func ReadMapHeader(data []byte, pos *int64) (int64, error)
- func WriteArrayHeader(buf []byte, length int64) []byte
- func WriteExt(buf []byte, extType int8, payload []byte) []byte
- type ConstructorDefaults
- type IndexedObjectLayoutState
Constants ¶
const ( // MessagePack-CSharp 将扩展类型 98 保留给 Lz4BlockArray 头,将类型 99 保留给单个 Lz4Block // 对应游戏 MessagePackSerializer.ToLZ4BinaryCore 与 TryDecompress 实现 // MessagePack-CSharp reserves extension type 98 for the Lz4BlockArray header and type 99 for a single Lz4Block // This corresponds to the game MessagePackSerializer.ToLZ4BinaryCore and TryDecompress implementations Lz4ArrayType = 98 Lz4BlockType = 99 )
Variables ¶
This section is empty.
Functions ¶
func CompressLz4BlockArray ¶
CompressLz4BlockArray 将数据按 65536 字节分块并压缩为 MessagePack-CSharp 标准 Lz4BlockArray 布局 输出不追求与游戏写出的字节一致:游戏的 ToLZ4BinaryCore 按 ReadOnlySequence 的内部缓冲段切块,段尾放不下下一个值时会提前换段, 这种块边界无法从载荷本身推导,而游戏自带的 LZ4Codec 压缩强度也低于本库使用的编码器 分块方式与压缩强度都只影响体积,不影响解码结果,游戏按 ext 98 头中记录的每块解压大小还原数据 CompressLz4BlockArray splits data into 65536-byte blocks and compresses it into the standard MessagePack-CSharp Lz4BlockArray layout The output does not aim to match the bytes the game writes, because the game ToLZ4BinaryCore splits by the internal buffer segments of a ReadOnlySequence and starts a new segment early when the next value does not fit, which produces block boundaries that cannot be derived from the payload itself, while the bundled game LZ4Codec also compresses less tightly than the encoder used here The split and the compression strength affect only the size and never the decoded result, because the game restores data using the per-block decompressed sizes recorded in the ext 98 header
func DecodeIndexedObjectSelf ¶
DecodeIndexedObjectSelf 按当前支持的固定 int-key 布局解码对象,并拒绝短数组、高位 Key、非 nil 稀疏槽以及值类型中的 nil DecodeIndexedObjectSelf decodes an object using the currently supported fixed int-key layout and rejects short arrays, high keys, non-nil sparse slots, and nil in value-typed positions
func DecodeMsgpack ¶
DecodeMsgpack 解码唯一的完整 MessagePack 根值并拒绝任何尾部字节 DecodeMsgpack decodes the sole complete MessagePack root value and rejects any trailing bytes
func DecompressLz4BlockArray ¶
DecompressLz4BlockArray 处理 MessagePack-CSharp 的 Lz4Block 与 Lz4BlockArray 格式 标准多块布局是 array N+1、含各块 MessagePack 解压大小的 ext 98 头和后续 bin 块 单块布局是 ext 99,其载荷为一个 MessagePack 解压大小及压缩数据 DecompressLz4BlockArray handles MessagePack-CSharp Lz4Block and Lz4BlockArray forms The standard multi-block layout is array N+1 with an ext 98 header containing MessagePack decompressed sizes followed by bin blocks The single-block layout is ext 99 whose payload contains one MessagePack decompressed size and compressed data
func EncodeIndexedMsgpack ¶
EncodeIndexedMsgpack 编码通过 codec.Selfer 和 EncodeIndexedObjectSelf 实现的固定 indexed object 模型 Raw 模式仅供已验证的 union 编码器临时写入具体类型槽位,普通调用者继续使用禁用 Raw 的 EncodeMsgpack EncodeIndexedMsgpack encodes a fixed indexed object model implemented through codec.Selfer and EncodeIndexedObjectSelf Raw mode is used only by validated union encoders to write a temporary concrete-value slot, while ordinary callers continue to use EncodeMsgpack with Raw disabled
func EncodeIndexedObjectSelf ¶
EncodeIndexedObjectSelf 按当前支持的固定 int-key 布局编码 MessagePack 对象,稀疏 Key 始终写为 nil EncodeIndexedObjectSelf encodes a MessagePack object using the currently supported fixed int-key layout and always writes sparse keys as nil
func EncodeMsgpack ¶
EncodeMsgpack 使用不允许注入 codec.Raw 的当前 KCES 句柄编码普通 MessagePack 对象 EncodeMsgpack encodes an ordinary MessagePack object with the current KCES handle that does not allow codec.Raw injection
func ReadArrayHeader ¶
ReadArrayHeader 容错读取 MessagePack 数组头,失败时不推进位置并返回零 ReadArrayHeader tolerantly reads a MessagePack array header and returns zero without advancing the position on failure
func ReadArrayHeaderStrict ¶
ReadArrayHeaderStrict 严格读取 MessagePack 数组头,格式错误或长度超出 C# Int32 范围时返回错误 ReadArrayHeaderStrict strictly reads a MessagePack array header and returns an error for malformed input or lengths outside the C# Int32 range
func ReadBin ¶
ReadBin 读取 MessagePack bin8、bin16 或 bin32 载荷并推进位置 ReadBin reads a MessagePack bin8, bin16, or bin32 payload and advances the position
func ReadExtHeader ¶
ReadExtHeader 读取指定 ext 类型并将载荷解码为整数 载荷可为一、二、四或八字节固定宽度大端整数,也可为 MessagePack-CSharp LZ4 格式使用的 MessagePack 整数 ReadExtHeader reads an extension of the expected type and decodes its payload as an integer The payload may be a one-byte, two-byte, four-byte, or eight-byte fixed-width big-endian integer or a MessagePack integer used by MessagePack-CSharp LZ4 framing
func ReadMapHeader ¶
ReadMapHeader 严格读取 MessagePack 映射头并推进位置,格式错误或长度超出 C# Int32 范围时返回错误 ReadMapHeader strictly reads a MessagePack map header and advances the position, returning an error for malformed input or lengths outside the C# Int32 range
func WriteArrayHeader ¶
WriteArrayHeader 以可表示长度的最短 MessagePack 数组头追加元素数量 WriteArrayHeader appends an element count using the shortest MessagePack array header that can represent it
Types ¶
type ConstructorDefaults ¶
type ConstructorDefaults interface {
ApplyMessagePackConstructorDefaults()
}
ConstructorDefaults 模拟 C# 无参构造函数与字段初始化器在 MessagePack 成员赋值前安装的默认值,使旧宽度缺失的尾部 Key 保留构造默认值而不是零值 ConstructorDefaults mirrors the defaults installed by the C# parameterless constructor and field initializers before MessagePack member assignment so trailing keys missing from older widths keep constructor defaults instead of zero values
type IndexedObjectLayoutState ¶
type IndexedObjectLayoutState interface {
MessagePackIndexedObjectWidth() int32
SetMessagePackIndexedObjectWidth(int32)
}
IndexedObjectLayoutState 保存对象最近一次解码使用的 indexed-array 宽度 IndexedObjectLayoutState stores the indexed-array width used by the object's most recent decode