protobuf

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WireVarint     = 0
	WireFixed64    = 1
	WireBytes      = 2
	WireStartGroup = 3
	WireEndGroup   = 4
	WireFixed32    = 5
)

Constants that identify the encoding of a value on the wire.

Variables

View Source
var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")

ErrInternalBadWireType is returned by generated code when an incorrect wire type is encountered. It does not get returned to user code.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

func NewBuffer

func NewBuffer(e []byte) *Buffer

NewBuffer allocates a new Buffer and initializes its internal data to the contents of the argument slice.

func (*Buffer) Bytes

func (p *Buffer) Bytes() []byte

Bytes returns the contents of the Buffer.

func (*Buffer) DecodeFixed32

func (p *Buffer) DecodeFixed32() (x uint64, err error)

DecodeFixed32 reads a 32-bit integer from the Buffer. This is the format for the fixed32, sfixed32, and float protocol buffer types.

func (*Buffer) DecodeFixed64

func (p *Buffer) DecodeFixed64() (x uint64, err error)

DecodeFixed64 reads a 64-bit integer from the Buffer. This is the format for the fixed64, sfixed64, and double protocol buffer types.

func (*Buffer) DecodeRawBytes

func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error)

DecodeRawBytes reads a count-delimited byte buffer from the Buffer. This is the format used for the bytes protocol buffer type and for embedded messages.

func (*Buffer) DecodeStringBytes

func (p *Buffer) DecodeStringBytes() (s string, err error)

DecodeStringBytes reads an encoded string from the Buffer. This is the format used for the proto2 string type.

func (*Buffer) DecodeVarint

func (p *Buffer) DecodeVarint() (x uint64, err error)

DecodeVarint reads a varint-encoded integer from the Buffer. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types.

func (*Buffer) DecodeZigzag32

func (p *Buffer) DecodeZigzag32() (x uint64, err error)

DecodeZigzag32 reads a zigzag-encoded 32-bit integer from the Buffer. This is the format used for the sint32 protocol buffer type.

func (*Buffer) DecodeZigzag64

func (p *Buffer) DecodeZigzag64() (x uint64, err error)

DecodeZigzag64 reads a zigzag-encoded 64-bit integer from the Buffer. This is the format used for the sint64 protocol buffer type.

func (*Buffer) Reset

func (p *Buffer) Reset()

Reset resets the Buffer, ready for marshaling a new protocol buffer.

func (*Buffer) SetBuf

func (p *Buffer) SetBuf(s []byte)

SetBuf replaces the internal buffer with the slice, ready for unmarshaling the contents of the slice.

func (*Buffer) SetDeterministic

func (p *Buffer) SetDeterministic(deterministic bool)

SetDeterministic sets whether to use deterministic serialization.

Deterministic serialization guarantees that for a given binary, equal messages will always be serialized to the same bytes. This implies:

  • Repeated serialization of a message will return the same bytes.
  • Different processes of the same binary (which may be executing on different machines) will serialize equal messages to the same bytes.

Note that the deterministic serialization is NOT canonical across languages. It is not guaranteed to remain stable over time. It is unstable across different builds with schema changes due to unknown fields. Users who need canonical serialization (e.g., persistent storage in a canonical form, fingerprinting, etc.) should define their own canonicalization specification and implement their own serializer rather than relying on this API.

If deterministic serialization is requested, map entries will be sorted by keys in lexographical order. This is an implementation detail and subject to change.

func (*Buffer) Unmarshal

func (p *Buffer) Unmarshal() (ProtobufJSON, bool)

type ProtobufJSON

type ProtobufJSON map[string]interface{}

func (ProtobufJSON) GetTagMessage

func (p ProtobufJSON) GetTagMessage(tags ...string) []ProtobufJSON

func (ProtobufJSON) GetTagValue

func (p ProtobufJSON) GetTagValue(wire string, tags ...string) []interface{}

func (ProtobufJSON) GetTagValueToInt64

func (p ProtobufJSON) GetTagValueToInt64(wire string, tags ...string) int64

func (ProtobufJSON) GetTagValueToString

func (p ProtobufJSON) GetTagValueToString(tags ...string) string

func (ProtobufJSON) SetTagValue

func (p ProtobufJSON) SetTagValue(tag string, value interface{})

Jump to

Keyboard shortcuts

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