opaqueany

package module
v0.0.0-...-81be317 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: MPL-2.0 Imports: 7 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

Functions

func MarshalFrom

func MarshalFrom(dst *Any, src proto.Message, opts proto.MarshalOptions) error

MarshalFrom marshals src into dst as the underlying message using the provided marshal options.

If no options are specified, call dst.MarshalFrom instead.

func UnmarshalNew

func UnmarshalNew(src *Any, opts proto.UnmarshalOptions) (dst proto.Message, err error)

UnmarshalNew unmarshals the underlying message from src into dst, which is newly created message using a type resolved from the type URL. The message type is resolved according to opt.Resolver, which should implement protoregistry.MessageTypeResolver. It reports an error if the underlying message type could not be resolved.

If no options are specified, call src.UnmarshalNew instead.

func UnmarshalTo

func UnmarshalTo(src *Any, dst proto.Message, opts proto.UnmarshalOptions) error

UnmarshalTo unmarshals the underlying message from src into dst using the provided unmarshal options. It reports an error if dst is not of the right message type.

If no options are specified, call src.UnmarshalTo instead.

Types

type Any

type Any struct {

	// A URL/resource name that uniquely identifies the type of the serialized
	// protocol buffer message. This string must contain at least
	// one "/" character. The last segment of the URL's path must represent
	// the fully qualified name of the type (as in
	// `path/google.protobuf.Duration`). The name should be in a canonical form
	// (e.g., leading "." is not accepted).
	//
	// In practice, teams usually precompile into the binary all types that they
	// expect it to use in the context of Any. However, for URLs which use the
	// scheme `http`, `https`, or no scheme, one can optionally set up a type
	// server that maps type URLs to message definitions as follows:
	//
	// * If no scheme is provided, `https` is assumed.
	// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
	//   value in binary format, or produce an error.
	// * Applications are allowed to cache lookup results based on the
	//   URL, or have them precompiled into a binary to avoid any
	//   lookup. Therefore, binary compatibility needs to be preserved
	//   on changes to types. (Use versioned type names to manage
	//   breaking changes.)
	//
	// Note: this functionality is not currently available in the official
	// protobuf release, and it is not used for type URLs beginning with
	// type.googleapis.com.
	//
	// Schemes other than `http`, `https` (or the empty scheme) might be
	// used with implementation specific semantics.
	//
	TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"`
	// Must be a valid serialized protocol buffer of the above specified type.
	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func New

func New(src proto.Message) (*Any, error)

New marshals src into a new Any instance.

func (*Any) Descriptor deprecated

func (*Any) Descriptor() ([]byte, []int)

Deprecated: Use Any.ProtoReflect.Descriptor instead.

func (*Any) GetTypeUrl

func (x *Any) GetTypeUrl() string

func (*Any) GetValue

func (x *Any) GetValue() []byte

func (*Any) MarshalFrom

func (x *Any) MarshalFrom(m proto.Message) error

MarshalFrom marshals m into x as the underlying message.

func (*Any) MessageIs

func (x *Any) MessageIs(m proto.Message) bool

MessageIs reports whether the underlying message is of the same type as m.

func (*Any) MessageName

func (x *Any) MessageName() protoreflect.FullName

MessageName reports the full name of the underlying message, returning an empty string if invalid.

func (*Any) ProtoMessage

func (*Any) ProtoMessage()

func (*Any) ProtoReflect

func (x *Any) ProtoReflect() protoreflect.Message

func (*Any) Reset

func (x *Any) Reset()

func (*Any) String

func (x *Any) String() string

func (*Any) UnmarshalNew

func (x *Any) UnmarshalNew() (proto.Message, error)

UnmarshalNew unmarshals the contents of the underlying message of x into a newly allocated message of the specified type. It reports an error if the underlying message type could not be resolved.

func (*Any) UnmarshalTo

func (x *Any) UnmarshalTo(m proto.Message) error

UnmarshalTo unmarshals the contents of the underlying message of x into m. It resets m before performing the unmarshal operation. It reports an error if m is not of the right message type.

Jump to

Keyboard shortcuts

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