MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / Decode

Method Decode

base/collection_gocb.go:530–548  ·  view source on GitHub ↗

Decode applies raw binary transcoding behaviour to decode into a Go type.

(bytes []byte, flags uint32, out interface{})

Source from the content-addressed store, hash-verified

528
529// Decode applies raw binary transcoding behaviour to decode into a Go type.
530func (t *SGRawTranscoder) Decode(bytes []byte, flags uint32, out interface{}) error {
531 valueType, compression := gocbcore.DecodeCommonFlags(flags)
532
533 // Make sure compression is disabled
534 if compression != gocbcore.NoCompression {
535 return errors.New("unexpected value compression")
536 }
537 // Normal types of decoding
538 switch valueType {
539 case gocbcore.BinaryType:
540 return gocb.NewRawBinaryTranscoder().Decode(bytes, flags, out)
541 case gocbcore.StringType:
542 return gocb.NewRawStringTranscoder().Decode(bytes, flags, out)
543 case gocbcore.JSONType:
544 return gocb.NewRawJSONTranscoder().Decode(bytes, flags, out)
545 default:
546 return errors.New("unexpected expectedFlags value")
547 }
548}
549
550// Encode applies raw binary transcoding behaviour to encode a Go type.
551func (t *SGRawTranscoder) Encode(value interface{}) ([]byte, uint32, error) {

Callers

nothing calls this directly

Calls 1

DecodeMethod · 0.65

Tested by

no test coverage detected