codec

package
v0.0.0-...-899fff0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

this codec is modified from https://github.com/mars9/codec

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientCodec

func NewClientCodec(rwc io.ReadWriteCloser) rpc.ClientCodec

NewClientCodec returns a new rpc.Client.

A ClientCodec implements writing of RPC requests and reading of RPC responses for the client side of an RPC session. The client calls WriteRequest to write a request to the connection and calls ReadResponseHeader and ReadResponseBody in pairs to read responses. The client calls Close when finished with the connection. ReadResponseBody may be called with a nil argument to force the body of the response to be read and then discarded.

Types

type DecodeReader

type DecodeReader interface {
	io.ByteReader
	io.Reader
}

type Decoder

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

A Decoder manages the receipt of type and data information read from the remote side of a connection.

func NewDecoder

func NewDecoder(r DecodeReader) *Decoder

NewDecoder returns a new decoder that reads from the io.Reader.

func (*Decoder) Decode

func (d *Decoder) Decode(m proto.Message) (err error)

Decode reads the next value from the input stream and stores it in the data represented by the empty interface value. If m is nil, the value will be discarded. Otherwise, the value underlying m must be a pointer to the correct type for the next data item received.

func (*Decoder) DecodeBytes

func (d *Decoder) DecodeBytes() (byteS []byte, err error)

type Encoder

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

An Encoder manages the transmission of type and data information to the other side of a connection.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new encoder that will transmit on the io.Writer.

func (*Encoder) Encode

func (e *Encoder) Encode(m proto.Message) (err error)

Encode transmits the data item represented by the empty interface value, guaranteeing that all necessary type information has been transmitted first.

Directories

Path Synopsis
Package wirepb is a generated protocol buffer package.
Package wirepb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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