DecoderFromBytes allows augmenting any type with an UnmarshalMsg method into a method that reads from []byte and returns a T. Provide an instance of T. This value isn't used. See ReadArrayBytes or ReadMapBytes "struct" examples for usage.
(_ T)
| 350 | // Provide an instance of T. This value isn't used. |
| 351 | // See ReadArrayBytes or ReadMapBytes "struct" examples for usage. |
| 352 | func DecoderFromBytes[T any, PT UnmarshalPtr[T]](_ T) func([]byte) (T, []byte, error) { |
| 353 | return func(b []byte) (T, []byte, error) { |
| 354 | var t T |
| 355 | tPtr := PT(&t) |
| 356 | b, err := tPtr.UnmarshalMsg(b) |
| 357 | return t, b, err |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | // FlexibleMarshaler is a constraint for types where either T or *T implements Marshaler |
| 362 | type FlexibleMarshaler[T any] interface { |
searching dependent graphs…