Documentation
¶
Overview ¶
Package marshaling provides utilities for marshaling and unmarshaling messages and other types.
Index ¶
- func MarshalMessageType(ma *Marshaler, mt message.Type) (string, error)
- func UnmarshalMessage(ma *Marshaler, p Packet) (dogma.Message, error)
- func UnmarshalMessageType(ma *Marshaler, n string) (message.Type, error)
- func UnmarshalMessageTypeFromMediaType(ma *Marshaler, mt string) (message.Type, error)
- type Codec
- type CodecCapabilities
- type Marshaler
- func (m *Marshaler) Marshal(v interface{}) (Packet, error)
- func (m *Marshaler) MarshalType(rt reflect.Type) (string, error)
- func (m *Marshaler) Unmarshal(p Packet) (interface{}, error)
- func (m *Marshaler) UnmarshalType(n string) (reflect.Type, error)
- func (m *Marshaler) UnmarshalTypeFromMediaType(mt string) (reflect.Type, error)
- type Packet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalMessageType ¶
MarshalMessageType marshals a message type to its portable representation.
func UnmarshalMessage ¶
UnmarshalMessage returns a message from its binary representation.
func UnmarshalMessageType ¶
UnmarshalMessageType unmarshals a message type from its portable representation.
Types ¶
type Codec ¶
type Codec interface {
// Query returns the capabilities of the codec for the given types.
Query(types []reflect.Type) CodecCapabilities
// MediaType returns the media-type used to identify values encoded by this
// codec.
MediaType() string
// Marshal returns the binary representation of v.
Marshal(v interface{}) ([]byte, error)
// Unmarshal decodes a binary representation into v.
Unmarshal(data []byte, v interface{}) error
}
Codec is an interface for encoding and decoding values.
type CodecCapabilities ¶
type CodecCapabilities struct {
// Types is a map of the support types to their portable type name.
Types map[reflect.Type]string
}
CodecCapabilities describes the capabilities of a codec as it relates to specific Go types.
type Marshaler ¶
type Marshaler struct {
// contains filtered or unexported fields
}
Marshaler uses a set of codecs to marshal and unmarshal values.
func NewMarshaler ¶
NewMarshaler returns a new marshaler that uses the given set of codecs to marshal and unmarshal values.
The codecs are given in order of preference.
func NewMarshalerForApplication ¶
func NewMarshalerForApplication( cfg *config.ApplicationConfig, codecs []Codec, ) (*Marshaler, error)
NewMarshalerForApplication returns a new marshaler for the given application config.
func (*Marshaler) MarshalType ¶
MarshalType marshals a type to its portable representation.
func (*Marshaler) UnmarshalType ¶
UnmarshalType marshals a type from its portable representation.
type Packet ¶
type Packet struct {
// MediaType is a MIME media-type describing the content and encoding of the
// binary data.
MediaType string
// Data is the marshaled binary data.
Data []byte
}
Packet is a container of marshaled data and its related meta-data.
func MarshalMessage ¶
MarshalMessage returns a binary representation of a message.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package json contains marshaler implementations that use Go's standard JSON marshaling.
|
Package json contains marshaler implementations that use Go's standard JSON marshaling. |
|
Package protobuf contains marshaler implemenentations for protocol buffers types.
|
Package protobuf contains marshaler implemenentations for protocol buffers types. |