pkg

ctxcode/valk-msgpack

Pure-Valk MessagePack encoder and decoder with typed class/struct support

github.com/ctxcode/valk-msgpack ↗
0.2.0 latest Valk ≥ 0.9.1

Install

vman install github.com/ctxcode/valk-msgpack

Adds the package to your valk.json. To allow only some versions, add them: vman install github.com/ctxcode/valk-msgpack 0.2.x

Documentation

Namespaces: main


main

Aliases for 'main'

// Maximum container nesting depth permitted when decoding or encoding.
+ value MAX_DEPTH (128)
// Extension type code reserved by the MessagePack specification for timestamps (`-1`).
+ value TIMESTAMP_EXT_TYPE (-1)

MAX_DEPTH

Maximum container nesting depth permitted when decoding or encoding.

TIMESTAMP_EXT_TYPE

Extension type code reserved by the MessagePack specification for timestamps (-1).

Enums for 'main'

// The kind of a decoded or constructed MessagePack `Value`.
+ enum Kind { nil, bool, int, uint, float, str, bin, array, map, ext }

Kind

The kind of a decoded or constructed MessagePack Value.

Functions for 'main'

// Decodes a single MessagePack value from `data`.
+ fn decode(data: local &[u8], max_depth: uint (MAX_DEPTH)) Value !Error
// Decodes all concatenated MessagePack values from `data` until the end of input.
+ fn decode_all(data: local &[u8], max_depth: uint (MAX_DEPTH)) Array[Value] !Error
// Decodes a single MessagePack value from `data` and converts it directly to `T`.
+ fn decode_to[T](data: local &[u8], max_depth: uint (MAX_DEPTH)) T !Error
// Encodes `value` into MessagePack bytes.
+ fn encode[T](value: T) String
// Encodes `value` into MessagePack bytes and writes them to `out`, returning the byte count written.
+ fn encode_into[T](value: T, out: Writer) uint !io:IoError
// Converts any supported Valk value into a MessagePack `Value`.
+ fn from[T](data: T) Value

decode

Decodes a single MessagePack value from data.

Throws .truncated when input is incomplete, .invalid_format on 0xc1,
.depth_limit when containers exceed max_depth, and .trailing_data when
extra bytes remain after the decoded value.

decode_all

Decodes all concatenated MessagePack values from data until the end of input.

Returns an empty array for empty input. Throws on any truncated or malformed value.

decode_to

Decodes a single MessagePack value from data and converts it directly to T.

Throws .trailing_data if unread bytes remain after the value, .missing_field if
a required class/struct field is absent, or .type_mismatch if types do not match.

encode

Encodes value into MessagePack bytes.

Accepts a Value or any supported Valk type: primitives, String, Binary, Ext,
Timestamp, time.DateTime, nullable types, arrays, maps, sets, deques, enums,
structs, and classes (with $tag(msgpack: ...) and $tag(omitempty) support).

encode_into

Encodes value into MessagePack bytes and writes them to out, returning the byte count written.

When out is a ByteBuffer, bytes are appended directly without an extra copy.

from

Converts any supported Valk value into a MessagePack Value.

Supports primitives, strings, Binary, Ext, Timestamp, time.DateTime, json.Value,
nullables, containers (Array, HashMap, FlatMap, HashSet, Deque), enums,
structs, and classes (honoring $tag(msgpack: ...) and $tag(omitempty)).

Classes for 'main'

// Wrapper for raw binary bytes (`bin`) in typed structs and classes.
+ class Binary {
    // The raw bytes.
    + data: String

    // Returns true when both `Binary` values contain identical bytes.
    + fn equals(other: Binary) bool
    // Creates a `Binary` directly from `data`.
    + static fn from_string(data: String) Binary
    // Returns the number of bytes.
    + get length: uint
    // Creates a `Binary` by copying `data`.
    + static fn new(data: local &[u8]) Binary
}

Binary

Wrapper for raw binary bytes (bin) in typed structs and classes.

Use Binary on a field when you want MessagePack bin format instead of str.

data

The raw bytes.

equals

Returns true when both Binary values contain identical bytes.

from_string

Creates a Binary directly from data.

length

Returns the number of bytes.

new

Creates a Binary by copying data.

