From dde1d15ca0807951b0e064660f31f7894fa920dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Tue, 1 Oct 2024 11:42:20 +0200 Subject: [PATCH] deprecate DumpObject() in favor of better named Encode() --- node.go | 7 ++++++- node_test.go | 4 ++-- wrap_test.go | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/node.go b/node.go index e16d49e..1f880c3 100644 --- a/node.go +++ b/node.go @@ -396,8 +396,13 @@ func (n *Node) MarshalJSON() ([]byte, error) { } // DumpObject marshals any object into its CBOR serialized byte representation -// TODO: rename +// Deprecated: use Encode instead. func DumpObject(obj interface{}) (out []byte, err error) { + return Encode(obj) +} + +// Encode marshals any object into its CBOR serialized byte representation +func Encode(obj interface{}) (out []byte, err error) { return marshaller.Marshal(obj) } diff --git a/node_test.go b/node_test.go index ad9c973..b6b131e 100644 --- a/node_test.go +++ b/node_test.go @@ -593,7 +593,7 @@ func TestBigIntRoundtrip(t *testing.T) { World: *big.NewInt(99), } - bytes, err := DumpObject(&one) + bytes, err := Encode(&one) if err != nil { t.Fatal(err) } @@ -616,7 +616,7 @@ func TestBigIntRoundtrip(t *testing.T) { "world": {Hello: big.NewInt(9), World: *big.NewInt(901), Hi: 3}, } - bytes, err = DumpObject(list) + bytes, err = Encode(list) if err != nil { t.Fatal(err) } diff --git a/wrap_test.go b/wrap_test.go index 875e6ae..313ba21 100644 --- a/wrap_test.go +++ b/wrap_test.go @@ -111,10 +111,10 @@ func BenchmarkDecodeBlockParallel(b *testing.B) { } } -func BenchmarkDumpObject(b *testing.B) { +func BenchmarkEncode(b *testing.B) { obj := testStruct() for i := 0; i < b.N; i++ { - bytes, err := DumpObject(obj) + bytes, err := Encode(obj) if err != nil { b.Fatal(err, bytes) }