serializeReflectValue serializes a reflect.Value directly, avoiding boxing overhead. This is used by Serialize[T] fallback path to avoid struct copy. For structs, the value must be a pointer to struct, not struct value. go:noinline
(value reflect.Value)
| 781 | // |
| 782 | //go:noinline |
| 783 | func (f *Fory) serializeReflectValue(value reflect.Value) ([]byte, error) { |
| 784 | // Check that structs are passed as pointers |
| 785 | if value.Kind() == reflect.Struct { |
| 786 | return nil, fmt.Errorf("cannot serialize struct %s directly, use pointer to struct (*%s) instead", value.Type(), value.Type()) |
| 787 | } |
| 788 | |
| 789 | // Serialize the value - TypeMeta is written inline using streaming protocol |
| 790 | f.writeCtx.WriteValue(value, RefModeTracking, true) |
| 791 | if f.writeCtx.HasError() { |
| 792 | return nil, f.writeCtx.TakeError() |
| 793 | } |
| 794 | |
| 795 | return f.writeCtx.buffer.GetByteSlice(0, f.writeCtx.buffer.writerIndex), nil |
| 796 | } |
| 797 | |
| 798 | // ============================================================================ |
| 799 | // Protocol Header |
no test coverage detected