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. //