protoio

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMsgExceedsMaxSize = errors.New("message exceeds max size")

ErrMsgExceedsMaxSize is returned by ReadMsg when the declared message length exceeds the reader's maxSize. Callers that pass a maxSize to bound what an unauthenticated peer can make them allocate can classify the rejection with errors.Is instead of matching on the message text.

Functions

func MarshalDelimited

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

func UnmarshalDelimited

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

Types

type ReadCloser

type ReadCloser interface {
	Reader
	io.Closer
}

func NewDelimitedReader

func NewDelimitedReader(r io.Reader, maxSize int) ReadCloser

NewDelimitedReader reads varint-delimited Protobuf messages from a reader. Unlike the gogoproto NewDelimitedReader, this does not buffer the reader, which may cause poor performance but is necessary when only reading single messages (e.g. in the p2p package). It also returns the number of bytes read, which is necessary for the p2p package.

type Reader

type Reader interface {
	ReadMsg(msg proto.Message) (int, error)
}

type WriteCloser

type WriteCloser interface {
	Writer
	io.Closer
}

func NewDelimitedWriter

func NewDelimitedWriter(w io.Writer) WriteCloser

NewDelimitedWriter writes a varint-delimited Protobuf message to a writer. It is equivalent to the gogoproto NewDelimitedWriter, except WriteMsg() also returns the number of bytes written, which is necessary in the p2p package.

type Writer

type Writer interface {
	WriteMsg(proto.Message) (int, error)
}

Jump to

Keyboard shortcuts

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