encoding

package
v0.29.8-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthEncoding        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowEncoding          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupEncoding = fmt.Errorf("proto: unexpected end of group")
)

Functions

func Decode

func Decode(bs []byte, msg proto.Message) error

Single shot decoding

func Encode

func Encode(msg proto.Message) ([]byte, error)

Single shot encoding

func ReadMessage

func ReadMessage(r io.Reader, pb proto.Message) (int, error)

Read messages with length-prefix framing from the provided Reader. Returns the number of bytes read and io.EOF if ReadMessage is called exactly on the end of a stream.

func WriteMessage

func WriteMessage(w io.Writer, pb proto.Message) (int, error)

Write messages with length-prefix framing to the provider Writer. Returns the number of bytes written.

Types

type Buffer

type Buffer struct {
	*proto.Buffer
}

func NewBuffer

func NewBuffer(bs []byte) *Buffer

Centralise proto.Buffer constructor. gogo protobuf freaks out about deterministic marshalling on objects with custom marshallers so we use google protobuf here

type TestMessage

type TestMessage struct {
	Type                 uint32   `protobuf:"varint,1,opt,name=Type,proto3" json:"Type,omitempty"`
	Amount               uint64   `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

For testing

func (*TestMessage) Descriptor

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

func (*TestMessage) GetAmount

func (m *TestMessage) GetAmount() uint64

func (*TestMessage) GetType

func (m *TestMessage) GetType() uint32

func (*TestMessage) Marshal

func (m *TestMessage) Marshal() (dAtA []byte, err error)

func (*TestMessage) MarshalTo

func (m *TestMessage) MarshalTo(dAtA []byte) (int, error)

func (*TestMessage) MarshalToSizedBuffer added in v0.30.0

func (m *TestMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TestMessage) ProtoMessage

func (*TestMessage) ProtoMessage()

func (*TestMessage) Reset

func (m *TestMessage) Reset()

func (*TestMessage) Size

func (m *TestMessage) Size() (n int)

func (TestMessage) String

func (tm TestMessage) String() string

func (*TestMessage) Unmarshal

func (m *TestMessage) Unmarshal(dAtA []byte) error

func (*TestMessage) XXX_DiscardUnknown

func (m *TestMessage) XXX_DiscardUnknown()

func (*TestMessage) XXX_Marshal

func (m *TestMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TestMessage) XXX_Merge

func (m *TestMessage) XXX_Merge(src proto.Message)

func (*TestMessage) XXX_MessageName

func (*TestMessage) XXX_MessageName() string

func (*TestMessage) XXX_Size

func (m *TestMessage) XXX_Size() int

func (*TestMessage) XXX_Unmarshal

func (m *TestMessage) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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