// Stateful streaming MessagePack decoder over a byte slice (`String`, `ByteBuffer`, or `&[u8]`).
+ class Decoder {
    // Maximum allowed container nesting depth.
    + max_depth: uint
    // Current byte offset in `source`.
    + pos: uint
    // Source byte view.
    + source: &[u8]

    // Decodes the next MessagePack value from the stream and advances `pos`.
    + fn decode() Value !Error
    // Decodes all remaining MessagePack values from the current position until EOF.
    + fn decode_all() Array[Value] !Error
    // Decodes the next MessagePack value from the stream, converts it to `T`, and advances `pos`.
    + fn decode_to[T]() T !Error
    // Returns true when all bytes have been consumed.
    + get is_eof: bool
    // Creates a new decoder positioned at byte 0 of `source`.
    + static fn new(source: &[u8], max_depth: uint (MAX_DEPTH)) Decoder
    // Returns the number of unread bytes remaining.
    + get remaining: uint
    // Resets the cursor back to byte 0.
    + fn reset() void
}

Decoder

Stateful streaming MessagePack decoder over a byte slice (String, ByteBuffer, or &[u8]).

Advances pos after each decoded object so multiple concatenated objects can be read
one by one.

max_depth

Maximum allowed container nesting depth.

pos

Current byte offset in source.

source

Source byte view.

decode

Decodes the next MessagePack value from the stream and advances pos.

decode_all

Decodes all remaining MessagePack values from the current position until EOF.

decode_to

Decodes the next MessagePack value from the stream, converts it to T, and advances pos.

is_eof

Returns true when all bytes have been consumed.

new

Creates a new decoder positioned at byte 0 of source.

remaining

Returns the number of unread bytes remaining.

reset

Resets the cursor back to byte 0.

// Streaming MessagePack encoder writing sequentially into a `ByteBuffer`.
+ class Encoder {
    // Underlying output buffer.
    + buffer: ByteBuffer

    // Clears the underlying buffer for reuse.
    + fn clear() void
    // Encodes `value` and appends it to the stream.
    + fn encode[T](value: T) void
    // Consumes the buffer and returns the encoded bytes as a `String` without copying.
    + fn into_string() String
    // Returns the number of bytes written so far.
    + get length: uint
    // Creates a new encoder backed by a fresh `ByteBuffer`.
    + static fn new(capacity: uint (128)) Encoder
    // Creates an encoder that appends directly to an existing `ByteBuffer`.
    + static fn to_buffer(buffer: ByteBuffer) Encoder
    // Copies the encoded bytes into a new `String`.
    + fn to_string() String
    // Writes an array header for `count` upcoming elements (`fixarray` / `array 16` / `array 32`).
    + fn write_array_header(count: uint) void
    // Writes raw binary bytes (`bin 8` / `bin 16` / `bin 32`).
    + fn write_bin(v: local &[u8]) void
    // Writes a MessagePack boolean.
    + fn write_bool(v: bool) void
    // Writes an extension value (`fixext 1/2/4/8/16` or `ext 8/16/32`).
    + fn write_ext(ext_type: i8, data: local &[u8]) void
    // Writes a 32-bit IEEE 754 float (`0xca`).
    + fn write_f32(v: f32) void
    // Writes a 64-bit IEEE 754 float (`0xcb`).
    + fn write_f64(v: f64) void
    // Writes a signed 64-bit integer in shortest MessagePack form.
    + fn write_int(v: i64) void
    // Writes a map header for `count` upcoming key/value pairs (`fixmap` / `map 16` / `map 32`).
    + fn write_map_header(count: uint) void
    // Writes a MessagePack `nil` (`0xc0`).
    + fn write_nil() void
    // Writes a UTF-8 string (`fixstr` / `str 8` / `str 16` / `str 32`).
    + fn write_str(v: local &[u8]) void
    // Writes a MessagePack Timestamp (`ext` type `-1`) in shortest 32/64/96-bit form.
    + fn write_timestamp(ts: Timestamp) void
    // Writes an unsigned 64-bit integer in shortest MessagePack form.
    + fn write_uint(v: u64) void
}

Encoder

Streaming MessagePack encoder writing sequentially into a ByteBuffer.

Use Encoder to write multiple concatenated MessagePack objects or build custom
wire payloads without constructing intermediate Value trees.

buffer

Underlying output buffer.

clear

Clears the underlying buffer for reuse.

encode

Encodes value and appends it to the stream.

into_string

Consumes the buffer and returns the encoded bytes as a String without copying.

