Documentation
¶
Overview ¶
Package yamlwire provides bounded, explicit YAML 1.2 decoding and deterministic encoding.
Decoding rejects duplicate keys and multiple documents by default. Anchors, aliases, and merge keys are supported with resource limits; callers can reject aliases or merge keys for protocols that do not permit them. YAML is not included in wire.DetectFormat because reliable detection from arbitrary text is not possible.
Index ¶
- Constants
- Variables
- func Decode(payload []byte, target any, options DecodeOptions) error
- func DecodeReader(reader io.Reader, target any, options DecodeOptions) error
- func Encode(value any, options EncodeOptions) ([]byte, error)
- func EncodeWriter(writer io.Writer, value any, options EncodeOptions) error
- type DecodeOptions
- type EncodeOptions
Constants ¶
const DefaultMaxBytes int64 = 1 << 20
DefaultMaxBytes is the default maximum YAML stream size.
Variables ¶
var ErrPayloadTooLarge = errors.New("payload exceeds size limit")
ErrPayloadTooLarge identifies YAML streams over the configured byte limit.
Functions ¶
func Decode ¶
func Decode(payload []byte, target any, options DecodeOptions) error
Decode parses a bounded YAML stream into target.
func DecodeReader ¶
func DecodeReader(reader io.Reader, target any, options DecodeOptions) error
DecodeReader reads a bounded YAML stream and decodes it into target.
func Encode ¶
func Encode(value any, options EncodeOptions) ([]byte, error)
Encode serializes value deterministically using sorted mapping keys.
func EncodeWriter ¶
func EncodeWriter(writer io.Writer, value any, options EncodeOptions) error
EncodeWriter serializes value and writes one complete YAML document.
Types ¶
type DecodeOptions ¶
type DecodeOptions struct {
MaxBytes int64
MaxDepth int
MaxAliases int
DisallowUnknownFields bool
AllowDuplicateKeys bool
AllowMultipleDocuments bool
DisallowAliases bool
DisallowMergeKeys bool
}
DecodeOptions controls YAML parsing, interoperability, and resource limits. Zero limits retain safe library defaults. AllowMultipleDocuments requires a pointer to a slice and decodes every document into that slice.
type EncodeOptions ¶
EncodeOptions controls deterministic YAML serialization.