Back to godoc.org
go.uber.org/thriftrw / gen / internal / tests / enum_conflict

Package enum_conflict

v1.25.0
Latest Go to latest

The highest tagged major version is .

Published: Sep 10, 2020 | License: MIT | Module: go.uber.org/thriftrw

Index

Constants

const DefaultOtherRecordType enums.RecordType = enums.RecordTypeName

Variables

var ThriftModule = &thriftreflect.ThriftModule{
	Name:     "enum_conflict",
	Package:  "go.uber.org/thriftrw/gen/internal/tests/enum_conflict",
	FilePath: "enum_conflict.thrift",
	SHA1:     "75e0e6472e2f0c74412512d61531cf1a0da7429c",
	Includes: []*thriftreflect.ThriftModule{
		enums.ThriftModule,
	},
	Raw: rawIDL,
}

ThriftModule represents the IDL file used to generate this package.

type RecordType

type RecordType int32
const (
	RecordTypeName  RecordType = 0
	RecordTypeEmail RecordType = 1
)
const DefaultRecordType RecordType = RecordTypeName

func RecordType_Values

func RecordType_Values() []RecordType

RecordType_Values returns all recognized values of RecordType.

func (RecordType) Equals

func (v RecordType) Equals(rhs RecordType) bool

Equals returns true if this RecordType value matches the provided value.

func (*RecordType) FromWire

func (v *RecordType) FromWire(w wire.Value) error

FromWire deserializes RecordType from its Thrift-level representation.

x, err := binaryProtocol.Decode(reader, wire.TI32)
if err != nil {
  return RecordType(0), err
}

var v RecordType
if err := v.FromWire(x); err != nil {
  return RecordType(0), err
}
return v, nil

func (RecordType) MarshalJSON

func (v RecordType) MarshalJSON() ([]byte, error)

MarshalJSON serializes RecordType into JSON.

If the enum value is recognized, its name is returned. Otherwise, its integer value is returned.

This implements json.Marshaler.

func (RecordType) MarshalLogObject

func (v RecordType) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler, enabling fast logging of RecordType. Enums are logged as objects, where the value is logged with key "value", and if this value's name is known, the name is logged with key "name".

func (RecordType) MarshalText

func (v RecordType) MarshalText() ([]byte, error)

MarshalText encodes RecordType to text.

If the enum value is recognized, its name is returned. Otherwise, its integer value is returned.

This implements the TextMarshaler interface.

func (RecordType) Ptr

func (v RecordType) Ptr() *RecordType

Ptr returns a pointer to this enum value.

func (RecordType) String

func (v RecordType) String() string

String returns a readable string representation of RecordType.

func (RecordType) ToWire

func (v RecordType) ToWire() (wire.Value, error)

ToWire translates RecordType into a Thrift-level intermediate representation. This intermediate representation may be serialized into bytes using a ThriftRW protocol implementation.

Enums are represented as 32-bit integers over the wire.

func (*RecordType) UnmarshalJSON

func (v *RecordType) UnmarshalJSON(text []byte) error

UnmarshalJSON attempts to decode RecordType from its JSON representation.

This implementation supports both, numeric and string inputs. If a string is provided, it must be a known enum name.

This implements json.Unmarshaler.

func (*RecordType) UnmarshalText

func (v *RecordType) UnmarshalText(value []byte) error

UnmarshalText tries to decode RecordType from a byte slice containing its name.

var v RecordType
err := v.UnmarshalText([]byte("Name"))

type Records

type Records struct {
	RecordType      *RecordType       `json:"recordType,omitempty"`
	OtherRecordType *enums.RecordType `json:"otherRecordType,omitempty"`
}

func Default_Records

func Default_Records() *Records

Default_Records constructs a new Records struct, pre-populating any fields with defined default values.

func (*Records) Equals

func (v *Records) Equals(rhs *Records) bool

Equals returns true if all the fields of this Records match the provided Records.

This function performs a deep comparison.

func (*Records) FromWire

func (v *Records) FromWire(w wire.Value) error

FromWire deserializes a Records struct from its Thrift-level representation. The Thrift-level representation may be obtained from a ThriftRW protocol implementation.

An error is returned if we were unable to build a Records struct from the provided intermediate representation.

x, err := binaryProtocol.Decode(reader, wire.TStruct)
if err != nil {
  return nil, err
}

var v Records
if err := v.FromWire(x); err != nil {
  return nil, err
}
return &v, nil

func (*Records) GetOtherRecordType

func (v *Records) GetOtherRecordType() (o enums.RecordType)

GetOtherRecordType returns the value of OtherRecordType if it is set or its default value if it is unset.

func (*Records) GetRecordType

func (v *Records) GetRecordType() (o RecordType)

GetRecordType returns the value of RecordType if it is set or its default value if it is unset.

func (*Records) IsSetOtherRecordType

func (v *Records) IsSetOtherRecordType() bool

IsSetOtherRecordType returns true if OtherRecordType is not nil.

func (*Records) IsSetRecordType

func (v *Records) IsSetRecordType() bool

IsSetRecordType returns true if RecordType is not nil.

func (*Records) MarshalLogObject

func (v *Records) MarshalLogObject(enc zapcore.ObjectEncoder) (err error)

MarshalLogObject implements zapcore.ObjectMarshaler, enabling fast logging of Records.

func (*Records) String

func (v *Records) String() string

String returns a readable string representation of a Records struct.

func (*Records) ToWire

func (v *Records) ToWire() (wire.Value, error)

ToWire translates a Records struct into a Thrift-level intermediate representation. This intermediate representation may be serialized into bytes using a ThriftRW protocol implementation.

An error is returned if the struct or any of its fields failed to validate.

x, err := v.ToWire()
if err != nil {
  return err
}

if err := binaryProtocol.Encode(x, writer); err != nil {
  return err
}

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier