textpb

package
v2.0.0-...-d24bc72 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package textpb marshals and unmarshals protocol buffer messages as the textproto format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(m proto.Message) ([]byte, error)

Marshal writes the given proto.Message in textproto format using default options.

func Unmarshal

func Unmarshal(m proto.Message, b []byte) error

Unmarshal reads the given []byte into the given proto.Message.

Types

type MarshalOptions

type MarshalOptions struct {
	pragma.NoUnkeyedLiterals

	// AllowPartial allows messages that have missing required fields to marshal
	// without returning an error. If AllowPartial is false (the default),
	// Marshal will return error if there are any missing required fields.
	AllowPartial bool

	// If Indent is a non-empty string, it causes entries for a Message to be
	// preceded by the indent and trailed by a newline. Indent can only be
	// composed of space or tab characters.
	Indent string

	// Resolver is the registry used for type lookups when marshaling out
	// google.protobuf.Any messages in expanded form. If Resolver is not set,
	// marshaling will default to using protoregistry.GlobalTypes.  If a type is
	// not found, an Any message will be marshaled as a regular message.
	Resolver *protoregistry.Types
}

MarshalOptions is a configurable text format marshaler.

func (MarshalOptions) Marshal

func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error)

Marshal writes the given proto.Message in textproto format using options in MarshalOptions object.

type UnmarshalOptions

type UnmarshalOptions struct {
	pragma.NoUnkeyedLiterals

	// AllowPartial accepts input for messages that will result in missing
	// required fields. If AllowPartial is false (the default), Unmarshal will
	// return error if there are any missing required fields.
	AllowPartial bool

	// Resolver is the registry used for type lookups when unmarshaling extensions
	// and processing Any. If Resolver is not set, unmarshaling will default to
	// using protoregistry.GlobalTypes.
	Resolver *protoregistry.Types
}

UnmarshalOptions is a configurable textproto format unmarshaler.

func (UnmarshalOptions) Unmarshal

func (o UnmarshalOptions) Unmarshal(m proto.Message, b []byte) error

Unmarshal reads the given []byte and populates the given proto.Message using options in UnmarshalOptions object.

Jump to

Keyboard shortcuts

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