length

Returns the number of bytes written so far.

new

Creates a new encoder backed by a fresh ByteBuffer.

to_buffer

Creates an encoder that appends directly to an existing ByteBuffer.

to_string

Copies the encoded bytes into a new String.

write_array_header

Writes an array header for count upcoming elements (fixarray / array 16 / array 32).

write_bin

Writes raw binary bytes (bin 8 / bin 16 / bin 32).

write_bool

Writes a MessagePack boolean.

write_ext

Writes an extension value (fixext 1/2/4/8/16 or ext 8/16/32).

write_f32

Writes a 32-bit IEEE 754 float (0xca).

write_f64

Writes a 64-bit IEEE 754 float (0xcb).

write_int

Writes a signed 64-bit integer in shortest MessagePack form.

write_map_header

Writes a map header for count upcoming key/value pairs (fixmap / map 16 / map 32).

write_nil

Writes a MessagePack nil (0xc0).

write_str

Writes a UTF-8 string (fixstr / str 8 / str 16 / str 32).

write_timestamp

Writes a MessagePack Timestamp (ext type -1) in shortest 32/64/96-bit form.

write_uint

Writes an unsigned 64-bit integer in shortest MessagePack form.

// Thrown when decoding or converting MessagePack data fails.
+ union Error {
    truncated(String, uint)
    invalid_format(String, uint)
    depth_limit(String, uint)
    type_mismatch(String)
    trailing_data(String, uint)
    missing_field(String)

    + get message: String
    + get offset: uint
    + fn to_string() String
}

Error

Thrown when decoding or converting MessagePack data fails.

  • truncated(message, offset): the input ended before a value or its payload finished.
  • invalid_format(message, offset): an invalid format byte (such as 0xc1) or malformed extension payload was encountered.
  • depth_limit(message, offset): containers were nested deeper than the configured depth limit (MAX_DEPTH).
  • type_mismatch(message): a decoded value cannot be converted to the requested type or overflows its range.
  • trailing_data(message, offset): unread bytes remained after decoding a single value.
  • missing_field(message): a required field on a target class or struct was absent from the map.
// A MessagePack extension value (`ext`) consisting of a signed 8-bit type code and raw bytes.
+ class Ext {
    // Raw extension payload bytes.
    + data: String
    // Extension type code (`-128 .. 127`).
    + type: i8

    // Returns true when both extension values have the same type code and payload bytes.
    + fn equals(other: Ext) bool
    // Creates an `Ext` value by copying `data`.
    + static fn new(type: i8, data: local &[u8]) Ext
}

Ext

A MessagePack extension value (ext) consisting of a signed 8-bit type code and raw bytes.

Type codes -128 .. -1 are reserved by the MessagePack specification (-1 is Timestamp);
0 .. 127 are application-defined.

data

Raw extension payload bytes.

type

Extension type code (-128 .. 127).

equals

Returns true when both extension values have the same type code and payload bytes.

new

Creates an Ext value by copying data.

// A single key/value pair inside a MessagePack map.
+ class MapEntry {
    // Entry key.
    + key: Value
    // Entry value.
    + value: Value

    // Returns true when both key and value are equal.
    + fn equals(other: MapEntry) bool
    // Creates a `MapEntry` with `key` and `value`.
    + static fn new(key: Value, value: Value) MapEntry
}

MapEntry

A single key/value pair inside a MessagePack map.

MessagePack maps allow arbitrary value types as keys (strings, integers, booleans, arrays, etc.)
and preserve entry order.

key

Entry key.

value

Entry value.

equals

Returns true when both key and value are equal.

new

Creates a MapEntry with key and value.

// A MessagePack Timestamp extension value (`ext` type `-1`).
+ class Timestamp {
    // Sub-second nanoseconds in `0 .. 999_999_999`.
    + nanoseconds: u32
    // Whole seconds since the Unix epoch (may be negative for dates before 1970).
    + seconds: i64

    // Returns true when both timestamps represent the exact same instant.
    + fn equals(other: Timestamp) bool
    // Converts a `time.DateTime` to a `Timestamp` (microsecond precision).
    + static fn from_datetime(dt: DateTime) Timestamp
    // Decodes a `Timestamp` from a MessagePack `Ext` (must have `type == -1` and 4, 8, or 12 bytes).
    + static fn from_ext(ext: Ext) Timestamp !Error
    // Creates a validated `Timestamp`, throwing `.invalid_format` if `nanoseconds > 999_999_999`.
    + static fn new(seconds: i64, nanoseconds: u32 (0)) Timestamp !Error
    // Converts this `Timestamp` to a UTC `time.DateTime` (truncated to microseconds).
    + fn to_datetime() DateTime !Error
    // Encodes this timestamp as a MessagePack `Ext` (`type = -1`) in shortest 32/64/96-bit form.
    + fn to_ext() Ext
}

