github.com/cloudwego/kitex@v0.9.0/pkg/protocol/bthrift/interface.go (about)

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