From fa9bec0ac882b27ae6f7ef82a204b2140010d4d2 Mon Sep 17 00:00:00 2001 From: Eric Myhre Date: Thu, 19 Aug 2021 19:56:22 +0200 Subject: [PATCH] Move ADL interface to package. Also, fix up its docs. Phew, those had old and badly misleading links. --- adl.go | 4 ++-- adl/interface.go | 25 +++++++++++++++++++++++++ datamodel/node.go | 13 ------------- 3 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 adl/interface.go diff --git a/adl.go b/adl.go index 8bfe2d3e..bb761896 100644 --- a/adl.go +++ b/adl.go @@ -1,7 +1,7 @@ package ipld import ( - "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/adl" ) -type ADL = datamodel.ADL +type ADL = adl.ADL diff --git a/adl/interface.go b/adl/interface.go new file mode 100644 index 00000000..5cd77223 --- /dev/null +++ b/adl/interface.go @@ -0,0 +1,25 @@ +package adl + +import ( + "github.com/ipld/go-ipld-prime/datamodel" +) + +// ADL is an interface denoting an Advanced Data Layout, +// which is something that supports all the datamodel.Node operations, +// but may be doing so using some custom internal logic. +// +// For more details, see the docs at +// https://ipld.io/docs/advanced-data-layouts/ . +// +// This interface doesn't specify much new behavior, but it does include +// the requirement of a way to tell an examiner about your "substrate", +// since this concept does seem to be present in all ADLs. +type ADL interface { + datamodel.Node + + // Substrate returns the underlying Data Model node, which can be used + // to encode an ADL's raw layout. + // + // Note that the substrate of an ADL can contain other ADLs! + Substrate() datamodel.Node +} diff --git a/datamodel/node.go b/datamodel/node.go index b9b307a6..600dc25d 100644 --- a/datamodel/node.go +++ b/datamodel/node.go @@ -165,19 +165,6 @@ type Node interface { Prototype() NodePrototype } -// ADL represents an Advanced Data Layout, a special kind of Node which -// implements custom logic while still behaving like an IPLD node. -// -// For more details, see the docs at -// https://github.com/ipld/specs/blob/master/schemas/authoring-guide.md. -type ADL interface { - Node - - // Substrate returns the underlying Data Model node, which can be used - // to encode an ADL's raw layout. - Substrate() Node -} - // NodePrototype describes a node implementation (all Node have a NodePrototype), // and a NodePrototype can always be used to get a NodeBuilder. //