go: github.com/thrift-iterator/go Index | Files | Directories

package thrifter

import "github.com/thrift-iterator/go"


Package Files

api.go config.go decoder.go encoder.go


var DefaultConfig = Config{Protocol: ProtocolBinary, StaticCodegen: false}.Froze()

func Marshal Uses

func Marshal(obj interface{}) ([]byte, error)

func MarshalMessage Uses

func MarshalMessage(msg general.Message) ([]byte, error)

MarshalMessage is just a shortcut to demonstrate message decoded by UnmarshalMessage can be encoded back

func NewIterator Uses

func NewIterator(reader io.Reader, buf []byte) spi.Iterator

func NewStream Uses

func NewStream(writer io.Writer, buf []byte) spi.Stream

func ToJSON Uses

func ToJSON(buf []byte) (string, error)

ToJSON convert the thrift message to JSON string

func Unmarshal Uses

func Unmarshal(buf []byte, obj interface{}) error

func UnmarshalMessage Uses

func UnmarshalMessage(buf []byte) (general.Message, error)

UnmarshalMessage demonstrate how to decode thrift binary without IDL into a general message struct

type API Uses

type API interface {
    // NewStream is low level streaming api
    NewStream(writer io.Writer, buf []byte) spi.Stream
    // NewIterator is low level streaming api
    NewIterator(reader io.Reader, buf []byte) spi.Iterator
    // Unmarshal from []byte
    Unmarshal(buf []byte, obj interface{}) error
    // UnmarshalMessage from []byte
    UnmarshalMessage(buf []byte) (general.Message, error)
    // Marshal to []byte
    Marshal(obj interface{}) ([]byte, error)
    // ToJSON convert thrift message to JSON string
    ToJSON(buf []byte) (string, error)
    // MarshalMessage to []byte
    MarshalMessage(msg general.Message) ([]byte, error)
    // NewDecoder to unmarshal from []byte or io.Reader
    NewDecoder(reader io.Reader, buf []byte) *Decoder
    // NewEncoder to marshal to io.Writer
    NewEncoder(writer io.Writer) *Encoder
    // WillDecodeFromBuffer should only be used in generic.Declare
    WillDecodeFromBuffer(sample ...interface{})
    // WillDecodeFromReader should only be used in generic.Declare
    WillDecodeFromReader(sample ...interface{})
    // WillEncode should only be used in generic.Declare
    WillEncode(sample ...interface{})

type Config Uses

type Config struct {
    Protocol      Protocol
    StaticCodegen bool
    Extensions    spi.Extensions

func (Config) AddExtension Uses

func (cfg Config) AddExtension(extension spi.Extension) Config

func (Config) Froze Uses

func (cfg Config) Froze() API

type Decoder Uses

type Decoder struct {
    // contains filtered or unexported fields

func NewDecoder Uses

func NewDecoder(reader io.Reader, buf []byte) *Decoder

func (*Decoder) Decode Uses

func (decoder *Decoder) Decode(val interface{}) error

func (*Decoder) DecodeMessage Uses

func (decoder *Decoder) DecodeMessage() (general.Message, error)

func (*Decoder) DecodeMessageArguments Uses

func (decoder *Decoder) DecodeMessageArguments() (general.Struct, error)

func (*Decoder) DecodeMessageHeader Uses

func (decoder *Decoder) DecodeMessageHeader() (protocol.MessageHeader, error)

func (*Decoder) Reset Uses

func (decoder *Decoder) Reset(reader io.Reader, buf []byte)

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields

func NewEncoder Uses

func NewEncoder(writer io.Writer) *Encoder

func (*Encoder) Buffer Uses

func (encoder *Encoder) Buffer() []byte

func (*Encoder) Encode Uses

func (encoder *Encoder) Encode(val interface{}) error

func (*Encoder) EncodeMessage Uses

func (encoder *Encoder) EncodeMessage(msg general.Message) error

func (*Encoder) EncodeMessageArguments Uses

func (encoder *Encoder) EncodeMessageArguments(msgArgs general.Struct) error

func (*Encoder) EncodeMessageHeader Uses

func (encoder *Encoder) EncodeMessageHeader(msgHeader protocol.MessageHeader) error

func (*Encoder) Reset Uses

func (encoder *Encoder) Reset(writer io.Writer)

type Protocol Uses

type Protocol int
var ProtocolBinary Protocol = 1
var ProtocolCompact Protocol = 2



Package thrifter imports 14 packages (graph) and is imported by 2 packages. Updated 2018-09-30. Refresh now. Tools for package owners.