encoding

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package encoding provides interfaces for configuration encoders and decoders.

Additional encoders can be added through the Register function. This allows for separation of concerns internally, but also for plugins to implement their own encoding.

Index

Constants

This section is empty.

Variables

View Source
var (
	// UnknownEncodingError is returned when an unknown encoding is requested using New.
	UnknownEncodingError = errors.New("unknown encoding requested")

	// IllFormattedVariable is returned when a payload contains a line that cannot be resolved to a config.Variable.
	IllFormattedVariable = errors.New("variable is incorrectly formatted")
)

Functions

func GetEncodings

func GetEncodings() []string

Get available Encoding names.

func Register

func Register(name string, encoding Encoding)

Register the given Encoding in a registry for New instances.

Types

type Decoder

type Decoder interface {
	Decode(payload []byte) ([]*config.Variable, error)
}

Allows to Decode a byte sequence into a list of config.Variable structs.

type Encoder

type Encoder interface {
	Encode(variables ...*config.Variable) ([]byte, error)
}

Allows to Encode config.Variable structs into a byte sequence.

type Encoding

type Encoding interface {
	Encoder
	Decoder
}

Shared interface Encoding for Encoder and Decoder.

func New

func New(format string) (Encoding, error)

Create a new Encoding for the given format.

Directories

Path Synopsis
Package json implements an encoder and decoder for a JSON representation of config.Variable.
Package json implements an encoder and decoder for a JSON representation of config.Variable.
Package text implements an encoder and decoder for a text based representation of config.Variable.
Package text implements an encoder and decoder for a text based representation of config.Variable.

Jump to

Keyboard shortcuts

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