Timestamp

A MessagePack Timestamp extension value (ext type -1).

Stores seconds since the Unix epoch (1970-01-01T00:00:00Z) and non-negative nanoseconds
in the range 0 .. 999_999_999. Encodes automatically in the shortest of the 32-bit,
64-bit, or 96-bit timestamp formats.

nanoseconds

Sub-second nanoseconds in 0 .. 999_999_999.

seconds

Whole seconds since the Unix epoch (may be negative for dates before 1970).

equals

Returns true when both timestamps represent the exact same instant.

from_datetime

Converts a time.DateTime to a Timestamp (microsecond precision).

from_ext

Decodes a Timestamp from a MessagePack Ext (must have type == -1 and 4, 8, or 12 bytes).

new

Creates a validated Timestamp, throwing .invalid_format if nanoseconds > 999_999_999.

to_datetime

Converts this Timestamp to a UTC time.DateTime (truncated to microseconds).

to_ext

Encodes this timestamp as a MessagePack Ext (type = -1) in shortest 32/64/96-bit form.

// A dynamically typed MessagePack value covering every type in the MessagePack specification.
+ class Value {
    // The MessagePack kind held by this value.
    ~ kind: Kind

    // Returns the array items held, or an empty array when not an array.
    + get array: Array[Value]
    // Returns the array items held, throwing `.type_mismatch` otherwise.
    + fn array_value() Array[Value] !Error
    // Returns the binary bytes held, or `""` when not binary.
    + get bin: String
    // Returns the binary bytes held, throwing `.type_mismatch` otherwise.
    + fn bin_value() String !Error
    // Returns the boolean held, or `false` if not a boolean.
    + get bool: bool
    // Returns the boolean held, throwing `.type_mismatch` otherwise.
    + fn bool_value() bool !Error
    // Encodes this value to MessagePack bytes.
    + fn encode() String
    // Encodes this value to MessagePack bytes and writes them to `out`.
    + fn encode_into(out: Writer) uint !io:IoError
    // Returns the ordered map entries held, or an empty array when not a map.
    + get entries: Array[MapEntry]
    // Returns the ordered map entries held, throwing `.type_mismatch` otherwise.
    + fn entries_value() Array[MapEntry] !Error
    // Deep structural equality; backs `==`.
    + fn equals(other: Value) bool
    // Returns the extension value held, or a zero `Ext` when not an extension.
    + get ext: Ext
    // Returns the extension value held, throwing `.type_mismatch` otherwise.
    + fn ext_value() Ext !Error
    // Returns the number held as `f64`, or `0.0` when not a number.
    + get float: f64
    // Returns the number held as `f32`, or `0.0` when not a number.
    + get float32: f32
    // Returns the number held as `f32`, throwing `.type_mismatch` on overflow or non-number.
    + fn float32_value() f32 !Error
    // Returns the number held as `f64`, accepting `float`, `int`, or `uint`.
    + fn float_value() f64 !Error
    // Creates an array value (`array`).
    + static fn from_array(items: Array[Value] (.{})) Value
    // Creates a binary byte-array value (`bin`).
    + static fn from_bin(v: local &[u8]) Value
    // Creates a boolean value.
    + static fn from_bool(v: bool) Value
    // Creates a map value (`map`) from an ordered list of `MapEntry` pairs (supports non-string keys).
    + static fn from_entries(entries: Array[MapEntry] (.{})) Value
    // Creates an extension value (`ext`).
    + static fn from_ext(ext_type: i8, data: local &[u8]) Value
    // Creates a 32-bit floating-point value (encoded as MessagePack `float 32`).
    + static fn from_f32(v: f32) Value
    // Creates a 64-bit floating-point value (encoded as MessagePack `float 64`).
    + static fn from_f64(v: f64) Value
    // Creates a 64-bit floating-point value.
    + static fn from_float(v: f64) Value
    // Creates a signed 64-bit integer value.
    + static fn from_int(v: i64) Value
    // Creates a map value (`map`) from a string-keyed `Map[Value]`.
    + static fn from_map(items: Map[Value]) Value
    // Creates a UTF-8 string value (`str`).
    + static fn from_str(v: String) Value
    // Creates a Timestamp extension value (`ext` type `-1`).
    + static fn from_timestamp(ts: Timestamp) Value
    // Creates an unsigned 64-bit integer value.
    + static fn from_uint(v: u64) Value
    // Returns the array element at `key` or the map value for string `key`, or `Value.nil()` when absent.
    + fn get(key: String | uint) Value
    // Looks up a map entry by an arbitrary `Value` key (supports integer, bool, binary, or compound keys).
    + fn get_key(key: Value) Value !Error
    // Returns true when this value is a map containing string key `key`.
    + fn has(key: String) bool
    // Returns the integer held as `i64`, or `0` when not convertible.
    + get int: i64
    // Returns the integer held as `i64`, accepting `int` or `uint <= i64.$max`.
    + fn int_value() i64 !Error
    // Returns true when the value is an array.
    + get is_array: bool
    // Returns true when the value is binary data (`bin`).
    + get is_bin: bool
    // Returns true when the value is a boolean.
    + get is_bool: bool
    // Returns true when the value is an extension (`ext`).
    + get is_ext: bool
    // Returns true when the value is a float (`f32` or `f64`).
    + get is_float: bool
    // Returns true when the value is specifically a 32-bit float.
    + get is_float32: bool
    // Returns true when the value is specifically a 64-bit float.
    + get is_float64: bool
    // Returns true when the value is stored as a signed integer.
    + get is_int: bool
    // Returns true when the value is either a signed or unsigned integer.
    + get is_integer: bool
    // Returns true when the value is a map.
    + get is_map: bool
    // Returns true when the value is `nil`.
    + get is_nil: bool
    // Returns true when the value is any integer or float.
    + get is_number: bool
    // Returns true when the value is a UTF-8 string (`str`).
    + get is_str: bool
    // Returns true when the value is a Timestamp extension (`ext` with `type == -1`).
    + get is_timestamp: bool
    // Returns true when the value is stored as an unsigned integer.
    + get is_uint: bool
    // Returns the kind name: `"nil"`, `"bool"`, `"int"`, `"uint"`, `"float"`, `"str"`, `"bin"`, `"array"`, `"map"`, or `"ext"`.
    + fn kind_name() String
    // Returns byte length for `str`/`bin`/`ext`, item count for `array`/`map`, or `0` otherwise.
    + get length: uint
    // Returns string-keyed entries as a `Map[Value]`, or an empty map when not a map.
    + get map: Map[Value]
    // Returns string-keyed entries as a `Map[Value]`, throwing `.type_mismatch` when not a map.
    + fn map_value() Map[Value] !Error
    // Creates a `nil` value.
    + static fn nil() Value
    // Returns the UTF-8 string held, or `""` when not a string.
    + get str: String
    // Returns the UTF-8 string held, throwing `.type_mismatch` otherwise.
    + fn str_value() String !Error
    // Alias for `str`: returns the UTF-8 string held, or `""` when not a string.
    + get string: String
    // Decodes a `Timestamp` from this value if it is an `ext` with `type == -1`.
    + fn timestamp_value() Timestamp !Error
    // Converts this MessagePack `Value` into a strongly typed Valk value `T`.
    + fn to_type[T]() T !Error
    // Returns the integer held as `u64`, or `0` when negative or not an integer.
    + get uint: u64
    // Returns the integer held as `u64`, accepting `uint` or non-negative `int`.
    + fn uint_value() u64 !Error
}

Value

A dynamically typed MessagePack value covering every type in the MessagePack specification.

Supports indexing with value["key"] (for maps) and value[index] (for arrays),
returning Value.nil() when absent. Use *_value() methods for strict typed extraction.

kind

The MessagePack kind held by this value.

array

Returns the array items held, or an empty array when not an array.

array_value

Returns the array items held, throwing .type_mismatch otherwise.

bin

Returns the binary bytes held, or "" when not binary.

bin_value

Returns the binary bytes held, throwing .type_mismatch otherwise.

bool

Returns the boolean held, or false if not a boolean.

bool_value

Returns the boolean held, throwing .type_mismatch otherwise.

encode

Encodes this value to MessagePack bytes.

encode_into

Encodes this value to MessagePack bytes and writes them to out.

entries

Returns the ordered map entries held, or an empty array when not a map.

entries_value

Returns the ordered map entries held, throwing .type_mismatch otherwise.

equals

Deep structural equality; backs ==.

Signed and unsigned integers representing the same numeric value compare equal.

ext

Returns the extension value held, or a zero Ext when not an extension.

ext_value

Returns the extension value held, throwing .type_mismatch otherwise.

float

Returns the number held as f64, or 0.0 when not a number.

float32

Returns the number held as f32, or 0.0 when not a number.

