framing

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorUnderrun       = Error("frame underrun, unexpected EOF")
	ErrorBadSize        = Error("bad frame size")
	ErrorOversizedFrame = Error("oversized frame, max size exceeded")
)

Variables

This section is empty.

Functions

func EOFReaderFunc added in v0.0.6

func EOFReaderFunc() ([]byte, error)

EOFReaderFunc always returns nil, io.EOF; it implements the ReaderFunc API.

Types

type Decoder

type Decoder interface {
	// Decode reads the next encoded message from its input and stores it
	// in the value pointed to by m. If m isn't a proto.Message, Decode will panic.
	Decode(interface{}) error
}

Decoder reads and decodes Protobuf messages from an io.Reader.

type DecoderFunc added in v0.0.4

type DecoderFunc func(interface{}) error

DecoderFunc is the functional adaptation of Decoder

func NewDecoder

func NewDecoder(r Reader, uf UnmarshalFunc) DecoderFunc

NewDecoder returns a new Decoder that reads from the given frame Reader.

func (DecoderFunc) Decode added in v0.0.4

func (f DecoderFunc) Decode(m interface{}) error

type Error added in v0.0.4

type Error string

func (Error) Error added in v0.0.4

func (err Error) Error() string

type Reader

type Reader interface {
	ReadFrame() (frame []byte, err error)
}

Reader generates data frames from some source, returning io.EOF when the end of the input stream is detected.

type ReaderFunc added in v0.0.4

type ReaderFunc func() ([]byte, error)

ReaderFunc is the functional adaptation of Reader.

func ReadAll added in v0.0.6

func ReadAll(r io.Reader) ReaderFunc

ReadAll returns a reader func that returns the complete contents of `r` in a single frame. A zero length frame is treated as an "end of stream" condition, returning io.EOF.

func (ReaderFunc) ReadFrame added in v0.0.4

func (f ReaderFunc) ReadFrame() ([]byte, error)

type UnmarshalFunc

type UnmarshalFunc func([]byte, interface{}) error

UnmarshalFunc translates bytes to objects

type Writer added in v0.0.4

type Writer interface {
	WriteFrame(frame []byte) error
}

Writer sends whole frames to some endpoint; returns io.ErrShortWrite if the frame is only partially written.

type WriterFunc added in v0.0.4

type WriterFunc func([]byte) error

WriterFunc is the functional adaptation of Writer.

func WriterFor added in v0.0.6

func WriterFor(w io.Writer) WriterFunc

WriterFor adapts an io.Writer to the Writer interface. All buffers are written to `w` without decoration or modification.

func (WriterFunc) WriteFrame added in v0.0.4

func (f WriterFunc) WriteFrame(b []byte) error

Jump to

Keyboard shortcuts

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