Documentation
¶
Overview ¶
Package protobuf contains marshaler implemenentations for protocol buffers types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultJSONMarshaler = &jsonpb.Marshaler{ OrigName: true, }
DefaultJSONMarshaler is the text marshaler used by JSONCodec if none is provided.
var DefaultJSONUnmarshaler = &jsonpb.Unmarshaler{ AllowUnknownFields: true, }
DefaultJSONUnmarshaler is the text marshaler used by JSONCodec if none is provided.
var DefaultTextMarshaler = &proto.TextMarshaler{ Compact: false, ExpandAny: true, }
DefaultTextMarshaler is the text marshaler used by TextCodec if none is provided.
Functions ¶
This section is empty.
Types ¶
type JSONCodec ¶
type JSONCodec struct {
// Marshaler is the JSON marshaler used to marshal messages.
// If it is nil, DefaultJSONMarshaler is used.
Marshaler *jsonpb.Marshaler
// Unmarshaler is the JSON unmarshaler used to unmarshal messages.
// If it is nil, DefaultJSONUnmarshaler is used.
Unmarshaler *jsonpb.Unmarshaler
// contains filtered or unexported fields
}
JSONCodec is an implementation of marshaling.Codec that marshals protocol buffers messages in text format.
func (*JSONCodec) MediaType ¶
MediaType returns the media-type used to identify values encoded by this codec.
func (JSONCodec) Query ¶
func (JSONCodec) Query(types []reflect.Type) marshaling.CodecCapabilities
Query returns the capabilities of the codec for the given types.
type NativeCodec ¶
type NativeCodec struct {
// contains filtered or unexported fields
}
NativeCodec is an implementation of marshaling.Codec that marshals protocol buffers messages in the native binary format.
func (*NativeCodec) Marshal ¶
func (c *NativeCodec) Marshal(v interface{}) ([]byte, error)
Marshal returns the binary representation of v.
func (*NativeCodec) MediaType ¶
func (c *NativeCodec) MediaType() string
MediaType returns the media-type used to identify values encoded by this codec.
func (NativeCodec) Query ¶
func (NativeCodec) Query(types []reflect.Type) marshaling.CodecCapabilities
Query returns the capabilities of the codec for the given types.
func (*NativeCodec) Unmarshal ¶
func (c *NativeCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal decodes a binary representation into v.
type TextCodec ¶
type TextCodec struct {
// Marshaler is the text marshaler used to marshal messages.
// If it is nil, DefaultTextMarshaler is used.
Marshaler *proto.TextMarshaler
// contains filtered or unexported fields
}
TextCodec is an implementation of marshaling.Codec that marshals protocol buffers messages in text format.
func (*TextCodec) MediaType ¶
MediaType returns the media-type used to identify values encoded by this codec.
func (TextCodec) Query ¶
func (TextCodec) Query(types []reflect.Type) marshaling.CodecCapabilities
Query returns the capabilities of the codec for the given types.