MCPcopy
hub / github.com/grpc/grpc-go / Unmarshal

Method Unmarshal

encoding/proto/proto.go:85–97  ·  view source on GitHub ↗
(data mem.BufferSlice, v any)

Source from the content-addressed store, hash-verified

83}
84
85func (c *codecV2) Unmarshal(data mem.BufferSlice, v any) (err error) {
86 vv := messageV2Of(v)
87 if vv == nil {
88 return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
89 }
90
91 buf := data.MaterializeToBuffer(mem.DefaultBufferPool())
92 defer buf.Free()
93 // TODO: Upgrade proto.Unmarshal to support mem.BufferSlice. Right now, it's not
94 // really possible without a major overhaul of the proto package, but the
95 // vtprotobuf library may be able to support this.
96 return proto.Unmarshal(buf.ReadOnlyData(), vv)
97}
98
99func messageV2Of(v any) proto.Message {
100 switch v := v.(type) {

Calls 7

DefaultBufferPoolFunction · 0.92
messageV2OfFunction · 0.85
MaterializeToBufferMethod · 0.80
ErrorfMethod · 0.65
FreeMethod · 0.65
UnmarshalMethod · 0.65
ReadOnlyDataMethod · 0.65