Documentation
¶
Overview ¶
Package kv3 reads binary KeyValues3 versions 4 and 5 and writes version 5, the format Source 2 compiled resources store their data in.
Decode accepts untrusted input: malformed data returns an error and never panics, and a value budget bounds the work one buffer can demand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode reads binary KeyValues3 data. Objects decode as map[string]any and arrays as []any; the scalars as nil, bool, int64, uint64, float64, string and Blob. Flags are dropped.
func Encode ¶
Encode writes value as binary KeyValues3 version 5 with LZ4 compression, the form the resource compiler writes. It takes nil, bool, every integer type, float32, float64, string, []any, Object and map[string]any. An integer is written in the narrowest of int32, uint32, int64 and uint64 that holds it.
Types ¶
type Blob ¶
type Blob struct {
// Size is the blob's length in bytes.
Size int
// Data is the blob's bytes, nil when the payload was unreadable.
Data []byte
}
Blob is a binary blob: its bytes, or only its size when the payload could not be read.
func (Blob) MarshalJSON ¶ added in v0.1.34
MarshalJSON writes a blob as its size, so a dump of a resource stays readable.