xml

package
v0.12.0 Latest Latest
Warning

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

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

README

xml

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

Package xml registers the XML 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/xml"

The codec is the standard library's encoding/xml, with its struct tags and its rules: a value marshals as an element, a struct names it with an XMLName field or its type name. It streams, one element per Encode or Decode.

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.3.*; match them with errs.HasCode, or the sentinels with errors.Is:

CodeMarshalFailed    0.3.3.1  encoding/xml could not encode the value
CodeUnmarshalFailed  0.3.3.2  the input is not XML the target can hold
CodeSizeExceeded     0.3.3.3  a value longer than NewBoundedDecoder's byte ceiling

No error message quotes the input.

Index

Constants

const CodeMarshalFailed errs.Code = 197377

CodeMarshalFailed is 0.3.3.1: encoding/xml could not encode the value.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/xml.CodeXMLMarshalFailed.

Code 0.3.3.1

const CodeSizeExceeded errs.Code = 197379

CodeSizeExceeded is 0.3.3.3: a value longer than NewBoundedDecoder's byte ceiling (#891).

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/xml.CodeXMLSizeExceeded.

Code 0.3.3.3

const CodeUnmarshalFailed errs.Code = 197378

CodeUnmarshalFailed is 0.3.3.2: the input is not XML the target can hold.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/xml.CodeXMLUnmarshalFailed.

Code 0.3.3.2

const Format = "xml"

Format is the name XML 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

var MarshalFailed *errs.Error

MarshalFailed is the sentinel of CodeMarshalFailed.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/xml.MarshalFailed.

Code 0.3.3.1 · reason MARSHAL_FAILED · public "XML encoding failed"

var SizeExceeded *errs.Error

SizeExceeded is the sentinel of CodeSizeExceeded.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/xml.SizeExceeded.

Code 0.3.3.3 · reason SIZE_EXCEEDED · public "XML input exceeds a size limit"

var UnmarshalFailed *errs.Error

UnmarshalFailed is the sentinel of CodeUnmarshalFailed.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/xml.UnmarshalFailed.

Code 0.3.3.2 · reason UNMARSHAL_FAILED · public "XML decoding failed"

Generated from docs/api by tools/genindex.

Documentation

Overview

Package xml registers the XML 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/xml"

The codec is the standard library's encoding/xml, with its struct tags and its rules: a value marshals as an element, a struct names it with an XMLName field or its type name. It streams, one element per Encode or Decode.

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.3.*; match them with errs.HasCode, or the sentinels with errors.Is:

CodeMarshalFailed    0.3.3.1  encoding/xml could not encode the value
CodeUnmarshalFailed  0.3.3.2  the input is not XML the target can hold
CodeSizeExceeded     0.3.3.3  a value longer than NewBoundedDecoder's byte ceiling

No error message quotes the input.

Index

Constants

View Source
const (
	// CodeMarshalFailed is 0.3.3.1: encoding/xml could not encode the value.
	CodeMarshalFailed errs.Code = corexml.CodeXMLMarshalFailed
	// CodeUnmarshalFailed is 0.3.3.2: the input is not XML the target can
	// hold.
	CodeUnmarshalFailed errs.Code = corexml.CodeXMLUnmarshalFailed
	// CodeSizeExceeded is 0.3.3.3: a value longer than NewBoundedDecoder's byte ceiling (#891).
	CodeSizeExceeded errs.Code = corexml.CodeXMLSizeExceeded
)

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

View Source
const Format = "xml"

Format is the name XML 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 = corexml.MarshalFailed
	// UnmarshalFailed is the sentinel of [CodeUnmarshalFailed].
	UnmarshalFailed = corexml.UnmarshalFailed
	// SizeExceeded is the sentinel of [CodeSizeExceeded].
	SizeExceeded = corexml.SizeExceeded
)

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