Unverified Commit be142a5a authored by Whyrusleeping's avatar Whyrusleeping Committed by GitHub

Merge pull request #55 from whyrusleeping/feat/non-pointer-enc

feat: take cbor adapters by-value when encoding
parents ad5b8262 d660ae24
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
type CborCid cid.Cid type CborCid cid.Cid
func (c *CborCid) MarshalCBOR(w io.Writer) error { func (c CborCid) MarshalCBOR(w io.Writer) error {
return WriteCid(w, cid.Cid(*c)) return WriteCid(w, cid.Cid(c))
} }
func (c *CborCid) UnmarshalCBOR(r io.Reader) error { func (c *CborCid) UnmarshalCBOR(r io.Reader) error {
......
...@@ -626,8 +626,8 @@ func WriteCidBuf(buf []byte, w io.Writer, c cid.Cid) error { ...@@ -626,8 +626,8 @@ func WriteCidBuf(buf []byte, w io.Writer, c cid.Cid) error {
type CborBool bool type CborBool bool
func (cb *CborBool) MarshalCBOR(w io.Writer) error { func (cb CborBool) MarshalCBOR(w io.Writer) error {
return WriteBool(w, bool(*cb)) return WriteBool(w, bool(cb))
} }
func (cb *CborBool) UnmarshalCBOR(r io.Reader) error { func (cb *CborBool) UnmarshalCBOR(r io.Reader) error {
...@@ -653,8 +653,8 @@ func (cb *CborBool) UnmarshalCBOR(r io.Reader) error { ...@@ -653,8 +653,8 @@ func (cb *CborBool) UnmarshalCBOR(r io.Reader) error {
type CborInt int64 type CborInt int64
func (ci *CborInt) MarshalCBOR(w io.Writer) error { func (ci CborInt) MarshalCBOR(w io.Writer) error {
v := int64(*ci) v := int64(ci)
if v >= 0 { if v >= 0 {
if err := WriteMajorTypeHeader(w, MajUnsignedInt, uint64(v)); err != nil { if err := WriteMajorTypeHeader(w, MajUnsignedInt, uint64(v)); err != nil {
return err return err
...@@ -695,7 +695,7 @@ func (ci *CborInt) UnmarshalCBOR(r io.Reader) error { ...@@ -695,7 +695,7 @@ func (ci *CborInt) UnmarshalCBOR(r io.Reader) error {
type CborTime time.Time type CborTime time.Time
func (ct *CborTime) MarshalCBOR(w io.Writer) error { func (ct CborTime) MarshalCBOR(w io.Writer) error {
nsecs := ct.Time().UnixNano() nsecs := ct.Time().UnixNano()
cbi := CborInt(nsecs) cbi := CborInt(nsecs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment