/
interface.go
99 lines (95 loc) · 4.06 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright 2021 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Package bthrift is byted thrift
package bthrift
import (
"github.com/apache/thrift/lib/go/thrift"
)
// BinaryWriter .
// Deprecated: removed from FastCodec in order to be compatible with Bytebuffer other than netpoll.
type BinaryWriter interface {
WriteDirect(b []byte, remainCap int) error
}
// BTProtocol .
type BTProtocol interface {
WriteMessageBegin(buf []byte, name string, typeID thrift.TMessageType, seqid int32) int
WriteMessageEnd(buf []byte) int
WriteStructBegin(buf []byte, name string) int
WriteStructEnd(buf []byte) int
WriteFieldBegin(buf []byte, name string, typeID thrift.TType, id int16) int
WriteFieldEnd(buf []byte) int
WriteFieldStop(buf []byte) int
WriteMapBegin(buf []byte, keyType, valueType thrift.TType, size int) int
WriteMapEnd(buf []byte) int
WriteListBegin(buf []byte, elemType thrift.TType, size int) int
WriteListEnd(buf []byte) int
WriteSetBegin(buf []byte, elemType thrift.TType, size int) int
WriteSetEnd(buf []byte) int
WriteBool(buf []byte, value bool) int
WriteByte(buf []byte, value int8) int
WriteI16(buf []byte, value int16) int
WriteI32(buf []byte, value int32) int
WriteI64(buf []byte, value int64) int
WriteDouble(buf []byte, value float64) int
WriteString(buf []byte, value string) int
WriteBinary(buf, value []byte) int
WriteStringNocopy(buf []byte, binaryWriter BinaryWriter, value string) int
WriteBinaryNocopy(buf []byte, binaryWriter BinaryWriter, value []byte) int
MessageBeginLength(name string, typeID thrift.TMessageType, seqid int32) int
MessageEndLength() int
StructBeginLength(name string) int
StructEndLength() int
FieldBeginLength(name string, typeID thrift.TType, id int16) int
FieldEndLength() int
FieldStopLength() int
MapBeginLength(keyType, valueType thrift.TType, size int) int
MapEndLength() int
ListBeginLength(elemType thrift.TType, size int) int
ListEndLength() int
SetBeginLength(elemType thrift.TType, size int) int
SetEndLength() int
BoolLength(value bool) int
ByteLength(value int8) int
I16Length(value int16) int
I32Length(value int32) int
I64Length(value int64) int
DoubleLength(value float64) int
StringLength(value string) int
BinaryLength(value []byte) int
StringLengthNocopy(value string) int
BinaryLengthNocopy(value []byte) int
ReadMessageBegin(buf []byte) (name string, typeID thrift.TMessageType, seqid int32, length int, err error)
ReadMessageEnd(buf []byte) (int, error)
ReadStructBegin(buf []byte) (name string, length int, err error)
ReadStructEnd(buf []byte) (int, error)
ReadFieldBegin(buf []byte) (name string, typeID thrift.TType, id int16, length int, err error)
ReadFieldEnd(buf []byte) (int, error)
ReadMapBegin(buf []byte) (keyType, valueType thrift.TType, size, length int, err error)
ReadMapEnd(buf []byte) (int, error)
ReadListBegin(buf []byte) (elemType thrift.TType, size, length int, err error)
ReadListEnd(buf []byte) (int, error)
ReadSetBegin(buf []byte) (elemType thrift.TType, size, length int, err error)
ReadSetEnd(buf []byte) (int, error)
ReadBool(buf []byte) (value bool, length int, err error)
ReadByte(buf []byte) (value int8, length int, err error)
ReadI16(buf []byte) (value int16, length int, err error)
ReadI32(buf []byte) (value int32, length int, err error)
ReadI64(buf []byte) (value int64, length int, err error)
ReadDouble(buf []byte) (value float64, length int, err error)
ReadString(buf []byte) (value string, length int, err error)
ReadBinary(buf []byte) (value []byte, length int, err error)
Skip(buf []byte, fieldType thrift.TType) (length int, err error)
}