node.go 1.23 KB
Newer Older
1 2 3 4
package typed

import (
	"github.com/ipld/go-ipld-prime"
5
	"github.com/ipld/go-ipld-prime/typed/system"
6 7
)

8 9 10 11 12 13 14 15 16 17 18 19 20
// typed.Node is a superset of the ipld.Node interface, and has additional behaviors.
//
// A typed.Node can be inspected for its typesystem.Type and typesystem.Kind,
// which conveys much more and richer information than the Data Model layer
// ipld.ReprKind.
//
// There are many different implementations of typed.Node.
// One implementation can wrap any other existing ipld.Node (i.e., it's zero-copy)
// and promises that it has *already* been validated to match the typesystem.Type;
// another implementation similarly wraps any other existing ipld.Node, but
// defers to the typesystem validation checking to fields that are accessed;
// and when using code generation tools, all of the generated native Golang
// types produced by the codegen will each individually implement typed.Node.
21 22 23 24 25
//
// Note that typed.Node can wrap *other* typed.Node instances.
// Imagine you have two parts of a very large code base which have codegen'd
// components which are from different versions of a schema.  Smooth migrations
// and zero-copy type-safe data sharing between them: We can accommodate that!
26 27
type Node interface {
	ipld.Node
28

29
	Type() typesystem.Type
30
}