12345678910111213141516171819 |
- package borealis
- import "github.com/fxamacker/cbor/v2"
- type MessageEncoderV1 struct{}
- func (encoder *MessageEncoderV1) Encode(stream string, message interface{}) ([]byte, error) {
- return cbor.Marshal(message)
- }
- func (encoder *MessageEncoderV1) Decode(stream string, input []byte, messagePtr interface{}) error {
- switch message := messagePtr.(type) {
- case *[]byte:
- *message = input
- return nil
- default:
- return cbor.Unmarshal(input, message)
- }
- }
|