MCPcopy
hub / github.com/tinylib/msgp / DecoderFrom

Function DecoderFrom

msgp/iter.go:308–315  ·  view source on GitHub ↗

DecoderFrom allows augmenting any type with a DecodeMsg method into a method that reads from Reader and returns a T. Provide an instance of T. This value isn't used. See ReadArray/ReadMap "struct" examples for usage.

(r *Reader, _ T)

Source from the content-addressed store, hash-verified

306// Provide an instance of T. This value isn't used.
307// See ReadArray/ReadMap "struct" examples for usage.
308func DecoderFrom[T any, PT DecodePtr[T]](r *Reader, _ T) func() (T, error) {
309 return func() (T, error) {
310 var t T
311 tPtr := PT(&t)
312 err := tPtr.DecodeMsg(r)
313 return t, err
314 }
315}
316
317// FlexibleEncoder is a constraint for types where either T or *T implements Encodable
318type FlexibleEncoder[T any] interface {

Callers 3

ExampleReadArray_structFunction · 0.85
ExampleReadMap_structFunction · 0.85

Calls 1

DecodeMsgMethod · 0.65

Tested by 3

ExampleReadArray_structFunction · 0.68
ExampleReadMap_structFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…