MCPcopy Create free account
hub / github.com/apache/fory / Read

Method Read

go/fory/enum.go:80–114  ·  view source on GitHub ↗
(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value)

Source from the content-addressed store, hash-verified

78}
79
80func (s *enumSerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) {
81 err := ctx.Err()
82 if refMode != RefModeNone {
83 if ctx.buffer.ReadInt8(err) == NullFlag {
84 return
85 }
86 }
87 if readType {
88 typeID := uint32(ctx.buffer.ReadUint8(err))
89 if ctx.HasError() {
90 return
91 }
92 internalID := TypeId(typeID)
93 if internalID != ENUM && internalID != NAMED_ENUM {
94 ctx.SetError(TypeMismatchError(internalID, ENUM))
95 return
96 }
97 typeInfo := ctx.TypeResolver().readTypeInfoWithTypeID(ctx.buffer, typeID, err)
98 if ctx.HasError() {
99 return
100 }
101 if typeInfo == nil || typeInfo.Type != s.type_ {
102 var actualType reflect.Type
103 if typeInfo != nil {
104 actualType = typeInfo.Type
105 }
106 ctx.SetError(DeserializationErrorf("enum type mismatch: expected %v, got %v", s.type_, actualType))
107 return
108 }
109 }
110 if ctx.HasError() {
111 return
112 }
113 s.ReadData(ctx, value)
114}
115
116func (s *enumSerializer) ReadWithTypeInfo(ctx *ReadContext, refMode RefMode, typeInfo *TypeInfo, value reflect.Value) {
117 s.Read(ctx, refMode, false, false, value)

Callers 1

ReadWithTypeInfoMethod · 0.95

Calls 12

ReadDataMethod · 0.95
TypeMismatchErrorFunction · 0.85
DeserializationErrorfFunction · 0.85
ReadUint8Method · 0.80
uint32Function · 0.50
TypeIdEnum · 0.50
ErrMethod · 0.45
ReadInt8Method · 0.45
HasErrorMethod · 0.45
SetErrorMethod · 0.45
TypeResolverMethod · 0.45

Tested by

no test coverage detected