Documentation ¶
Index ¶
Constants ¶
const ( TypeMessagePackStr = "msgp" TypeProtocolBufferStr = "protobuf" 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 ¶
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 ProtocolBufferEncoder ¶ added in v0.2.0
type ProtocolBufferEncoder struct {
// contains filtered or unexported fields
}
ProtocolBufferEncoder defines the standard implementation for the ProtocolBuffer Encoding Type, using a single proto.Buffer for all marshal calls, of the github.com/gogo/protobuf/proto internally.
func NewProtocolBufferEncoder ¶ added in v0.2.0
func NewProtocolBufferEncoder() *ProtocolBufferEncoder
NewProtocolBufferEncoder creates a new ProtocolBufferEncoder, allocating a new proto buffer used for marshaling.
See ProtocolBufferEncoder for more information.
func (*ProtocolBufferEncoder) Marshal ¶ added in v0.2.0
func (encoder *ProtocolBufferEncoder) Marshal(v interface{}) ([]byte, error)
Marshal implements Encoder.Marshal
func (*ProtocolBufferEncoder) Unmarshal ¶ added in v0.2.0
func (encoder *ProtocolBufferEncoder) Unmarshal(data []byte, v interface{}) error
Unmarshal implements encoder.Unmarshal
type ProtocolBufferMarshaler ¶ added in v0.2.0
type ProtocolBufferMarshaler interface {
ProtocolBufferMarshal(ProtocolBufferWriter) error
}
ProtocolBufferMarshaler is the interface implemented by types that know how to write themselves as ProtocolBuffer Messages into a given ProtocolBufferWriter.
type ProtocolBufferReader ¶ added in v0.2.0
ProtocolBufferReader is used by ProtocolBufferUnmarshaler implementations to unmarshal (=read) their encoded form as a given ProtocolBuffer Message
type ProtocolBufferUnmarshaler ¶ added in v0.2.0
type ProtocolBufferUnmarshaler interface {
ProtocolBufferUnmarshal(ProtocolBufferReader) error
}
ProtocolBufferUnmarshaler is the interface implemented by types that know how to read themselves as ProtocolBuffer Messages from a given ProtocolBufferReader.
type ProtocolBufferWriter ¶ added in v0.2.0
ProtocolBufferWriter is used by ProtocolBufferMarshaler implementations to marshal (=write) themselves as a ProtocolBuffer Message.