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

Method Deserialize

go/fory/fory.go:556–573  ·  view source on GitHub ↗

Deserialize deserializes data directly into the provided target value. The target must be a pointer to the value to deserialize into.

(data []byte, v any)

Source from the content-addressed store, hash-verified

554// Deserialize deserializes data directly into the provided target value.
555// The target must be a pointer to the value to deserialize into.
556func (f *Fory) Deserialize(data []byte, v any) error {
557 defer f.resetReadState()
558 f.readCtx.SetData(data)
559
560 readHeader(f.readCtx)
561 if f.readCtx.HasError() {
562 return f.readCtx.TakeError()
563 }
564
565 // Deserialize the value - TypeMeta is read inline using streaming protocol
566 target := reflect.ValueOf(v).Elem()
567 f.readCtx.ReadValue(target, RefModeTracking, true)
568 if f.readCtx.HasError() {
569 return f.readCtx.TakeError()
570 }
571
572 return nil
573}
574
575// resetReadState resets read context state without allocation
576func (f *Fory) resetReadState() {

Callers 15

TestEvolvingRoundTripFunction · 0.95
UnmarshalMethod · 0.95
runLocalExampleRoundTripFunction · 0.45
runFileExampleRoundTripFunction · 0.45
runLocalAnyRoundTripFunction · 0.45
runLocalRoundTripFunction · 0.45
runFileRoundTripFunction · 0.45
runFileAutoIdRoundTripFunction · 0.45

Calls 6

resetReadStateMethod · 0.95
readHeaderFunction · 0.85
SetDataMethod · 0.80
ReadValueMethod · 0.80
HasErrorMethod · 0.45
TakeErrorMethod · 0.45

Tested by 15

TestEvolvingRoundTripFunction · 0.76
runLocalExampleRoundTripFunction · 0.36
runFileExampleRoundTripFunction · 0.36
runLocalAnyRoundTripFunction · 0.36
runLocalRoundTripFunction · 0.36
runFileRoundTripFunction · 0.36
runFileAutoIdRoundTripFunction · 0.36