protolator

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 10 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

func MostlyDeterministicMarshal

func MostlyDeterministicMarshal(msg proto.Message) ([]byte, error)

MostlyDeterministicMarshal is _NOT_ the function you are looking for. It causes protobuf serialization consistent within a single build. It does not guarantee that the serialization is deterministic across proto versions or proto implementations. It is useful for situations where the same process wants to compare binary messages for equality without needing to unmarshal first, but should not be used generally.

Types

type DecoratedProto

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

DecoratedProto 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 {
	// DynamicMapFields 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 {
	// DynamicSliceFields 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 {
	// StaticallyOpaqueMapFields returns the field names which contain opaque data
	StaticallyOpaqueMapFields() []string

	// StaticallyOpaqueMapFieldProto 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 {
	// StaticallyOpaqueSliceFields returns the field names which contain opaque data
	StaticallyOpaqueSliceFields() []string

	// StaticallyOpaqueSliceFieldProto 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 {
	// VariablyOpaqueMapFields returns the field names which contain opaque data
	VariablyOpaqueMapFields() []string

	// VariablyOpaqueMapFieldProto 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 {
	// VariablyOpaqueSliceFields 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

Jump to

Keyboard shortcuts

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