MCPcopy Create free account
hub / github.com/aws/smithy-go / Decode

Method Decode

document/cbor/decode.go:44–55  ·  view source on GitHub ↗

Decode unmarshals a CBOR Value into the target.

(v cbor.Value, to interface{})

Source from the content-addressed store, hash-verified

42
43// Decode unmarshals a CBOR Value into the target.
44func (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
57func (d *decoder) decode(cv cbor.Value, rv reflect.Value, tag serde.Tag) error {
58 if _, ok := cv.(*cbor.Nil); ok {

Callers 3

TestDecode_KitchenSinkFunction · 0.95
MustJSONUnmarshalFunction · 0.80

Calls 4

decodeMethod · 0.95
IsNoSerdeFunction · 0.92
ErrorfMethod · 0.80
IsValidMethod · 0.80

Tested by 2

TestDecode_KitchenSinkFunction · 0.76
MustJSONUnmarshalFunction · 0.64