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

Method DeserializeWithCallbackBuffers

go/fory/fory.go:735–776  ·  view source on GitHub ↗

DeserializeWithCallbackBuffers deserializes from buffer into the provided value (for streaming/cross-language use). The third parameter is optional external buffers for out-of-band data (can be nil).

(buffer *ByteBuffer, v any, buffers []*ByteBuffer)

Source from the content-addressed store, hash-verified

733// DeserializeWithCallbackBuffers deserializes from buffer into the provided value (for streaming/cross-language use).
734// The third parameter is optional external buffers for out-of-band data (can be nil).
735func (f *Fory) DeserializeWithCallbackBuffers(buffer *ByteBuffer, v any, buffers []*ByteBuffer) error {
736 // Reset context and use the provided buffer
737 f.readCtx.buffer = buffer
738 defer func() {
739 f.readCtx.Reset()
740 if f.metaContext != nil {
741 f.metaContext.Reset()
742 }
743 f.readCtx.buffer = nil
744 f.readCtx.outOfBandBuffers = nil
745 }()
746 // Set up out-of-band buffers if provided
747 if buffers != nil {
748 f.readCtx.outOfBandBuffers = buffers
749 }
750
751 // ReadData and validate header
752 readHeader(f.readCtx)
753 if f.readCtx.HasError() {
754 return f.readCtx.TakeError()
755 }
756
757 // v must be a pointer so we can deserialize into it
758 if v == nil {
759 return fmt.Errorf("v cannot be nil")
760 }
761 rv := reflect.ValueOf(v)
762 if rv.Kind() != reflect.Ptr {
763 return fmt.Errorf("v must be a pointer, got %v", rv.Kind())
764 }
765 if rv.IsNil() {
766 return fmt.Errorf("v must be a non-nil pointer")
767 }
768
769 // Deserialize the value - TypeMeta is read inline using streaming protocol
770 f.readCtx.ReadValue(rv.Elem(), RefModeTracking, true)
771 if f.readCtx.HasError() {
772 return f.readCtx.TakeError()
773 }
774
775 return nil
776}
777
778// serializeReflectValue serializes a reflect.Value directly, avoiding boxing overhead.
779// This is used by Serialize[T] fallback path to avoid struct copy.

Callers 15

testStringSerializerFunction · 0.80
testListFunction · 0.80
testMapFunction · 0.80
testIntegerFunction · 0.80
testDecimalFunction · 0.80
testItemFunction · 0.80
testColorFunction · 0.80
testConsistentNamedFunction · 0.80
testPolymorphicListFunction · 0.80

Calls 6

readHeaderFunction · 0.85
KindMethod · 0.80
ReadValueMethod · 0.80
ResetMethod · 0.45
HasErrorMethod · 0.45
TakeErrorMethod · 0.45

Tested by 1