(ctx *WriteContext, value reflect.Value)
| 29 | } |
| 30 | |
| 31 | func (s *enumSerializer) WriteData(ctx *WriteContext, value reflect.Value) { |
| 32 | // Convert the enum value to its integer ordinal |
| 33 | var ordinal uint32 |
| 34 | switch value.Kind() { |
| 35 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
| 36 | ordinal = uint32(value.Int()) |
| 37 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
| 38 | ordinal = uint32(value.Uint()) |
| 39 | default: |
| 40 | ctx.SetError(SerializationErrorf("enum serializer: unsupported kind %v", value.Kind())) |
| 41 | return |
| 42 | } |
| 43 | ctx.buffer.WriteVarUint32Small7(ordinal) |
| 44 | } |
| 45 | |
| 46 | func (s *enumSerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) { |
| 47 | if refMode != RefModeNone { |
no test coverage detected