| 1 |
package thrift |
| 2 |
|
| 3 |
import ( |
| 4 |
"io" |
| 5 |
) |
| 6 |
|
| 7 |
// Features is a bitset describing the thrift encoding features supported by |
| 8 |
// protocol implementations. |
| 9 |
type Features uint |
| 10 |
|
| 11 |
const ( |
| 12 |
// DeltaEncoding is advertised by protocols that allow encoders to apply |
| 13 |
// delta encoding on struct fields. |
| 14 |
UseDeltaEncoding Features = 1 << iota |
| 15 |
|
| 16 |
// CoalesceBoolFields is advertised by protocols that allow encoders to |
| 17 |
// coalesce boolean values into field types. |
| 18 |
CoalesceBoolFields |
| 19 |
) |
| 20 |
|
| 21 |
// The Protocol interface abstracts the creation of low-level thrift readers and |
| 22 |
// writers implementing the various protocols that the encoding supports. |
| 23 |
// |
| 24 |
// Protocol instances must be safe to use concurrently from multiple gourintes. |
| 25 |
// However, the readers and writer that they instantiates are intended to be |
| 26 |
// used by a single goroutine. |
| 27 |
type Protocol interface { |
| 28 |
NewReader(r io.Reader) Reader |
| 29 |
NewWriter(w io.Writer) Writer |
| 30 |
Features() Features |
| 31 |
} |
| 32 |
|
| 33 |
// Reader represents a low-level reader of values encoded according to one of |
| 34 |
// the thrift protocols. |
| 35 |
type Reader interface { |
| 36 |
Protocol() Protocol |
| 37 |
Reader() io.Reader |
| 38 |
ReadBool() (bool, error) |
| 39 |
ReadInt8() (int8, error) |
| 40 |
ReadInt16() (int16, error) |
| 41 |
ReadInt32() (int32, error) |
| 42 |
ReadInt64() (int64, error) |
| 43 |
ReadFloat64() (float64, error) |
| 44 |
ReadBytes() ([]byte, error) |
| 45 |
ReadString() (string, error) |
| 46 |
ReadLength() (int, error) |
| 47 |
ReadMessage() (Message, error) |
| 48 |
ReadField() (Field, error) |
| 49 |
ReadList() (List, error) |
| 50 |
ReadSet() (Set, error) |
| 51 |
ReadMap() (Map, error) |
| 52 |
} |
| 53 |
|
| 54 |
// Writer represents a low-level writer of values encoded according to one of |
| 55 |
// the thrift protocols. |
| 56 |
type Writer interface { |
| 57 |
Protocol() Protocol |
| 58 |
Writer() io.Writer |
| 59 |
WriteBool(bool) error |
| 60 |
WriteInt8(int8) error |
| 61 |
WriteInt16(int16) error |
| 62 |
WriteInt32(int32) error |
| 63 |
WriteInt64(int64) error |
| 64 |
WriteFloat64(float64) error |
| 65 |
WriteBytes([]byte) error |
| 66 |
WriteString(string) error |
| 67 |
WriteLength(int) error |
| 68 |
WriteMessage(Message) error |
| 69 |
WriteField(Field) error |
| 70 |
WriteList(List) error |
| 71 |
WriteSet(Set) error |
| 72 |
WriteMap(Map) error |
| 73 |
} |