Documentation ¶
Index ¶
- func Marshal(p Protocol, v interface{}) ([]byte, error)
- func Unmarshal(p Protocol, b []byte, v interface{}) error
- type BinaryProtocol
- type CompactProtocol
- type Decoder
- type Encoder
- type Features
- type Field
- type List
- type Map
- type Message
- type MessageType
- type MissingField
- type Protocol
- type Reader
- type Set
- type Type
- type TypeMismatch
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal serializes v into a thrift representation according to the the protocol p.
The function panics if v cannot be converted to a thrift representation.
func Unmarshal ¶
Unmarshal deserializes the thrift data from b to v using to the protocol p.
The function errors if the data in b does not match the type of v.
The function panics if v cannot be converted to a thrift representation.
As an optimization, the value passed in v may be reused across multiple calls to Unmarshal, allowing the function to reuse objects referenced by pointer fields of struct values. When reusing objects, the application is responsible for resetting the state of v before calling Unmarshal again.
Types ¶
type BinaryProtocol ¶
type BinaryProtocol struct {
NonStrict bool
}
BinaryProtocol is a Protocol implementation for the binary thrift protocol.
https://github.com/apache/thrift/blob/master/doc/specs/thrift-binary-protocol.md
func (*BinaryProtocol) Features ¶
func (p *BinaryProtocol) Features() Features
type CompactProtocol ¶
type CompactProtocol struct{}
CompactProtocol is a Protocol implementation for the compact thrift protocol.
https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md#integer-encoding
func (*CompactProtocol) Features ¶
func (p *CompactProtocol) Features() Features
type Features ¶
type Features uint
Features is a bitset describing the thrift encoding features supported by protocol implementations.
type Message ¶
type Message struct { Type MessageType Name string SeqID int32 }
type MessageType ¶
type MessageType int8
const ( Call MessageType = iota Reply Exception Oneway )
func (MessageType) String ¶
func (m MessageType) String() string
type MissingField ¶
type MissingField struct {
Field Field
}
func (*MissingField) Error ¶
func (e *MissingField) Error() string
type Protocol ¶
type Protocol interface { NewReader(r io.Reader) Reader NewWriter(w io.Writer) Writer Features() Features }
The Protocol interface abstracts the creation of low-level thrift readers and writers implementing the various protocols that the encoding supports.
Protocol instances must be safe to use concurrently from multiple gourintes. However, the readers and writer that they instantiates are intended to be used by a single goroutine.
type Reader ¶
type Reader interface { Protocol() Protocol Reader() io.Reader ReadBool() (bool, error) ReadInt8() (int8, error) ReadInt16() (int16, error) ReadInt32() (int32, error) ReadInt64() (int64, error) ReadFloat64() (float64, error) ReadBytes() ([]byte, error) ReadString() (string, error) ReadLength() (int, error) ReadMessage() (Message, error) ReadField() (Field, error) ReadList() (List, error) ReadSet() (Set, error) ReadMap() (Map, error) }
Reader represents a low-level reader of values encoded according to one of the thrift protocols.
type TypeMismatch ¶
func (*TypeMismatch) Error ¶
func (e *TypeMismatch) Error() string
type Writer ¶
type Writer interface { Protocol() Protocol Writer() io.Writer WriteBool(bool) error WriteInt8(int8) error WriteInt16(int16) error WriteInt32(int32) error WriteInt64(int64) error WriteFloat64(float64) error WriteBytes([]byte) error WriteString(string) error WriteLength(int) error WriteMessage(Message) error WriteField(Field) error WriteList(List) error WriteSet(Set) error WriteMap(Map) error }
Writer represents a low-level writer of values encoded according to one of the thrift protocols.