Movatterモバイル変換


[0]ホーム

URL:


messageset

package
v1.36.11Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License:BSD-3-ClauseImports:4Imported by:0

Details

Repository

github.com/protocolbuffers/protobuf-go

Links

Documentation

Overview

Package messageset encodes and decodes the obsolete MessageSet wire format.

Index

Constants

View Source
const (FieldItem    =protowire.Number(1)FieldTypeID  =protowire.Number(2)FieldMessage =protowire.Number(3))

The MessageSet wire format is equivalent to a message defined as follows,where each Item defines an extension field with a field number of 'type_id'and content of 'message'. MessageSet extensions must be non-repeated messagefields.

message MessageSet {repeated group Item = 1 {required int32 type_id = 2;required string message = 3;}}
View Source
const ExtensionName = "message_set_extension"

ExtensionName is the field name for extensions of MessageSet.

A valid MessageSet extension must be of the form:

message MyMessage {extend proto2.bridge.MessageSet {optional MyMessage message_set_extension = 1234;}...}

Variables

This section is empty.

Functions

funcAppendFieldEnd

func AppendFieldEnd(b []byte) []byte

AppendFieldEnd appends the trailing end group marker for a MessageSet item field.

funcAppendFieldStart

func AppendFieldStart(b []byte, numprotowire.Number) []byte

AppendFieldStart appends the start of a MessageSet item field containingan extension with the given number. The caller must add the messagesubfield (including the tag).

funcAppendUnknown

func AppendUnknown(b, unknown []byte) ([]byte,error)

AppendUnknown appends unknown fields to b in MessageSet format.

For historic reasons, unresolved items in a MessageSet are stored in amessage's unknown fields section in non-MessageSet format. That is, anunknown item with typeID T and value V appears in the unknown fields asa field with number T and value V.

This function converts the unknown fields back into MessageSet form.

funcConsumeFieldValue

func ConsumeFieldValue(b []byte, wantLenbool) (typeidprotowire.Number, message []byte, nint, errerror)

ConsumeFieldValue parses b as a MessageSet item field value until and includingthe trailing end group marker. It assumes the start group tag has already been parsed.It returns the contents of the type_id and message subfields and the totalitem length.

If wantLen is true, the returned message value includes the length prefix.

funcIsMessageSet

func IsMessageSet(mdprotoreflect.MessageDescriptor)bool

IsMessageSet returns whether the message uses the MessageSet wire format.

funcIsMessageSetExtension

func IsMessageSetExtension(fdprotoreflect.FieldDescriptor)bool

IsMessageSetExtension reports this field properly extends a MessageSet.

funcSizeField

func SizeField(numprotowire.Number)int

SizeField returns the size of a MessageSet item field containing an extensionwith the given field number, not counting the contents of the message subfield.

funcSizeUnknown

func SizeUnknown(unknown []byte) (sizeint)

SizeUnknown returns the size of an unknown fields section in MessageSet format.

See AppendUnknown.

funcUnmarshal

func Unmarshal(b []byte, wantLenbool, fn func(typeIDprotowire.Number, value []byte)error)error

Unmarshal parses a MessageSet.

It calls fn with the type ID and value of each item in the MessageSet.Unknown fields are discarded.

If wantLen is true, the item values include the varint length prefix.This is ugly, but simplifies the fast-path decoder in internal/impl.

Types

This section is empty.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp