pem

package
v0.3.0 Latest Latest
Warning

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

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

README

pem

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

Package pem registers the PEM 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/pem"

The codec is the standard library's encoding/pem, RFC 7468's textual armour: its native value is a *pem.Block — a type, headers and the bytes — and an Unmarshal target is a **pem.Block. Through the codec package's Marshal any other value is carried as the bytes of one JSON-typed block.

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

CodeMarshalFailed    0.3.10.1  encoding/pem refused to write the block
CodeUnmarshalFailed  0.3.10.2  no PEM block in the input
CodeValueInvalid     0.3.10.3  the value is not a *pem.Block, or the target a **pem.Block

No error message quotes the input.

Index

Constants

const CodeMarshalFailed errs.Code = 199169

CodeMarshalFailed is 0.3.10.1: encoding/pem refused to write the block.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/pem.CodePEMMarshalFailed.

Code 0.3.10.1

const CodeUnmarshalFailed errs.Code = 199170

CodeUnmarshalFailed is 0.3.10.2: no PEM block in the input.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/pem.CodePEMUnmarshalFailed.

Code 0.3.10.2

const CodeValueInvalid errs.Code = 199171

CodeValueInvalid is 0.3.10.3: the value is not a *pem.Block, or the target a **pem.Block.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/pem.CodePEMValueInvalid.

Code 0.3.10.3

const Format = "pem"

Format is the name PEM 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/pem.MarshalFailed.

Code 0.3.10.1 · reason MARSHAL_FAILED · public "PEM encoding failed"

var UnmarshalFailed *errs.Error

UnmarshalFailed is the sentinel of CodeUnmarshalFailed.

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

Code 0.3.10.2 · reason UNMARSHAL_FAILED · public "PEM decoding failed"

var ValueInvalid *errs.Error

ValueInvalid is the sentinel of CodeValueInvalid.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/pem.ValueInvalid.

Code 0.3.10.3 · reason VALUE_INVALID · public "PEM codec requires a *pem.Block value"

Generated from docs/api by tools/genindex.

Documentation

Overview

Package pem registers the PEM 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/pem"

The codec is the standard library's encoding/pem, RFC 7468's textual armour: its native value is a *pem.Block — a type, headers and the bytes — and an Unmarshal target is a **pem.Block. Through the codec package's Marshal any other value is carried as the bytes of one JSON-typed block.

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

CodeMarshalFailed    0.3.10.1  encoding/pem refused to write the block
CodeUnmarshalFailed  0.3.10.2  no PEM block in the input
CodeValueInvalid     0.3.10.3  the value is not a *pem.Block, or the target a **pem.Block

No error message quotes the input.

Index

Constants

View Source
const (
	// CodeMarshalFailed is 0.3.10.1: encoding/pem refused to write the block.
	CodeMarshalFailed errs.Code = corepem.CodePEMMarshalFailed
	// CodeUnmarshalFailed is 0.3.10.2: no PEM block in the input.
	CodeUnmarshalFailed errs.Code = corepem.CodePEMUnmarshalFailed
	// CodeValueInvalid is 0.3.10.3: the value is not a *pem.Block, or the
	// target a **pem.Block.
	CodeValueInvalid errs.Code = corepem.CodePEMValueInvalid
)

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

View Source
const Format = "pem"

Format is the name PEM 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 = corepem.MarshalFailed
	// UnmarshalFailed is the sentinel of [CodeUnmarshalFailed].
	UnmarshalFailed = corepem.UnmarshalFailed
	// ValueInvalid is the sentinel of [CodeValueInvalid].
	ValueInvalid = corepem.ValueInvalid
)

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