erigon-pulse/ethdb/cbor/marshal.go

34 lines
525 B
Go
Raw Normal View History

2020-10-02 03:56:13 +00:00
package cbor
import (
"io"
)
func Marshal(dst io.Writer, v interface{}) error {
2020-10-02 03:56:13 +00:00
e := Encoder(dst)
err := e.Encode(v)
returnEncoderToPool(e)
return err
}
func Unmarshal(dst interface{}, data io.Reader) error {
2020-10-02 03:56:13 +00:00
d := Decoder(data)
err := d.Decode(dst)
returnDecoderToPool(d)
return err
}
func MustMarshal(dst io.Writer, v interface{}) {
2020-10-02 03:56:13 +00:00
err := Marshal(dst, v)
if err != nil {
panic(err)
}
}
func MustUnmarshal(dst interface{}, data io.Reader) {
2020-10-02 03:56:13 +00:00
err := Unmarshal(dst, data)
if err != nil {
panic(err)
}
}