forked from OneOfOne/genh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgp.go
49 lines (38 loc) · 1.11 KB
/
msgp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package genh
import (
"io"
"github.com/vmihailenco/msgpack/v5"
"github.com/alpineiq/genh/internal"
)
type (
MsgpackEncoder = msgpack.Encoder
MsgpackDecoder = msgpack.Decoder
)
func UnmarshalMsgpack(b []byte, v any) error {
return internal.UnmarshalMsgpack(b, v)
}
func MarshalMsgpack(v any) ([]byte, error) {
return internal.MarshalMsgpack(v)
}
func EncodeMsgpack(w io.Writer, vs ...any) error {
return internal.EncodeMsgpack(w, vs...)
}
func DecodeMsgpack(r io.Reader, vs ...any) error {
return internal.DecodeMsgpack(r, vs...)
}
// NewMsgpackDecoder returns a new Decoder that writes to w.
// uses json CustomStructTag, compact floats and ints.
func NewMsgpackEncoder(w io.Writer) *MsgpackEncoder {
return internal.NewMsgpackEncoder(w)
}
func PutMsgpackEncoder(enc *MsgpackEncoder) {
internal.PutMsgpackEncoder(enc)
}
// NewMsgpackDecoder returns a new Decoder that reads from r.
// uses json CustomStructTag, and loose interface decoding.
func NewMsgpackDecoder(r io.Reader) *MsgpackDecoder {
return internal.NewMsgpackDecoder(r)
}
func PutMsgpackDecoder(dec *MsgpackDecoder) {
internal.PutMsgpackDecoder(dec)
}