Decode applies raw binary transcoding behaviour to decode into a Go type.
(bytes []byte, flags uint32, out interface{})
| 528 | |
| 529 | // Decode applies raw binary transcoding behaviour to decode into a Go type. |
| 530 | func (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. |
| 551 | func (t *SGRawTranscoder) Encode(value interface{}) ([]byte, uint32, error) { |