format

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package format bridges Codec[T] to concrete serialization formats (JSON, YAML, TOML).

A codec works with an intermediate representation (map[string]any) that is format-agnostic. Format wraps that intermediate layer so the same codec can read and write multiple wire formats without any changes to the codec itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format[T any] struct {
	// contains filtered or unexported fields
}

Format binds a Codec[T] to a specific serialization format. Use JSON, YAML, or TOML to construct one.

func JSON

func JSON[T any](c codex.Codec[T]) Format[T]

JSON returns a Format that reads and writes JSON.

func New

func New[T any](c codex.Codec[T], marshal func(any) ([]byte, error), unmarshal func([]byte) (