msgpack

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 3 Imported by: 0

README

msgpack

import "github.com/kitsunium/sdk/pkg/v1/data/codec/msgpack"

Package msgpack registers the MessagePack codec with the SDK's codec registry — and no other codec — when it is imported (ADR 0134):

import _ "github.com/kitsunium/sdk/pkg/v1/data/codec/msgpack"

The codec is the msgpack.org specification written on the standard library: maps, arrays, the integer and float families, strings, binary, the timestamp extension, struct fields by their msgpack tag, and types that marshal themselves. Input is bounded in size and depth, and read without allocating what a declared length claims before the bytes are there. It streams.

Everything that dispatches through the registry by format name then reads and writes it: the codec package's Marshal and Unmarshal, config.FSSource and i18n.LoadFS. Importing github.com/kitsunium/sdk/pkg/v1/data/codec instead registers every format the SDK ships; this package links this one codec, the core package declaring its codes and the standard library, and nothing else. Importing both is harmless: a format is registered by the package that implements it, which Go initialises once however many packages import it.

Errors

Failures carry the range 0.3.7.*; match them with errs.HasCode, or the sentinels with errors.Is:

CodeMarshalFailed    0.3.7.1  a value MessagePack cannot represent, nesting past the bound, a writer's failure
CodeUnmarshalFailed  0.3.7.2  malformed or truncated input, past a bound, or a value the target cannot hold

No error message quotes the input.

Index

Constants

The error codes, range 0.3.7.*, declared in the core (ADR 0160).

const (
    // CodeMarshalFailed is 0.3.7.1: a value MessagePack cannot represent,
    // nesting past the bound, a writer's failure.
    CodeMarshalFailed errs.Code = coremsgpack.CodeMsgPackMarshalFailed
    // CodeUnmarshalFailed is 0.3.7.2: malformed or truncated input, past a
    // bound, or a value the target cannot hold.
    CodeUnmarshalFailed errs.Code = coremsgpack.CodeMsgPackUnmarshalFailed
)

Format is the name MessagePack is registered under. It is an untyped constant, so it goes wherever a format name is taken — the codec package's Marshal, config.FSSource's string, i18n.LoadFS's codec.Format — without a conversion.

const Format = "msgpack"

Variables

The sentinels, for errors.Is: each carries the code of the same name.

var (
    // MarshalFailed is the sentinel of [CodeMarshalFailed].
    MarshalFailed = coremsgpack.MarshalFailed
    // UnmarshalFailed is the sentinel of [CodeUnmarshalFailed].
    UnmarshalFailed = coremsgpack.UnmarshalFailed
)

Generated by gomarkdoc

Documentation

Overview

Package msgpack registers the MessagePack codec with the SDK's codec registry — and no other codec — when it is imported (ADR 0134):

import _ "github.com/kitsunium/sdk/pkg/v1/data/codec/msgpack"

The codec is the msgpack.org specification written on the standard library: maps, arrays, the integer and float families, strings, binary, the timestamp extension, struct fields by their msgpack tag, and types that marshal themselves. Input is bounded in size and depth, and read without allocating what a declared length claims before the bytes are there. It streams.

Everything that dispatches through the registry by format name then reads and writes it: the codec package's Marshal and Unmarshal, config.FSSource and i18n.LoadFS. Importing github.com/kitsunium/sdk/pkg/v1/data/codec instead registers every format the SDK ships; this package links this one codec, the core package declaring its codes and the standard library, and nothing else. Importing both is harmless: a format is registered by the package that implements it, which Go initialises once however many packages import it.

Errors

Failures carry the range 0.3.7.*; match them with errs.HasCode, or the sentinels with errors.Is:

CodeMarshalFailed    0.3.7.1  a value MessagePack cannot represent, nesting past the bound, a writer's failure
CodeUnmarshalFailed  0.3.7.2  malformed or truncated input, past a bound, or a value the target cannot hold

No error message quotes the input.

Index

Constants

View Source
const (
	// CodeMarshalFailed is 0.3.7.1: a value MessagePack cannot represent,
	// nesting past the bound, a writer's failure.
	CodeMarshalFailed errs.Code = coremsgpack.CodeMsgPackMarshalFailed
	// CodeUnmarshalFailed is 0.3.7.2: malformed or truncated input, past a
	// bound, or a value the target cannot hold.
	CodeUnmarshalFailed errs.Code = coremsgpack.CodeMsgPackUnmarshalFailed
)

The error codes, range 0.3.7.*, declared in the core (ADR 0160).

View Source
const Format = "msgpack"

Format is the name MessagePack is registered under. It is an untyped constant, so it goes wherever a format name is taken — the codec package's Marshal, config.FSSource's string, i18n.LoadFS's codec.Format — without a conversion.

Variables

View Source
var (
	// MarshalFailed is the sentinel of [CodeMarshalFailed].
	MarshalFailed = coremsgpack.MarshalFailed
	// UnmarshalFailed is the sentinel of [CodeUnmarshalFailed].
	UnmarshalFailed = coremsgpack.UnmarshalFailed
)

The sentinels, for errors.Is: each carries the code of the same name.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL