Skip to content

Commit

Permalink
feat: match draft-11
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Fossati <[email protected]>
  • Loading branch information
thomas-fossati committed Nov 29, 2024
1 parent 2370afa commit 5e7e827
Show file tree
Hide file tree
Showing 18 changed files with 1,449 additions and 802 deletions.
36 changes: 36 additions & 0 deletions cbor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cmw

import (
"reflect"

"github.com/fxamacker/cbor/v2"
)

var (
em, emError = initCBOREncMode()
dm, dmError = initCBORDecMode()
)

func initCBOREncMode() (en cbor.EncMode, err error) {
o := cbor.CoreDetEncOptions() // use preset options as a starting point
return o.EncMode()
}

func initCBORDecMode() (en cbor.DecMode, err error) {
tags := cbor.NewTagSet()
tags.Add(
cbor.TagOptions{EncTag: cbor.EncTagNone, DecTag: cbor.DecTagOptional},
reflect.TypeOf(CMW{}),
765)

return cbor.DecOptions{}.DecModeWithTags(tags)
}

func init() {
if emError != nil {
panic(emError)
}
if dmError != nil {
panic(dmError)
}
}
Loading

0 comments on commit 5e7e827

Please sign in to comment.