Decode unmarshals a CBOR Value into the target.
(v cbor.Value, to interface{})
| 42 | |
| 43 | // Decode unmarshals a CBOR Value into the target. |
| 44 | func (d *decoder) Decode(v cbor.Value, to interface{}) error { |
| 45 | if document.IsNoSerde(to) { |
| 46 | return fmt.Errorf("unsupported type: %T", to) |
| 47 | } |
| 48 | |
| 49 | rv := reflect.ValueOf(to) |
| 50 | if rv.Kind() != reflect.Ptr || rv.IsNil() || !rv.IsValid() { |
| 51 | return &document.InvalidUnmarshalError{Type: reflect.TypeOf(to)} |
| 52 | } |
| 53 | |
| 54 | return d.decode(v, rv, serde.Tag{}) |
| 55 | } |
| 56 | |
| 57 | func (d *decoder) decode(cv cbor.Value, rv reflect.Value, tag serde.Tag) error { |
| 58 | if _, ok := cv.(*cbor.Nil); ok { |