protolator

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepMarshalJSON

func DeepMarshalJSON(w io.Writer, msg proto.Message) error

DeepMarshalJSON marshals msg to w as JSON, but instead of marshaling bytes fields which contain nested marshaled messages as base64 (like the standard proto encoding), these nested messages are remarshaled as the JSON representation of those messages. This is done so that the JSON representation is as non-binary and human readable as possible.

func DeepUnmarshalJSON

func DeepUnmarshalJSON(r io.Reader, msg proto.Message) error

DeepUnmarshalJSON takes JSON output as generated by DeepMarshalJSON and decodes it into msg This includes re-marshaling the expanded nested elements to binary form

Types

type DecoratedProto

type DecoratedProto interface {
	// Underlying returns the underlying proto message which is being dynamically decorated
	Underlying() proto.Message
}

DecoreatedProto should be implemented by the dynamic wrappers applied by the Dynamic*FieldProto interfaces This is necessary for the proto system to unmarshal, because it discovers proto message type by reflection (Rather than by interface definition as it probably should ( https://github.com/golang/protobuf/issues/291 )

type DynamicFieldProto

type DynamicFieldProto interface {
	// DynamicFields returns the field names which are dynamic
	DynamicFields() []string

	// DynamicFieldProto returns a newly allocated dynamic message, decorating an underlying
	// proto message with the runtime determined function
	DynamicFieldProto(name string, underlying proto.Message) (proto.Message, error)
}

DynamicFieldProto should be implemented by protos which have nested fields whose attributes (such as their opaque types) cannot be determined until runtime

type DynamicMapFieldProto

type DynamicMapFieldProto interface {
	// DynamicFields returns the field names which are dynamic
	DynamicMapFields() []string

	// DynamicMapFieldProto returns a newly allocated dynamic message, decorating an underlying
	// proto message with the runtime determined function
	DynamicMapFieldProto(name string, key string, underlying proto.Message) (proto.Message, error)
}

DynamicMapFieldProto should be implemented by protos which have maps to messages whose attributes (such as their opaque types) cannot be determined until runtime

type DynamicSliceFieldProto

type DynamicSliceFieldProto interface {
	// DynamicFields returns the field names which are dynamic
	DynamicSliceFields() []string

	// DynamicSliceFieldProto returns a newly allocated dynamic message, decorating an underlying
	// proto message with the runtime determined function
	DynamicSliceFieldProto(name string, index int, underlying proto.Message) (proto.Message, error)
}

DynamicSliceFieldProto should be implemented by protos which have slices of messages whose attributes (such as their opaque types) cannot be determined until runtime

type StaticallyOpaqueFieldProto

type StaticallyOpaqueFieldProto interface {
	// StaticallyOpaqueFields returns the field names which contain opaque data
	StaticallyOpaqueFields() []string

	// StaticallyOpaqueFieldProto returns a newly allocated proto message of the correct
	// type for the field name.
	StaticallyOpaqueFieldProto(name string) (proto.Message, error)
}

StaticallyOpaqueFieldProto should be implemented by protos which have bytes fields which are the marshaled value of a fixed type

type StaticallyOpaqueMapFieldProto

type StaticallyOpaqueMapFieldProto interface {
	// StaticallyOpaqueFields returns the field names which contain opaque data
	StaticallyOpaqueMapFields() []string

	// StaticallyOpaqueFieldProto returns a newly allocated proto message of the correct
	// type for the field name.
	StaticallyOpaqueMapFieldProto(name string, key string) (proto.Message, error)
}

StaticallyOpaqueMapFieldProto should be implemented by protos which have maps to bytes fields which are the marshaled value of a fixed type

type StaticallyOpaqueSliceFieldProto

type StaticallyOpaqueSliceFieldProto interface {
	// StaticallyOpaqueFields returns the field names which contain opaque data
	StaticallyOpaqueSliceFields() []string

	// StaticallyOpaqueFieldProto returns a newly allocated proto message of the correct
	// type for the field name.
	StaticallyOpaqueSliceFieldProto(name string, index int) (proto.Message, error)
}

StaticallyOpaqueSliceFieldProto should be implemented by protos which have maps to bytes fields which are the marshaled value of a fixed type

type VariablyOpaqueFieldProto

type VariablyOpaqueFieldProto interface {
	// VariablyOpaqueFields returns the field names which contain opaque data
	VariablyOpaqueFields() []string

	// VariablyOpaqueFieldProto returns a newly allocated proto message of the correct
	// type for the field name.
	VariablyOpaqueFieldProto(name string) (proto.Message, error)
}

VariablyOpaqueFieldProto should be implemented by protos which have bytes fields which are the marshaled value depends upon the other contents of the proto

type VariablyOpaqueMapFieldProto

type VariablyOpaqueMapFieldProto interface {
	// VariablyOpaqueFields returns the field names which contain opaque data
	VariablyOpaqueMapFields() []string

	// VariablyOpaqueFieldProto returns a newly allocated proto message of the correct
	// type for the field name.
	VariablyOpaqueMapFieldProto(name string, key string) (proto.Message, error)
}

VariablyOpaqueMapFieldProto should be implemented by protos which have maps to bytes fields which are the marshaled value of a a message type determined by the other contents of the proto

type VariablyOpaqueSliceFieldProto

type VariablyOpaqueSliceFieldProto interface {
	// VariablyOpaqueFields returns the field names which contain opaque data
	VariablyOpaqueSliceFields() []string

	// VariablyOpaqueFieldProto returns a newly allocated proto message of the correct
	// type for the field name.
	VariablyOpaqueSliceFieldProto(name string, index int) (proto.Message, error)
}

VariablyOpaqueSliceFieldProto should be implemented by protos which have maps to bytes fields which are the marshaled value of a a message type determined by the other contents of the proto

Directories

Path Synopsis
Package testprotos is a generated protocol buffer package.
Package testprotos is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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