protobuf

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package protobuf contains marshaler implemenentations for protocol buffers types.

Index

Constants

This section is empty.

Variables

View Source
var DefaultJSONMarshaler = &jsonpb.Marshaler{
	OrigName: true,
}

DefaultJSONMarshaler is the text marshaler used by JSONCodec if none is provided.

View Source
var DefaultJSONUnmarshaler = &jsonpb.Unmarshaler{
	AllowUnknownFields: true,
}

DefaultJSONUnmarshaler is the text marshaler used by JSONCodec if none is provided.

View Source
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) Marshal

func (c *JSONCodec) Marshal(v interface{}) ([]byte, error)

Marshal returns the binary representation of v.

func (*JSONCodec) MediaType

func (c *JSONCodec) MediaType() string

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.

func (*JSONCodec) Unmarshal

func (c *JSONCodec) Unmarshal(data []byte, v interface{}) error

Unmarshal decodes a binary representation into v.

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) Marshal

func (c *TextCodec) Marshal(v interface{}) ([]byte, error)

Marshal returns the binary representation of v.

func (*TextCodec) MediaType

func (c *TextCodec) MediaType() string

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.

func (*TextCodec) Unmarshal

func (c *TextCodec) Unmarshal(data []byte, v interface{}) error

Unmarshal decodes a binary representation into v.

Jump to

Keyboard shortcuts

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