toml

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package toml declares an adapter for external TOML packages to accommodate for different implementations of data encoders and decoders. This limits the necessary code changes when swapping out implementations. This can possibly leave space for the user to configure the implementation they want to use.

Index

Constants

This section is empty.

Variables

View Source
var ErrTOMLMarshal = errors.New("failed to marshal TOML output")

ErrTOMLMarshal mean an error was raised when marshalling the output.

View Source
var ErrTOMLUnmarshal = errors.New("failed to unmarshal TOML input")

ErrTOMLUnmarshal means an error encountered when unmarshalling the input.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter unifies the external TOML library interface to confine any changes to external libraries confined to a particular place in code.

func NewAdapter

func NewAdapter(adapted DecodeEncoder) *Adapter

NewAdapter returns the adapted external library TOML functionalities.

func (*Adapter) Marshal

func (a *Adapter) Marshal(v any) ([]byte, error)

Marshal marshals the argument passed to the parameter v to a slice of bytes.

func (*Adapter) Unmarshal

func (a *Adapter) Unmarshal(r io.Reader, v any) error

Unmarshal unmarshals the input r into the reference pointer argument passed to the parameter v.

type DecodeEncoder

type DecodeEncoder interface {
	Decoder
	Encoder
}

DecodeEncoder defines the combined interface for both decoding and encoding TOML data.

type Decoder

type Decoder interface {
	Decode(io.Reader, any) error
}

Decoder defines the interface for decoding TOML data.

type Encoder

type Encoder interface {
	Encode(any) ([]byte, error)
}

Encoder defines the interface for encoding TOML data.

type GoTOML

type GoTOML struct {
	// contains filtered or unexported fields
}

GoTOML exposes the go-toml/v2 package functionality to that satisfies the decodeEncoder interface.

func NewGoTOML

func NewGoTOML(c GoTOMLConf) GoTOML

NewGoTOML returns a struct exposing the go-toml/v2 package functionality to that satisfies the decodeEncoder interface.

func (GoTOML) Decode

func (t GoTOML) Decode(r io.Reader, v any) error

Decode decodes the input r into the reference pointer argument passed to the parameter v.

func (GoTOML) Encode

func (t GoTOML) Encode(v any) ([]byte, error)

Encode encodes the argument passed to the parameter v as a slice of bytes.

type GoTOMLConf

type GoTOMLConf struct {
	Encoder struct {
		TablesInline    bool
		ArraysMultiline bool
		IndentSymbol    string
		IndentTables    bool
	}
}

GoTOMLConf specifies sensible configuration for the go-toml/v2 package.

Jump to

Keyboard shortcuts

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