thriftrw: go.uber.org/thriftrw/protocol/binary Index | Files

package binary

import "go.uber.org/thriftrw/protocol/binary"

Package binary implements the Thrift Binary protocol.

See "go.uber.org/thriftrw/protocol".Binary for a higher-level Encode/Decode API.

Index

Package Files

common.go doc.go envelope.go error.go lazy_list.go reader.go writer.go

func IsDecodeError Uses

func IsDecodeError(e error) bool

IsDecodeError checks if an error is a protocol decode error.

func ReturnWriter Uses

func ReturnWriter(w *Writer)

ReturnWriter returns a previously borrowed Writer back to the system.

type Reader Uses

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

Reader implements a parser for the Thrift Binary Protocol based on an io.ReaderAt.

func NewReader Uses

func NewReader(r io.ReaderAt) Reader

NewReader builds a new Reader based on the given io.ReaderAt.

func (*Reader) ReadEnveloped Uses

func (bw *Reader) ReadEnveloped() (wire.Envelope, error)

ReadEnveloped reads an Apache Thrift envelope

Thrift supports two kinds of envelopes: strict, and non-strict.

Non-strict envelopes: Name (4 byte length prefixed string) Type ID (1 byte) Sequence ID (4 bytes)

Strict envelopes:

Version | Type ID (4 bytes) Name (4 byte length prefixed string) Sequence ID (4 bytes)

When reading payloads, we need to support both strict and non-strict payloads. To do this, we read the first 4 byte. Non-strict payloads will always have a size >= 0, while strict payloads have selected version numbers such that the value will always be negative.

func (*Reader) ReadValue Uses

func (br *Reader) ReadValue(t wire.Type, off int64) (wire.Value, int64, error)

ReadValue reads a value off the given type off the wire starting at the given offset.

Returns the Value, the new offset, and an error if there was a decode error.

type Writer Uses

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

Writer implements basic logic for writing the Thrift Binary Protocol to an io.Writer.

func BorrowWriter Uses

func BorrowWriter(w io.Writer) *Writer

BorrowWriter fetches a Writer from the system that will write its output to the given io.Writer.

This Writer must be returned back using ReturnWriter.

func (*Writer) WriteEnveloped Uses

func (bw *Writer) WriteEnveloped(e wire.Envelope) error

WriteEnveloped writes enveloped value using the strict envelope.

func (*Writer) WriteLegacyEnveloped Uses

func (bw *Writer) WriteLegacyEnveloped(e wire.Envelope) error

WriteLegacyEnveloped writes enveloped value using the non-strict envelope (non-strict lacks an envelope version).

func (*Writer) WriteValue Uses

func (bw *Writer) WriteValue(v wire.Value) error

WriteValue writes the given Thrift value to the underlying stream using the Thrift Binary Protocol.

Package binary imports 7 packages (graph) and is imported by 5 packages. Updated 2020-01-04. Refresh now. Tools for package owners.