Skip to content

Commit 55e521a

Browse files
feat: match draft-11
Signed-off-by: Thomas Fossati <[email protected]>
1 parent 2370afa commit 55e521a

18 files changed

+1562
-800
lines changed

cbor.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package cmw
2+
3+
import (
4+
"reflect"
5+
6+
"github.com/fxamacker/cbor/v2"
7+
)
8+
9+
var (
10+
em, emError = initCBOREncMode()
11+
dm, dmError = initCBORDecMode()
12+
)
13+
14+
func initCBOREncMode() (en cbor.EncMode, err error) {
15+
o := cbor.CoreDetEncOptions() // use preset options as a starting point
16+
return o.EncMode()
17+
}
18+
19+
func initCBORDecMode() (en cbor.DecMode, err error) {
20+
tags := cbor.NewTagSet()
21+
tags.Add(
22+
cbor.TagOptions{EncTag: cbor.EncTagNone, DecTag: cbor.DecTagOptional},
23+
reflect.TypeOf(CMW{}),
24+
765)
25+
26+
return cbor.DecOptions{}.DecModeWithTags(tags)
27+
}
28+
29+
func init() {
30+
if emError != nil {
31+
panic(emError)
32+
}
33+
if dmError != nil {
34+
panic(dmError)
35+
}
36+
}

0 commit comments

Comments
 (0)