Decode decodes b into a new instance of the target type.
(ctx context.Context, b []byte)
| 436 | |
| 437 | // Decode decodes b into a new instance of the target type. |
| 438 | func (d *Decoder) Decode(ctx context.Context, b []byte) (any, error) { |
| 439 | nv := reflect.New(d.typ).Interface() |
| 440 | if err := d.fn(ctx, b, nv); err != nil { |
| 441 | return nil, err |
| 442 | } |
| 443 | ptr := reflect.ValueOf(nv) |
| 444 | return ptr.Elem().Interface(), nil |
| 445 | } |
| 446 | |
| 447 | var ( |
| 448 | // StringDecoder decodes into strings. |
no outgoing calls