From 27e0a6a44864ac37152a398cd37ef01fbdc04a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 17 Mar 2021 15:07:19 +0100 Subject: [PATCH] re-add the Encoder and Decoder APIs We're a semver v1, so we can't remove exposed APIs unless we bump to v2+. Bumping the major version to just rename two APIs seems a bit overkill; keeping the old ones around and deprecating them is much easier. This partially reverts commit b8473079d0cdc9d6b4d8f386524ed54312cb7cda. --- multicodec.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/multicodec.go b/multicodec.go index 180328a..e222e45 100644 --- a/multicodec.go +++ b/multicodec.go @@ -50,3 +50,18 @@ func AddSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) trav return existing(lnk, lnkCtx) } } + +// We switched to simpler API names after v1.0.0, so keep the old names around +// as deprecated forwarding funcs until a future v2+. +// TODO: consider deprecating Marshal/Unmarshal too, since it's a bit +// unnecessary to have two supported names for each API. + +// Deprecated: use Decode instead. +func Decoder(na ipld.NodeAssembler, r io.Reader) error { + return Unmarshal(na, r) +} + +// Deprecated: use Encode instead. +func Encoder(n ipld.Node, w io.Writer) error { + return Marshal(n, w) +} -- GitLab