float32_value

Returns the number held as f32, throwing .type_mismatch on overflow or non-number.

float_value

Returns the number held as f64, accepting float, int, or uint.

from_array

Creates an array value (array).

from_bin

Creates a binary byte-array value (bin).

from_bool

Creates a boolean value.

from_entries

Creates a map value (map) from an ordered list of MapEntry pairs (supports non-string keys).

from_ext

Creates an extension value (ext).

from_f32

Creates a 32-bit floating-point value (encoded as MessagePack float 32).

from_f64

Creates a 64-bit floating-point value (encoded as MessagePack float 64).

from_float

Creates a 64-bit floating-point value.

from_int

Creates a signed 64-bit integer value.

from_map

Creates a map value (map) from a string-keyed Map[Value].

from_str

Creates a UTF-8 string value (str).

from_timestamp

Creates a Timestamp extension value (ext type -1).

from_uint

Creates an unsigned 64-bit integer value.

get

Returns the array element at key or the map value for string key, or Value.nil() when absent.

Backs value[key].

get_key

Looks up a map entry by an arbitrary Value key (supports integer, bool, binary, or compound keys).

Throws .type_mismatch when this value is not a map, or .missing_field when no matching key exists.

has

Returns true when this value is a map containing string key key.

int

Returns the integer held as i64, or 0 when not convertible.

int_value

Returns the integer held as i64, accepting int or uint <= i64.$max.

is_array

Returns true when the value is an array.

is_bin

Returns true when the value is binary data (bin).

is_bool

Returns true when the value is a boolean.

is_ext

Returns true when the value is an extension (ext).

is_float

Returns true when the value is a float (f32 or f64).

is_float32

Returns true when the value is specifically a 32-bit float.

is_float64

Returns true when the value is specifically a 64-bit float.

is_int

Returns true when the value is stored as a signed integer.

is_integer

Returns true when the value is either a signed or unsigned integer.

is_map

Returns true when the value is a map.

is_nil

Returns true when the value is nil.

is_number

Returns true when the value is any integer or float.

is_str

Returns true when the value is a UTF-8 string (str).

is_timestamp

Returns true when the value is a Timestamp extension (ext with type == -1).

is_uint

Returns true when the value is stored as an unsigned integer.

kind_name

Returns the kind name: "nil", "bool", "int", "uint", "float", "str", "bin", "array", "map", or "ext".

length

Returns byte length for str/bin/ext, item count for array/map, or 0 otherwise.

map

Returns string-keyed entries as a Map[Value], or an empty map when not a map.

map_value

Returns string-keyed entries as a Map[Value], throwing .type_mismatch when not a map.

nil

Creates a nil value.

str

Returns the UTF-8 string held, or "" when not a string.

str_value

Returns the UTF-8 string held, throwing .type_mismatch otherwise.

string

Alias for str: returns the UTF-8 string held, or "" when not a string.

timestamp_value

Decodes a Timestamp from this value if it is an ext with type == -1.

to_type

Converts this MessagePack Value into a strongly typed Valk value T.

Supports primitives, strings, Binary, Ext, Timestamp, time.DateTime,
json.Value, nullable types, enums, containers (Array, HashMap, FlatMap,
HashSet, Deque), structs, and classes.

Field tags on classes and structs control mapping:

  • $tag(msgpack: "name") / `msgpack: "name"` renames the map key.
  • $tag(msgpack: "-") skips decoding and uses the field's default value.
  • $tag(omitempty) allows missing or nil keys when the field has a default value.

Types implementing static fn from_msgpack(value: Value) SELF !Error use that hook.

uint

Returns the integer held as u64, or 0 when negative or not an integer.

uint_value

Returns the integer held as u64, accepting uint or non-negative int.