encoding

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeMessagePackStr = "msgp"
	TypeJSONStr        = "json"
)

string versions of the Type enumeration values

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder interface {
	Marshal(interface{}) ([]byte, error)
	Unmarshal([]byte, interface{}) error
}

Encoder defines a universal interface that all EncodingType implementations have to adhere.

func NewEncoder

func NewEncoder(et Type) (Encoder, error)

NewEncoder creates an Encoder, using the standard Encoder implementation matched for the given Encoding Type.

type JSONEncoder

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

JSONEncoder defines the standard implementation for the JSON Encoding Type, using a single bytes.Buffer for all marshal calls, and using the Encoder type of the std encoding/json pkg internally.

func NewJSONEncoder

func NewJSONEncoder() *JSONEncoder

NewJSONEncoder creates a new JSONEncoder, allocating a new bytes buffer and a (std) JSON Encoder (encapsulating the buffer).

See JSONEncoder for more information.

func (JSONEncoder) Marshal

func (encoder JSONEncoder) Marshal(v interface{}) ([]byte, error)

Marshal implements Encoder.Marshal

func (JSONEncoder) Unmarshal

func (encoder JSONEncoder) Unmarshal(data []byte, v interface{}) error

Unmarshal implements encoder.Unmarshal

type MessagePackEncoder

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

MessagePackEncoder defines the standard implementation for the MessagePack Encoding Type, using a single bytes.Buffer for all marshal calls, and using a single shared instance of the Reader/Writer types of the github.com/tinylib/msgp/msgp pkg internally.

func NewMessagePackEncoder

func NewMessagePackEncoder() *MessagePackEncoder

NewMessagePackEncoder creates a new MessagePackEncoder, allocating a new bytes buffer and a MessagePack Writer (encapsulating the buffer).

See MessagePackEncoder for more information.

func (MessagePackEncoder) Marshal

func (encoder MessagePackEncoder) Marshal(v interface{}) ([]byte, error)

Marshal implements Encoder.Marshal

func (MessagePackEncoder) Unmarshal

func (encoder MessagePackEncoder) Unmarshal(data []byte, v interface{}) error

Unmarshal implements encoding.Unmarshal

type Type

type Type uint8

Type identifies a type of Encoder

const (
	TypeMessagePack Type = iota
	TypeJSON
)

the Type enumeration values

func (*Type) LoadString

func (et *Type) LoadString(str string) error

LoadString implements StringLoader.LoadString, piggy-backing on the flag.Value.Set implementation of this type.

func (*Type) Set

func (et *Type) Set(str string) error

Set implements flag.Value.Set

func (Type) String

func (et Type) String() string

String implements flag.Value.String and fmt.Stringer.String

func (Type) Type

func (et Type) Type() string

Type implements pflag.Value.Type

Jump to

Keyboard shortcuts

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