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

Method DeserializeFromStream

go/fory/stream.go:96–116  ·  view source on GitHub ↗

DeserializeFromStream reads the next object from the stream into the provided value. It preserves the stream buffer while clearing root-scoped read metadata between calls.

(is *InputStream, v any)

Source from the content-addressed store, hash-verified

94// DeserializeFromStream reads the next object from the stream into the provided value.
95// It preserves the stream buffer while clearing root-scoped read metadata between calls.
96func (f *Fory) DeserializeFromStream(is *InputStream, v any) error {
97 origBuffer := f.readCtx.buffer
98 f.readCtx.buffer = is.buffer
99 defer func() {
100 f.readCtx.buffer = origBuffer
101 f.resetReadState()
102 }()
103
104 readHeader(f.readCtx)
105 if f.readCtx.HasError() {
106 return f.readCtx.TakeError()
107 }
108
109 target := reflect.ValueOf(v).Elem()
110 f.readCtx.ReadValue(target, RefModeTracking, true)
111 if f.readCtx.HasError() {
112 return f.readCtx.TakeError()
113 }
114
115 return nil
116}
117
118// DeserializeFromReader deserializes a single object from a stream.
119// It is strictly stateless: the buffer and all read state are always reset before

Calls 5

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