codec

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	//Encode(io.Writer, interface{}) error
	//Decode(io.Reader, interface{}) error
	Encoder
	Decoder
}

type Decoder

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

type Encoder

type Encoder interface {
	Encode(io.Writer, interface{}) error
}

type HTMLEncoder

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

func NewHTMLEncoder

func NewHTMLEncoder(tmpl *template.Template, name string) *HTMLEncoder

func (*HTMLEncoder) Encode

func (c *HTMLEncoder) Encode(w io.Writer, v interface{}) error

type JSONCodec

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

func NewJSONCodec

func NewJSONCodec(opts ...Option) *JSONCodec

func (*JSONCodec) Decode

func (c *JSONCodec) Decode(r io.Reader, v interface{}) error

func (*JSONCodec) Encode

func (c *JSONCodec) Encode(w io.Writer, v interface{}) error

type Option

type Option func(*Options)

func Format

func Format(format string) Option

func Indent

func Indent(indent bool) Option

func UseNumber

func UseNumber(useNumber bool) Option

type Options

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

type ProtobufCodec

type ProtobufCodec struct {
}
type MsgpackCodec struct {
	w io.Writer
	h codec.Handle
}
func NewMsgpackCodec() *MsgpackCodec {
	return &MsgpackCodec{
		w: ioutil.Discard,
		h: new(codec.MsgpackHandle),
	}
}
func (c *MsgpackCodec) Encode(w io.Writer, v interface{}) error {
	// TODO encoder pool
	return codec.NewEncoder(w, c.h).Encode(v)
}
func (c *MsgpackCodec) Decode(r io.Reader, v interface{}) error {
	// TODO decoder pool
	return codec.NewDecoder(r, c.h).Decode(v)
}

func (*ProtobufCodec) Decode

func (c *ProtobufCodec) Decode(r io.Reader, v interface{}) error

func (*ProtobufCodec) Encode

func (c *ProtobufCodec) Encode(w io.Writer, v interface{}) error

type StringCodec

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

func NewStringCodec

func NewStringCodec(opts ...Option) *StringCodec

func (*StringCodec) Decode

func (c *StringCodec) Decode(r io.Reader, v interface{}) error

func (*StringCodec) Encode

func (c *StringCodec) Encode(w io.Writer, v interface{}) error

type XMLCodec

type XMLCodec struct {
}

func NewPBCodec

func NewPBCodec() *XMLCodec

func NewXMLCodec

func NewXMLCodec(opts ...Option) *XMLCodec

func (*XMLCodec) Decode

func (c *XMLCodec) Decode(r io.Reader, v interface{}) error

func (*XMLCodec) Encode

func (c *XMLCodec) Encode(w io.Writer, v interface{}) error

Jump to

Keyboard shortcuts

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