iocodec

package
v0.0.0-...-60fd75b Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: BSD-3-Clause Imports: 6 Imported by: 4

Documentation

Overview

Package iocodec provides multiple input decoders and output encoders.

Index

Constants

This section is empty.

Variables

View Source
var DefaultDecoders = DecoderGroup{
	"xml":  DecoderMakerFunc(func(r io.Reader) Decoder { return xml.NewDecoder(r) }),
	"json": DecoderMakerFunc(func(r io.Reader) Decoder { return json.NewDecoder(r) }),
	"yaml": DecoderMakerFunc(func(r io.Reader) Decoder { return &yamlDecoder{r} }),
}

DefaultDecoders contains the default list of decoders per MIME type.

View Source
var DefaultEncoders = EncoderGroup{
	"xml":        EncoderMakerFunc(func(w io.Writer) Encoder { return &xmlEncoder{w} }),
	"json":       EncoderMakerFunc(func(w io.Writer) Encoder { return &jsonEncoder{w, false} }),
	"prettyjson": EncoderMakerFunc(func(w io.Writer) Encoder { return &jsonEncoder{w, true} }),
	"yaml":       EncoderMakerFunc(func(w io.Writer) Encoder { return &yamlEncoder{w} }),
}

DefaultEncoders contains the default list of encoders per MIME type.

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

A Decoder decodes data into v.

type DecoderGroup

type DecoderGroup map[string]DecoderMaker

A DecoderGroup maps MIME types to DecoderMakers.

type DecoderMaker

type DecoderMaker interface {
	NewDecoder(r io.Reader) Decoder
}

A DecoderMaker creates and returns a new Decoder.

type DecoderMakerFunc

type DecoderMakerFunc func(r io.Reader) Decoder

DecoderMakerFunc is an adapter for creating DecoderMakers from functions.

func (DecoderMakerFunc) NewDecoder

func (f DecoderMakerFunc) NewDecoder(r io.Reader) Decoder

NewDecoder implements the DecoderMaker interface.

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

An Encoder encodes data from v.

type EncoderGroup

type EncoderGroup map[string]EncoderMaker

An EncoderGroup maps MIME types to EncoderMakers.

type EncoderMaker

type EncoderMaker interface {
	NewEncoder(w io.Writer) Encoder
}

An EncoderMaker creates and returns a new Encoder.

type EncoderMakerFunc

type EncoderMakerFunc func(w io.Writer) Encoder

EncoderMakerFunc is an adapter for creating EncoderMakers from functions.

func (EncoderMakerFunc) NewEncoder

func (f EncoderMakerFunc) NewEncoder(w io.Writer) Encoder

NewEncoder implements the EncoderMaker interface.

Jump to

Keyboard shortcuts

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