marshaling

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package marshaling provides utilities for marshaling and unmarshaling messages and other types.

Index

Constants

View Source
const (
	// JSONContentType is the content-type name for JSON-encoded messages.
	JSONContentType = "application/json"
)
View Source
const (
	// ProtobufContentType is the content-type name for protocol buffer messages.
	ProtobufContentType = "application/vnd.google.protobuf"
)

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(msg proto.Message) (ct string, data []byte, err error)

MarshalJSON marshals a ProtocolBuffers message to its JSON representation and returns a MIME content-type that identifies the particular message protocol.

func MarshalProtobuf

func MarshalProtobuf(m proto.Message) (ct string, data []byte, err error)

MarshalProtobuf marshals a ProtocolBuffers message to its binary representation and returns a MIME content-type that identifies the particular message protocol.

func MarshalTime

func MarshalTime(t time.Time) string

MarshalTime marshals t to an RFC3339+Nano string.

func Unmarshal

func Unmarshal(ct string, data []byte) (proto.Message, error)

Unmarshal unmarshals a protocol buffers message from some serialized representation. ct is the MIME content-type for the binary data.

func UnmarshalJSON

func UnmarshalJSON(ct string, data []byte) (proto.Message, error)

UnmarshalJSON unmarshals a ProtocolBuffers message from its JSON representation using an unparsed MIME content-type to identify the particular message protocol.

func UnmarshalJSONParams

func UnmarshalJSONParams(ctn string, p map[string]string, data []byte) (proto.Message, error)

UnmarshalJSONParams unmarshals a JSON-encoded message using a pre-parsed MIME content-type to identify the particular message protocol.

ctn is the MIME content-type name, p is the set of pre-parsed content-type parameters, as returned by mime.ParseMediaType().

func UnmarshalProtobuf

func UnmarshalProtobuf(ct string, data []byte) (proto.Message, error)

UnmarshalProtobuf unmarshals a ProtocolBuffers message from its binary representation using an unparsed MIME content-type to identify the particular message protocol.

func UnmarshalProtobufParams

func UnmarshalProtobufParams(ctn string, p map[string]string, data []byte) (proto.Message, error)

UnmarshalProtobufParams unmarshals a ProtocolBuffers messages from its binary representation using a pre-parsed MIME content-type to identify the particular message protocol.

ctn is the MIME content-type name, p is the set of pre-parsed content-type parameters, as returned by mime.ParseMediaType().

func UnmarshalTime

func UnmarshalTime(s string, t *time.Time) error

UnmarshalTime unmarshals an RFC3339+Nano formatted string into t.

Types

This section is empty.

Jump to

Keyboard shortcuts

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