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

Method ReadData

go/fory/enum.go:62–78  ·  view source on GitHub ↗
(ctx *ReadContext, value reflect.Value)

Source from the content-addressed store, hash-verified

60}
61
62func (s *enumSerializer) ReadData(ctx *ReadContext, value reflect.Value) {
63 err := ctx.Err()
64 ordinal := ctx.buffer.ReadVarUint32Small7(err)
65 if ctx.HasError() {
66 return
67 }
68
69 // Set the value based on the underlying kind
70 switch value.Kind() {
71 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
72 value.SetInt(int64(ordinal))
73 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
74 value.SetUint(uint64(ordinal))
75 default:
76 ctx.SetError(DeserializationErrorf("enum serializer: unsupported kind %v", value.Kind()))
77 }
78}
79
80func (s *enumSerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) {
81 err := ctx.Err()

Callers 1

ReadMethod · 0.95

Calls 8

DeserializationErrorfFunction · 0.85
ReadVarUint32Small7Method · 0.80
KindMethod · 0.80
int64Function · 0.50
uint64Function · 0.50
ErrMethod · 0.45
HasErrorMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected