unknown

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package unknown provides definitions that work with the thriftgo `keep_unknown_fields` option. When the option is turned on, thriftgo generates an extra field `_unknownFields` for each structure defined in the IDL to store fields that are not recognized by the current IDL when deserializing data. Those unknown fields will be written out at the end of the data stream when serializing the structure that carries them.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExceedDepthLimit = thrift.NewTProtocolExceptionWithType(thrift.DEPTH_LIMIT, errors.New("depth limit exceeded"))

	ErrUnknownType = func(t thrift.TType) error {
		return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("unknown data type %d", t))
	}
)

errors .

Functions

func SetNestingDepthLimit

func SetNestingDepthLimit(d int)

SetNestingDepthLimit sets the max number of nesting level.

func Write

func Write(oprot thrift.TProtocol, f *Field) (err error)

Write writes out the unknown field.

Types

type Field

type Field struct {
	Name    string
	ID      int16
	Type    thrift.TType
	KeyType thrift.TType
	ValType thrift.TType
	Value   interface{}
}

Field is used to store unrecognized field when deserializing data.

func Read

func Read(iprot thrift.TProtocol, name string, fieldType thrift.TType, id int16, maxDepth int) (f *Field, err error)

Read reads an unknown field from the given TProtocol.

type Fields

type Fields []*Field

Fields is a list of Field.

func (*Fields) Append

func (fs *Fields) Append(iprot thrift.TProtocol, name string, fieldType thrift.TType, id int16) error

Append reads an unrecognized field and append it to the current slice.

func (*Fields) Write

func (fs *Fields) Write(oprot thrift.TProtocol) (err error)

Write writes out the unknown fields.

type WithUnknownFields

type WithUnknownFields interface {
	// CarryingUnknownFields tells whether the structure contains data from fields not recognized by the current IDL.
	CarryingUnknownFields() bool
}

WithUnknownFields is the interface of all structures that supports keeping unknown fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL