diff --git a/HACKME.md b/HACKME.md index 971a3767..08d32c2e 100644 --- a/HACKME.md +++ b/HACKME.md @@ -57,16 +57,16 @@ effective instructions for how one could build a copy of that node, using the same implementation details. By example, if some node `n` was made as a `basicnode.plainString`, -then `n.Prototype()` will be `basicnode.Prototype__String{}`, +then `n.Prototype()` will be `basicnode.Prototype.String`, and `n.Prototype().NewBuilder().AssignString("xyz")` can be presumed to work. Note there are also limits to this: if a node was built in a flexible way, the prototype it reports later may only report what it is now, and not return that same flexibility again. By example, if something was made as an "any" -- i.e., -via `basicnode.Prototype__Any{}.NewBuilder()`, and then *happened* to be assigned a string value -- +via `basicnode.Prototype.Any.NewBuilder()`, and then *happened* to be assigned a string value -- the resulting node will still carry a `Prototype()` property that returns -`Prototype__String` -- **not** `Prototype__Any`. +`basicnode.Prototype.String` -- **not** `basicnode.Prototype.Any`. #### NodePrototype meets generic transformation @@ -102,7 +102,7 @@ and might be wrapped with additional rules (such as map key uniqueness, field name expectations, etc). (Note that it's also not an exclusive statement about what `AssignNode(Node)` will -accept; e.g. in many situations, while a `Prototype__MyStringType` might be the prototype +accept; e.g. in many situations, while a `Prototype.MyStringType` might be the prototype returned, any string kinded node can be used in `AssignNode(Node)` and will be appropriately converted.) diff --git a/README.md b/README.md index 59a3b911..9ca389ea 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ if you want to write your own extensions, whether for new Node implementations or new codecs, or new higher-order order functions!) - `github.com/ipld/go-ipld-prime` -- imported as just `ipld` -- contains the core interfaces for IPLD. The most important interfaces are `Node`, `NodeBuilder`, `Path`, and `Link`. -- `github.com/ipld/go-ipld-prime/node/basic` -- imported as `basicnode` -- provides concrete implementations of `Node` and `NodeBuilder` which work for any kind of data. +- `github.com/ipld/go-ipld-prime/node/basicnode` -- imported as `basicnode` -- provides concrete implementations of `Node` and `NodeBuilder` which work for any kind of data. - `github.com/ipld/go-ipld-prime/traversal` -- contains higher-order functions for traversing graphs of data easily. - `github.com/ipld/go-ipld-prime/traversal/selector` -- contains selectors, which are sort of like regexps, but for trees and graphs of IPLD data! - `github.com/ipld/go-ipld-prime/codec` -- parent package of all the codec implementations! diff --git a/_rsrch/methodsets/base.go b/_rsrch/methodsets/base.go deleted file mode 100644 index ff849578..00000000 --- a/_rsrch/methodsets/base.go +++ /dev/null @@ -1,15 +0,0 @@ -package methodsets - -type Thing struct { - Alpha string - Beta string -} - -func (x *Thing) Pow() { - x.Alpha = "base" -} - -type ThingPrivate struct { - a string - b string -} diff --git a/_rsrch/methodsets/crosspkg/isomorphicCast.go b/_rsrch/methodsets/crosspkg/isomorphicCast.go deleted file mode 100644 index b51f513d..00000000 --- a/_rsrch/methodsets/crosspkg/isomorphicCast.go +++ /dev/null @@ -1,26 +0,0 @@ -package crosspkg - -import ( - "github.com/ipld/go-ipld-prime/_rsrch/methodsets" -) - -type What struct { - Alpha string - Beta string -} - -func FlipWhat(x *methodsets.Thing) *What { - return (*What)(x) -} - -type WhatPrivate struct { - a string - b string -} - -//func FlipWhatPrivate(x *methodsets.ThingPrivate) *What { -// return (*WhatPrivate)(x) -//} -// NOPE! -// (thank HEAVENS.) -// ./isomorphicCast.go:22:23: cannot convert x (type *methodsets.ThingPrivate) to type *WhatPrivate diff --git a/_rsrch/methodsets/viaAliases.go b/_rsrch/methodsets/viaAliases.go deleted file mode 100644 index 68e9b4ee..00000000 --- a/_rsrch/methodsets/viaAliases.go +++ /dev/null @@ -1,28 +0,0 @@ -package methodsets - -type AliasThing = Thing - -// func (x *AliasThing) Pow() {} -// NOPE! -// ./viaAliases.go:5:22: (*Thing).Pow redeclared in this block -// previous declaration at ./base.go:8:6 - -type AliasPtr = *Thing - -// ^ Oddly, works. - -// func (x *AliasPtr) Pow() {} -// NOPE! -// ./aliases.go:14:6: invalid receiver type **Thing (*Thing is not a defined type) - -// func (x AliasPtr) Pow() {} -// NOPE! -// ./aliases.go:18:19: (*Thing).Pow redeclared in this block -// previous declaration at ./base.go:8:6 - -/* - Conclusion: no joy. - Aliases really are a syntactic sugar thing, and do not seem to enable - any interesting tricks that would not otherwise be possible, - and certainly don't appear to get us closer to the "methodsets" semantic I yearn for. -*/ diff --git a/_rsrch/methodsets/viaTypedef.go b/_rsrch/methodsets/viaTypedef.go deleted file mode 100644 index 90999813..00000000 --- a/_rsrch/methodsets/viaTypedef.go +++ /dev/null @@ -1,15 +0,0 @@ -package methodsets - -type Thing2ViaTypedef Thing - -// This also compiles and works if you longhand the entire struct defn again... -// as long as it's identical, it works. -// (This does not extend to replacing field types with other-named but structurally identical types.) - -func FlipTypedef(x *Thing) *Thing2ViaTypedef { - return (*Thing2ViaTypedef)(x) -} - -func (x *Thing2ViaTypedef) Pow() { - x.Alpha = "typedef" -} diff --git a/_rsrch/methodsets/viaTypedef_test.go b/_rsrch/methodsets/viaTypedef_test.go deleted file mode 100644 index 861c860e..00000000 --- a/_rsrch/methodsets/viaTypedef_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package methodsets - -import ( - "testing" - - . "github.com/warpfork/go-wish" -) - -func TestViaTypedef(t *testing.T) { - x := Thing{"alpha", "beta"} - - x.Pow() - Wish(t, x, ShouldEqual, Thing{"base", "beta"}) - - x2 := FlipTypedef(&x) - Wish(t, x2, ShouldEqual, &Thing2ViaTypedef{"base", "beta"}) - - x2.Pow() - Wish(t, x2, ShouldEqual, &Thing2ViaTypedef{"typedef", "beta"}) - - Wish(t, x, ShouldEqual, Thing{"typedef", "beta"}) // ! effects propagate back to original. - - x.Pow() - Wish(t, x2, ShouldEqual, &Thing2ViaTypedef{"base", "beta"}) // ! and still also vice versa. - - // it's not just that we care about retaining mutability (though that's sometimes useful); - // it's that a 'yes' to that directly implies 'yes' to "can we get this pov without any allocations". -} diff --git a/_rsrch/methodsets/viaUnsafe.go b/_rsrch/methodsets/viaUnsafe.go deleted file mode 100644 index e14883c3..00000000 --- a/_rsrch/methodsets/viaUnsafe.go +++ /dev/null @@ -1,22 +0,0 @@ -package methodsets - -import ( - "unsafe" -) - -type Thing2ViaUnsafe struct { - Alpha string - Beta string -} - -func FlipUnsafe(x *Thing) *Thing2ViaUnsafe { - return (*Thing2ViaUnsafe)(unsafe.Pointer(x)) -} - -func UnflipUnsafe(x *Thing2ViaUnsafe) *Thing { - return (*Thing)(unsafe.Pointer(x)) -} - -func (x *Thing2ViaUnsafe) Pow() { - x.Alpha = "unsafe" -} diff --git a/_rsrch/methodsets/viaUnsafe_test.go b/_rsrch/methodsets/viaUnsafe_test.go deleted file mode 100644 index f0489ee9..00000000 --- a/_rsrch/methodsets/viaUnsafe_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package methodsets - -import ( - "testing" - - . "github.com/warpfork/go-wish" -) - -func TestViaUnsafe(t *testing.T) { - x := Thing{"alpha", "beta"} - - x.Pow() - Wish(t, x, ShouldEqual, Thing{"base", "beta"}) - - x2 := FlipUnsafe(&x) - Wish(t, x2, ShouldEqual, &Thing2ViaUnsafe{"base", "beta"}) - - x2.Pow() - Wish(t, x2, ShouldEqual, &Thing2ViaUnsafe{"unsafe", "beta"}) - - Wish(t, x, ShouldEqual, Thing{"unsafe", "beta"}) // ! effects propagate back to original. - - x.Pow() - Wish(t, x2, ShouldEqual, &Thing2ViaUnsafe{"base", "beta"}) // ! and still also vice versa. - - // it's not just that we care about retaining mutability (though that's sometimes useful); - // it's that a 'yes' to that directly implies 'yes' to "can we get this pov without any allocations". -} diff --git a/_rsrch/microbench/multihoisting/canhazptrcmp_test.go b/_rsrch/microbench/multihoisting/canhazptrcmp_test.go deleted file mode 100644 index 3f1beae0..00000000 --- a/_rsrch/microbench/multihoisting/canhazptrcmp_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package multihoisting - -import ( - "testing" -) - -func BenchmarkCmpPtrs(b *testing.B) { - for i := 0; i < b.N; i++ { - v := hoisty{} - e := returnE(&v.b) - if e == &v.b.e { - sink = e - } else { - b.Fail() - } - sink = e - } -} - -func BenchmarkCmpVal(b *testing.B) { - for i := 0; i < b.N; i++ { - v := hoisty{} - e := returnE(&v.b) - if *e == v.b.e { - sink = e - } else { - b.Fail() - } - sink = e - } -} - -// not sure these are nailing it because no interfaces were harmed in the making -// also the sink is... gonna cost different things for these; need something else for the inside of the 'if'. -// ^ jk that last, actually. it does one alloc either way... just shuffles which line technically triggers it. -// the value compare *is* slower, but on the order of two nanoseconds. diff --git a/_rsrch/microbench/multihoisting/multihoisting_test.go b/_rsrch/microbench/multihoisting/multihoisting_test.go deleted file mode 100644 index 11cff953..00000000 --- a/_rsrch/microbench/multihoisting/multihoisting_test.go +++ /dev/null @@ -1,186 +0,0 @@ -package multihoisting - -import ( - "testing" -) - -var sink interface{} - -type nest struct { - a, b, c nest2 -} - -type nest2 struct { - d nest3 -} - -type nest3 string - -type fizz interface { - buzz(string) fizz -} - -func (x nest) buzz(k string) fizz { - switch k { - case "a": - return x.a - case "b": - return x.b - case "c": - return x.c - default: - return nil - } -} -func (x nest2) buzz(k string) fizz { - switch k { - case "d": - return x.d - default: - return nil - } -} -func (x nest3) buzz(k string) fizz { - return x -} - -// b.Log(unsafe.Sizeof(nest{})) - -// These all three score: -// BenchmarkWot1-8 50000000 31.6 ns/op 16 B/op 1 allocs/op -// BenchmarkWot2-8 30000000 35.3 ns/op 16 B/op 1 allocs/op -// BenchmarkWot3-8 50000000 37.1 ns/op 16 B/op 1 allocs/op -// -// Don't entirely get it (namely the 16). -// Something fancy that's enabled by inlining, for sure. -// The one alloc makes enough sense: it's just what's going into 'sink'. -func BenchmarkWot1(b *testing.B) { - for i := 0; i < b.N; i++ { - v := nest{} - sink = v.buzz("a") - } -} -func BenchmarkWot2(b *testing.B) { - for i := 0; i < b.N; i++ { - v := nest{} - fizzer := v.buzz("a") - sink = fizzer.buzz("d") - } -} -func BenchmarkWot3(b *testing.B) { - for i := 0; i < b.N; i++ { - v := nest{} - fizzer := v.buzz("a") - fizzer = fizzer.buzz("d") - sink = fizzer.buzz(".") - } -} - -// This comes out pretty much like you'd expect: -// BenchmarkZot1-8 20000000 80.6 ns/op 64 B/op 2 allocs/op -// BenchmarkZot2-8 20000000 88.1 ns/op 64 B/op 2 allocs/op -// BenchmarkZot3-8 20000000 84.9 ns/op 64 B/op 2 allocs/op -// -// The `nest` type gets moved to the heap -- 1 alloc, 48 bytes. -// Then the `nest2` type also gets moved to the heap when returned -- 1 alloc, 16 bytes. -// Wait, where's 3? one of either 2 or 3 is getting magiced, but which and why -// is it because the addr of 3 is literally 2, or -func BenchmarkZot1(b *testing.B) { - for i := 0; i < b.N; i++ { - v := nest{} - sink = buzzit(v, "a") - } -} -func BenchmarkZot2(b *testing.B) { - for i := 0; i < b.N; i++ { - v := nest{} - fizzer := buzzit(v, "a") - sink = buzzit(fizzer, "d") - } -} -func BenchmarkZot3(b *testing.B) { - for i := 0; i < b.N; i++ { - v := nest{} - fizzer := buzzit(v, "a") - fizzer = buzzit(fizzer, "d") - sink = buzzit(fizzer, ".") - } -} - -// This is a function that bamboozles inlining. -// (Note you need to take a ptr to it for that to work.) -// (FIXME DOC wait what??? the above is not true, why) -func buzzit(fizzer fizz, k string) fizz { - return fizzer.buzz(k) -} - -type wider struct { - z, y, x nest -} - -func (x wider) buzz(k string) fizz { - switch k { - case "z": - return x.z - case "y": - return x.y - case "x": - return x.x - default: - return nil - } -} -func BenchmarkZot4(b *testing.B) { - for i := 0; i < b.N; i++ { - v := wider{} - fizzer := buzzit(v, "z") - fizzer = buzzit(fizzer, "a") - fizzer = buzzit(fizzer, "d") - sink = buzzit(fizzer, ".") - } -} - -// So the big question is, can we get multiple heap pointers out of a single move, -// and is that something we can do with a choice in one place in advance -// (rather than requiring different code in a fractal of use sites to agree)? - -func BenchmarkMultiStartingStack(b *testing.B) { - for i := 0; i < b.N; i++ { - v := wider{} - fizzer1 := buzzit(v, "z") - fizzer2 := buzzit(fizzer1, "a") - fizzer2 = buzzit(fizzer2, "d") - sink = buzzit(fizzer2, ".") - fizzer2 = buzzit(fizzer1, "b") - fizzer2 = buzzit(fizzer2, "d") - sink = buzzit(fizzer2, ".") - } -} -func BenchmarkMultiStartingHeap(b *testing.B) { - for i := 0; i < b.N; i++ { - v := &wider{} - fizzer1 := buzzit(v, "z") - fizzer2 := buzzit(fizzer1, "a") - fizzer2 = buzzit(fizzer2, "d") - sink = buzzit(fizzer2, ".") - fizzer2 = buzzit(fizzer1, "b") - fizzer2 = buzzit(fizzer2, "d") - sink = buzzit(fizzer2, ".") - } -} - -func escape(root *nest) fizz { - confound := 8 - var fizzer fizz - fizzer = root - if confound%2 == 0 { - fizzer = &root.a - } - if confound%4 == 0 { - fizzer = &root.b - } - if confound%8 == 0 { - fizzer = &root.c - } - return fizzer -} diff --git a/_rsrch/microbench/multihoisting/multihosting2_test.go b/_rsrch/microbench/multihoisting/multihosting2_test.go deleted file mode 100644 index dc7e7f2a..00000000 --- a/_rsrch/microbench/multihoisting/multihosting2_test.go +++ /dev/null @@ -1,114 +0,0 @@ -package multihoisting - -import ( - "testing" -) - -type hoisty struct { - a, b, c hoisty2 -} -type hoisty2 struct { - d, e hoisty3 -} -type hoisty3 struct { - f hoisty4 -} -type hoisty4 string - -func BenchmarkHoist(b *testing.B) { - for i := 0; i < b.N; i++ { - v := hoisty{} - sink = returnE(&v.a) - sink = returnE(&v.b) - sink = returnE(&v.c) - } -} - -func BenchmarkHoist2(b *testing.B) { - for i := 0; i < b.N; i++ { - v := &hoisty{} - sink = returnE(&v.a) - sink = returnE(&v.b) - sink = returnE(&v.c) - } -} - -func returnE(x *hoisty2) *hoisty3 { - return &x.e -} - -// okay, am now confident the above two are the same. escape analysis rocks em. - -func BenchmarkHoistBranched(b *testing.B) { - for i := 0; i < b.N; i++ { - v := &hoisty{} - sink = returnE(&v.a) - oi := returnE(&v.b) - sink = returnE(&v.c) - sink = returnF(oi) - } -} - -func returnF(x *hoisty3) *hoisty4 { - return &x.f -} - -// now let's see if interfaces make this worse, somehow. -// (i'm *hoping* all the buzz methods being pointery will fail escape clearly, -// and then returning more pointers from mid already-deffo-heap structures will be cheap.) - -func BenchmarkHoistBranchedInterfacey(b *testing.B) { - for i := 0; i < b.N; i++ { - v := &hoisty{} - sink = v.buzz("a") - oi := v.buzz("b") - sink = v.buzz("c") - sink = oi.buzz("f") - } -} - -func (x *hoisty) buzz(k string) fizz { - switch k { - case "a": - return &x.a - case "b": - return &x.b - case "c": - return &x.c - default: - return nil - } -} -func (x *hoisty2) buzz(k string) fizz { - switch k { - case "d": - return &x.d - case "e": - return &x.e - default: - return nil - } -} -func (x *hoisty3) buzz(k string) fizz { - switch k { - case "f": - return &x.f - default: - return nil - } -} -func (x *hoisty4) buzz(k string) fizz { - return x -} - -// also important: can i assign into this? -// ja. it's fine. no addntl allocs, with or without inlining. - -func BenchmarkHoistAssign(b *testing.B) { - for i := 0; i < b.N; i++ { - v := &hoisty{} - oi := returnE(&v.b) - oi.f = "yoi" - sink = returnF(oi) - } -} diff --git a/_rsrch/microbench/multihoisting/reextenting_test.go b/_rsrch/microbench/multihoisting/reextenting_test.go deleted file mode 100644 index 7ba808fe..00000000 --- a/_rsrch/microbench/multihoisting/reextenting_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package multihoisting - -import ( - "fmt" - "runtime" - "testing" -) - -// not sure how to test this -// benchmem is going to report allocation costs... which we know. -// the question is if the memory usage goes *down* after full gc. - -// okay here we go: `runtime.ReadMemStats` has consistency forcers. - -func init() { - runtime.GOMAXPROCS(1) -} - -func BenchmarkReextentingGC(b *testing.B) { - memUsage := func(m1, m2 *runtime.MemStats) { - fmt.Println( - "Alloc:", m2.Alloc-m1.Alloc, - "TotalAlloc:", m2.TotalAlloc-m1.TotalAlloc, - "HeapAlloc:", m2.HeapAlloc-m1.HeapAlloc, - "Mallocs:", m2.Mallocs-m1.Mallocs, - "Frees:", m2.Frees-m1.Frees, - ) - } - var m1, m2, m3, m4, m5 runtime.MemStats - runtime.GC() - runtime.ReadMemStats(&m1) - sink1 = &hoisty{} - runtime.GC() - runtime.ReadMemStats(&m2) - sink2 = &sink1.b - runtime.GC() - runtime.ReadMemStats(&m3) - sink1 = nil - runtime.GC() - runtime.ReadMemStats(&m4) - sink2 = nil - runtime.GC() - runtime.ReadMemStats(&m5) - fmt.Println("first extent size, size to get ref inside, size after dropping enclosing, size after dropping both") - memUsage(&m1, &m2) - memUsage(&m1, &m3) - memUsage(&m1, &m4) - memUsage(&m1, &m5) -} - -var sink1 *hoisty -var sink2 *hoisty2 - -// results: -// yeah, one giant alloc occurs in the first move. -// subsequent pointer-getting causes no new memory usage. -// nilling the top level pointer does *not* let *anything* be collected. -// nilling both allows collection of the whole thing. - -// so in practice: -// we can use internal pointers heavily without consequence in alloc count... -// but it's desirable not to combine items with different lifetimes into -// a single extent in memory, because the longest living thing will extend -// the life of everything it was allocated with. diff --git a/_rsrch/microbench/multihoisting/soln/solnFunctions.go b/_rsrch/microbench/multihoisting/soln/solnFunctions.go deleted file mode 100644 index 86c975a0..00000000 --- a/_rsrch/microbench/multihoisting/soln/solnFunctions.go +++ /dev/null @@ -1,102 +0,0 @@ -package solution - -type Node interface { - LookupByString(key string) Node -} - -type NodeBuilder interface { - InsertByString(key string, value Node) - Build() Node -} - -func (n *Stroct) LookupByString(key string) Node { - switch key { - case "foo": - return &n.foo - case "bar": - return &n.bar - default: - panic("no") - } -} - -func (n *Strooct) LookupByString(key string) Node { - panic("nyi") -} - -func (n *String) LookupByString(key string) Node { - panic("nyi") -} - -func NewStroctBuilder() NodeBuilder { - r := _Stroct__Racker{} - return &r._Stroct__Builder -} - -func (nb *_Stroct__Builder) InsertByString(key string, value Node) { - switch key { - case "foo": - if nb.isset_foo { - panic("cannot set field repeatedly!") // surprisingly, could make this optional without breaking memviz semantics. - } - if &nb.d.foo != value.(*Strooct) { // shortcut: if shmem, no need to memcopy self to self! - nb.d.foo = *value.(*Strooct) // REVIEW: maybe this isn't necessary here and only should be checked in the racker? - } - // interestingly, no need to set br.frz_foo... nb.b isn't revealed yet, so, while - nb.isset_foo = true - case "bar": - nb.d.bar = *value.(*String) - nb.isset_bar = true - default: - panic("no") - } -} -func (br *_Stroct__Racker) InsertByString(key string, value Node) { - switch key { - case "foo": - if &br.d.foo == value.(*Strooct) { // not just a shortcut: if shmem, this branch insert is ONLY possible WHEN the field is frozen. - br.isset_foo = true // FIXME straighten this out to dupe less plz?! also should panic if already set, consistently (or not). - } - if br.frz_foo { - panic("cannot set field which has been frozen due to shared immutable memory!") - } - // TODO finish and sanity check in morning. - // ... seems like there's a lot less shared code than i thought. - // ... resultingly, i'm seriously questioning if builders and rackers deserve separate types. - // ... what's that for? reducing the (fairly temporary) size of builders if used sans racking style? does that... matter? - // no, by the morning light i think this can in fact just be simplified a lot and code share will emerge. - default: - panic("no") - } -} - -func (nb *_Stroct__Builder) Build() Node { - return nb.d -} -func (br *_Stroct__Racker) Build() Node { - // TODO freeze something. but what? do i really need a pointer "up" that to be fed into here? - // is that even a pointer? if it depends on what this value is contained in... remember, for maps and lists, it's different than structs: bools ain't it. - // if we try to use a function pointer here: A) you're kidding.. that will not be fast.. B) check to see if it causes fucking allocs, because it fucking might, something about grabbing methods causing closures. - - // AH HA. Obrigado!: - // We can actually use the invalidation of the 'd' pointer as our signal, and do the freezing update the next time either Set or GetBuilderForValue is called. - - // For structs, since we'll keep a builder/racker per field, that's enough state already. You'll be able to get the childbuilders for multiple fields simultaneously (though you shouldn't rely on it, in general). - // For lists, there will be a frozen offset and an isset offset. The former will be able to advance well beyond the latter. You'll only be allowed to have one childbuilder at a time. - // For maps, we'll still do copies and allocs (reshuffling maps with large embeds is its own cost center usually better avoided). You'll only be able to use one keybuilder at a time (keys will be copied when done), and one value builder (but each use of the value builder will incur an alloc for its 'd' field). - // And here we hit one more piece of Fun that might require a small break to current interfaces: in order to make it possible for keys to reuse a swap space and not get shifted to heap... we can't return them. - // Which means no ChildBuilderForKey method at all: that interface doesn't fly. - // Oh dear. This is unpleasant. More thought needed on this. - // ... Hang on. Have I imagined this more complicated than it is? - // For structs, the key is always a string. - // For maps with enum keys... always a string. (...I don't know how to say enums of int repr would work; I don't think they do, Because Data Model rules.) - // For maps with union keys... okay, we're gonna require that those act like struct keys (unions used in keys will have to have nonptr internals; a fun detail). - // For maps with struct keys... okay, sure it has to be a string from repr land... but also yes, we have to accept the mappy form, for typed level copies and transforms. - // Yup. That last bit means a need for swap space while assembling it. Which we don't want to be forced to return as a node, because that would cause a heap alloc. Which we'd immediately undo since map keys need to be by value to behave correctly. Ow. - // I... don't know what to do about this. We could have the Build method flat out return a nil, and just "document" that. But it's pretty unappealing to make such an edge case. - - // Also, yeah, we really do need an InsertByString method on MapBuilder. Incurring some nonsense boxing for string keys in structs is laughable. - // If you're thinking a workaroudn such as having a single swap space for building a single justString key for temporary use would help... no, sadly: "single swap space" plus visibility model won't jive like that. - // (And even if it did, ever asking an end user to write that much boilerplate is still pretty crass... as well as easily avoidable for minimal library code size cost.) - return br.d -} diff --git a/_rsrch/microbench/multihoisting/soln/solnStructures.go b/_rsrch/microbench/multihoisting/soln/solnStructures.go deleted file mode 100644 index 1e8ab7a3..00000000 --- a/_rsrch/microbench/multihoisting/soln/solnStructures.go +++ /dev/null @@ -1,118 +0,0 @@ -package solution - -// -- ipld schema --> -/* - type Stroct struct { - foo Strooct - bar String - } - - type Strooct struct { - zot String - zam String - zems Strems - zigs Zigs - zee Zahn - } - - type Strems [String] - - type Zigs {String:Zahn} - - type Zahn struct { - bahn String - } -*/ - -// -- the readable types --> - -type Stroct struct { - foo Strooct - bar String -} -type Strooct struct { - zot String - zam String - zems Strems - zigs Zigs - zee Zahn -} -type String struct { - x string -} -type Strems struct { - x []String -} -type Zigs struct { - x map[String]Zahn -} -type Zahn struct { - bahn String -} - -// -- the builders alone --> - -type _Stroct__Builder struct { - d *Stroct // this pointer aims into the thing we're building (it's as yet unrevealed). it will be nil'd when we reveal it. - - isset_foo bool - isset_bar bool -} -type _Strooct__Builder struct { - d *Strooct - - isset_zot bool - isset_zam bool - isset_zems bool - isset_zigs bool - isset_zee bool -} -type _Strems__Builder struct { - d *Strems - // TODO -} -type _String__Builder struct { - // okay, this one is a gimme: data contains only a ptr itself, effectively. - // TODO: still might need a 'd' pointer, in case you're assigning into a list and wanna save boxing allocs? - // ... so long as we're doing wrapper types (to block blind casting), we're gonna have those boxing alloc concerns. -} -type _Zigs__Builder struct { - d *Zigs - // TODO -} - -// -- the rackerized builders --> - -type _Stroct__Racker struct { - _Stroct__Builder // most methods come from this, but child-builder getters will be overriden. - - cb_foo _Strooct__Racker // provides child builder for field 'foo'. - frz_foo bool // if true, must never yield cb_foo again. becomes true on cb_foo.Build *or* assignment to field (latter case reachable if the value was made without going through cb_foo). -} -type _Strooct__Racker struct { - _Strooct__Builder // most methods come from this, but child-builder getters will be overriden. - - // TODO: we might still actually need builders for scalars. if it's got a wrapper struct, it would incur boxing. damnit. - zems _Strems__Racker - zigs _Zigs__Racker - zee _Zahn__Racker -} -type _Strems__Racker struct { - // TODO didn't finish -} -type _Zigs__Racker struct { - // TODO didn't finish -} -type _Zahn__Racker struct { - // TODO didn't finish -} - -// right, here's one wild ride we haven't addressed yet: -// if you build a thing that resides in racker-operated memory, you get a node. -// so far so good, and you can even use it multiple places. -// if assignments go through a Maybe struct? -// ... actually, this is all fine. -// the 'MaybeFoo' structs should store pointers to the thing. done. -// if the thing originated in racker-operated memory, this is free; -// if it didn't, it's a cost you would've hit somewhere else already anyway too. -// done. it's fine. diff --git a/_rsrch/microbench/multihoisting/soln/soln_test.go b/_rsrch/microbench/multihoisting/soln/soln_test.go deleted file mode 100644 index 345eaa75..00000000 --- a/_rsrch/microbench/multihoisting/soln/soln_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package solution - -import ( - "fmt" - "runtime" - "testing" -) - -func init() { - runtime.GOMAXPROCS(1) // necessary if we want to do precise accounting on runtime.ReadMemStats. -} - -var sink interface{} - -func TestAllocCount(t *testing.T) { - memUsage := func(m1, m2 *runtime.MemStats) { - fmt.Println( - "Alloc:", m2.Alloc-m1.Alloc, - "TotalAlloc:", m2.TotalAlloc-m1.TotalAlloc, - "HeapAlloc:", m2.HeapAlloc-m1.HeapAlloc, - "Mallocs:", m2.Mallocs-m1.Mallocs, - "Frees:", m2.Frees-m1.Frees, - ) - } - var m [99]runtime.MemStats - runtime.GC() - runtime.GC() // i know not why, but as of go-1.13.3, and not in go-1.12.5, i have to call this twice before we start to get consistent numbers. - runtime.ReadMemStats(&m[0]) - - var x Node - x = &Stroct{} - runtime.GC() - runtime.ReadMemStats(&m[1]) - - x = x.LookupByString("foo") - runtime.GC() - runtime.ReadMemStats(&m[2]) - - sink = x - runtime.GC() - runtime.ReadMemStats(&m[3]) - - sink = nil - runtime.GC() - runtime.ReadMemStats(&m[4]) - memUsage(&m[0], &m[1]) - memUsage(&m[0], &m[2]) - memUsage(&m[0], &m[3]) - memUsage(&m[0], &m[4]) -} diff --git a/_rsrch/microbench/typedbuilders/neu/neu.go b/_rsrch/microbench/typedbuilders/neu/neu.go deleted file mode 100644 index fa8109bc..00000000 --- a/_rsrch/microbench/typedbuilders/neu/neu.go +++ /dev/null @@ -1,59 +0,0 @@ -package wow - -type String string -type MaybeString struct { - exists, null bool - value String -} - -func (x MaybeString) Must() String { - if !x.exists || x.null { - panic("unbox of a maybe rejected") - } - return x.value -} - -// Which bits are which? -// We probably precompute a table based on the struct as a whole. -// One might suppose a bit should be on to indicate 'present' so that in inaction the default doesn't become zero values? -// Ah, but this conflicts with another goal: it would make you say two things at once to create a value; that's silly. -// Honestly. This whole set of questions sucks and is stupid. -type _Foo__bitfield uint32 - -type Foo struct { - d Foo__Content -} - -type Foo__Content struct { - Modifiers _Foo__bitfield // shoot -- this symbol has to be exported too, then? or can we do enough with builders? - // even if you kick the can down the road with builder funcs... your choices are put all symbols in munges of func name, - // or else you'll still just end up with more constants needing to be exported somewhere. - - F1 String // `ipldsch:"String"` - F2 String // `ipldsch:"optional String"` - F3 String // `ipldsch:"optional nullable String"` - F4 String // `ipldsch:"nullable String"` -} - -func (d Foo__Content) Build() Foo { - return Foo{d} -} - -// and we still need something to handle all the accessors. -// maybe we should just... go back to the MaybeFoo stuff. -// use bitfields for longlived stuff, but maybestuff, fat though it is, during both build and yield. -// the main reason that approach got unpalatable was the pointer fuffery, right? which we're deciding to avoid regardless. - -func (x Foo) F1() String { - return x.d.F1 -} -func (x Foo) F2() (exists bool, value String) { - return true, x.d.F1 // we can do both fo these methods -} -func (x Foo) F2_Maybe() MaybeString { - return MaybeString{value: x.d.F1} -} - -func frob(x Foo) { - -} diff --git a/_rsrch/microbench/typedbuilders/round2_test.go b/_rsrch/microbench/typedbuilders/round2_test.go deleted file mode 100644 index 7d1b47be..00000000 --- a/_rsrch/microbench/typedbuilders/round2_test.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - This system is going to write a *lot* of code, - and then defacto dictate style and constraints on the shape of *even more* - code that *other people* subsequently write (and invest a lot of time in -- - both writing, and then later yet debugging and maintaining). - - We basically have to imagine every possible way to write code in this language, - and then think about which ones we want to encourage, - and then figure out how to encourage that. - - The impact is HIGH. - - This requires a lot (...LOT...) of thinking. -*/ -package typedbuilders - -import "testing" - -func BenchmarkRound2(b *testing.B) { - var v Stroct - for i := 0; i < b.N; i++ { - v = Stroct__Cntnt{ - F1: "foo", - F2: "bar", - F3: "baz", - F4: "woz", - }.Build() - // The 'Patch' function is the only one who can tolerate 'skip this' bools. Would be nice to confine that. - // Adding a third^W fourth type tho? - - // We've now got proposal for: - // - the readonly type - // - the mutable builder ('content') which disregards - // - the null/absent bitmask type - // - the patch/ignore bits type. - // each of these would need exported symbols if used as a struct; - // so at least the first two do (maybe the latter two can be builder.func gated). - // four is two many. two is acceptable. three is stretching. - - // if the mutable builder also avoids nulls by default: that may *also* actua...... no, don't care. yes shit do damnit. - // if you want to hoist one value out of the mutable builder by pointer, it's gonna move the whole thing, - // and this actually becomes *more* of a concern if you do recursively-flat objects, because the constants get bigger. - } - sink = v -} diff --git a/_rsrch/microbench/typedbuilders/typedbuilders_test.go b/_rsrch/microbench/typedbuilders/typedbuilders_test.go deleted file mode 100644 index 19b56952..00000000 --- a/_rsrch/microbench/typedbuilders/typedbuilders_test.go +++ /dev/null @@ -1,387 +0,0 @@ -/* - Designing how the user should interact with, build, and mutate data - when using natively-typed/generated code for IPLD-Schema-based structures... - is nontrivial. - - We have to account for the distinction between nullable and optional/absent fields. - This is a celebrated feature and critical to our ability to round-trip binary data losslessly; - it's also tricky to provide users with a smooth access to that distinction. - There's very little prior art to follow, either -- we're one of first projects (if not 'the' first project) - to try to directly handle the "+2 cardinality" problem (most others ignore it, shifting blame - for inevitable consequent bugs on users, which is a 'solution' of sorts, but certainly not ours); - in the long run, this is valuable, but at present it means we need some creativity. - - (Fasinatingly, by engaging directly with the "+1"'ing, we might also have stumbled upon - one of the better solutions in history to the "how do I denote patches to data" problem: - it's just another "+1" in the 'Maybe' enumeration seen below. This makes golang's "zero" - values work for us in a useful way: fail to mention a field? It won't be patched. Neat.) - - Here are some experiments, which may or may not outline a solution, - but definitely should at least concretely explain the problem. -*/ -package typedbuilders - -import "testing" - -var sink interface{} - -// Stroct is an example of the kind of struct we're already generating from schemas. -type Stroct struct { - f1 String // `ipldsch:"String"` - f2 *String // `ipldsch:"optional String"` - f3 *String // `ipldsch:"optional nullable String"` - f4 *String // `ipldsch:"nullable String"` - - f3__exists bool -} - -// Stroct__Content is a proposed way we might have typed builders. -// This is the subject of discussion. -type Stroct__Content struct { - F1 MaybeString - F2 MaybeString - F3 MaybeString - F4 MaybeString -} - -// String is a another type we're already generating from schemas. -// (It has to conform to the ipld 'Node' interfaces, so it's more than a plain golang string.) -type String string - -// MaybeString is a proposed part of the way we might handle typed builders. -// A "Maybe{Foo}" type would be generated for all "{Foo}" types. -type MaybeString struct { - Maybe Maybe - String String -} - -// Maybe is a const used for an enum. It would be defined in the ipld packages. -// (It's all in the same file here -- but the other types would be in codegen output; this one would not.) -type Maybe uint8 - -const ( - Maybe_Ignore = Maybe(0) - Maybe_Value = Maybe(1) - Maybe_Null = Maybe(2) - Maybe_Absent = Maybe(3) -) - -/* - Next two funcs are 'Build' and 'Apply'. - - 'Apply' "patches" an existing struct to have new values. - - Both are look complex -- but semantically simple, emit helpful errors, and are the product of codegen. - Imagine doing these semantics *without* having these helpers -- the odds of user error would be *high*. - - These functions also mean the user can write code without knowing the details - of how the internal implementation uses pointers or bools (or both) to represent optionality and nulls. - This is important, because note how in this example, a pointer is created for any nullable or optional field? - Right now, we've hardcoded that as the only option. But it mean a heap alloc! - What if we implement adjunct config that allows different implementation choices (e.g., more bools for less heap pointers)? - This abstraction will make that possible without disrup. -*/ - -func (p Stroct__Content) Build() Stroct { - v := Stroct{} - switch p.F1.Maybe { - case Maybe_Ignore: - panic("must explicitly state all fields when building") - case Maybe_Value: - v.f1 = p.F1.String - case Maybe_Null: - panic("cannot assign null to nonnullable field") - case Maybe_Absent: - panic("cannot have absent nonoptional field") - default: - goto no - } - switch p.F2.Maybe { - case Maybe_Ignore: - panic("must explicitly state all fields when building") - case Maybe_Value: - v.f2 = &p.F2.String - case Maybe_Null: - panic("cannot assign null to nonnullable field") - case Maybe_Absent: - v.f2 = nil - default: - goto no - } - switch p.F3.Maybe { - case Maybe_Ignore: - panic("must explicitly state all fields when building") - case Maybe_Value: - v.f3 = &p.F3.String - v.f3__exists = true - case Maybe_Null: - v.f3 = nil - v.f3__exists = true - case Maybe_Absent: - v.f3 = nil - v.f3__exists = false - default: - goto no - } - switch p.F4.Maybe { - case Maybe_Ignore: - panic("must explicitly state all fields when building") - case Maybe_Value: - v.f4 = &p.F4.String - case Maybe_Null: - v.f4 = nil - case Maybe_Absent: - panic("cannot have absent nonoptional field") - default: - goto no - } - return v -no: - panic("invalid maybe") -} - -func (p Stroct__Content) Apply(old Stroct) Stroct { - v := Stroct{} - switch p.F1.Maybe { - case Maybe_Ignore: // pass - case Maybe_Value: - v.f1 = p.F1.String - case Maybe_Null: - panic("cannot assign null to nonnullable field") - case Maybe_Absent: - panic("cannot have absent nonoptional field") - default: - goto no - } - switch p.F2.Maybe { - case Maybe_Ignore: // pass - case Maybe_Value: - v.f2 = &p.F2.String - case Maybe_Null: - panic("cannot assign null to nonnullable field") - case Maybe_Absent: - v.f2 = nil - default: - goto no - } - switch p.F3.Maybe { - case Maybe_Ignore: // pass - case Maybe_Value: - v.f3 = &p.F3.String - v.f3__exists = true - case Maybe_Null: - v.f3 = nil - v.f3__exists = true - case Maybe_Absent: - v.f3 = nil - v.f3__exists = false - default: - goto no - } - switch p.F4.Maybe { - case Maybe_Ignore: // pass - case Maybe_Value: - v.f4 = &p.F4.String - case Maybe_Null: - v.f4 = nil - case Maybe_Absent: - panic("cannot have absent nonoptional field") - default: - goto no - } - return v -no: - panic("invalid maybe") -} - -/* - Misc considerations: - - - Could make Stroct__Content use functions instead of exported fields. - Purely syntactic concern. - Probably makes no difference to perf: setters would be inlined. - Would let us call B.S. on invalid Maybe states closer to incident site. - - - It's wild, but what if we made everything include its own Maybe states all the time? - Would make it possible to have zero-values scream -- desirable. - Would raise questions of where to put funcs for making them -- undesirable if grows the reserved words lists. - Would make dense lists of ints twice the size -- wildly undesirable. - Might be interesting to roll around this thought and see if there are ways to deburr it of the undesirable parts. - - - For internal sanity, we should consider renaming the '__exists' fields to '__absent'. - It's six of one and a half dozen of the other, but look at the struct initializers. The former makes you say two things at once. - - - Syntax: what if we generated a whole 'maybe' package? - Each type would exist in your output package, and its 'maybe' variant in the maybe subpackage. - Alternative: maybe the `Maybe_*` constants deserve a small package their own? - Worried about the sheer char count around using these things. - - - Obviously, we've given up on compile-time checking against bugs like trying to assign null to a nonnullable field. - Ideally, I'd love to have those checks. - The only way I can see to get them involves generating a combinatoric set of MaybeFoo types (undesirable), - or, making a lot more methods on the builder (worth consideration, but syntactically raises eyebrows). -*/ - -func BenchmarkStroctConstructionDirect(b *testing.B) { - var v Stroct - for i := 0; i < b.N; i++ { - v = Stroct{ - f1: "foo", - f2: strptr("bar"), - f3: strptr("baz"), f3__exists: true, - f4: strptr("woz"), - } - } - sink = v -} - -func strptr(s String) *String { - return &s -} - -func BenchmarkStroctConstructionBuilder(b *testing.B) { - var v Stroct - for i := 0; i < b.N; i++ { - v = Stroct__Content{ - F1: MaybeString{Maybe_Value, "foo"}, - F2: MaybeString{Maybe_Value, "bar"}, - F3: MaybeString{Maybe_Value, "baz"}, - F4: MaybeString{Maybe_Value, "woz"}, - }.Build() - } - sink = v -} - -// n.b. both of these are a little untrue, syntactically, because we didn't box the strings *enough*. -// the penalty visually is probably similar for both, but might actually change perf of number one(...?). -// -// worth considering: we might want to special-case any builders for the prelude types (such as 'String') -// such that they need less boilerplate to construct. -// it's one of those things that's technically a constact factor improvement, but on like 50% of cases, so aggregate impactful. -// and the example here seems to suggest it's actually very conveniently possible to do so, -// making it overall uncontentious that we then should. - -/* - Okay, let's now investigate the idea of having a bunch of builder methods. - This might give us better brevity (we'll see), - and also can give us better compile-time checks (and autocomplete) for which special modes are valid on a field. - - This could be offered in combination with the exported fields. - Or, we could unexport the fields (and possibly even the maybeFoo types) by using this approach. - - Big question: can chaining syntax like this be optimized by the compiler enough to even be viable? -*/ - -func (p *Stroct__Content) Set_f1(v String) *Stroct__Content { - p.F1 = MaybeString{Maybe_Value, v} - return p -} -func (p *Stroct__Content) Set_f2(v String) *Stroct__Content { - p.F2 = MaybeString{Maybe_Value, v} - return p -} -func (p *Stroct__Content) Set_f3(v String) *Stroct__Content { - p.F3 = MaybeString{Maybe_Value, v} - return p -} -func (p *Stroct__Content) Set_f4(v String) *Stroct__Content { - p.F4 = MaybeString{Maybe_Value, v} - return p -} - -// TODO/elided: more `Set_fN_Null()` and `Set_fN_Absent()` methods, -// as appropriate for the fields that should have them. - -func BenchmarkStroctConstructionBuilderMethodic(b *testing.B) { - var v Stroct - for i := 0; i < b.N; i++ { - b := Stroct__Content{} - v = b. - Set_f1("foo"). - Set_f2("bar"). - Set_f3("baz"). - Set_f4("woz"). - Build() - } - sink = v -} - -/* -Okay, disassembly time. What have we learned? - -- The vast majority of our time spent in *any* of these is the heap allocation for the string pointer. - This isn't a super huge surprise, honestly. - This is why the "hide whether pointers are involved from users" thing is so dang important. - -- Oh wow. I think if we *do* keep pointers in play... I see why the builder is advantaged now. - It looks like *the whole builder struct* is getting moved to the heap by the Build func, - and so then getting an address for each string doesn't generate subsequent allocs. - This moves the alloc count from 3 to 1 in total. - In exchange, it's probably moving a larger amount of things to the heap. - Yes, benchmem confirms (that probably would've been easier than reading asm...): - - BenchmarkStroctConstructionDirect-8 10000000 71.6 ns/op 48 B/op 3 allocs/op - BenchmarkStroctConstructionBuilder-8 10000000 51.0 ns/op 96 B/op 1 allocs/op - BenchmarkStroctConstructionBuilderMethodic-8 10000000 62.5 ns/op 96 B/op 1 allocs/op - - This has... interesting implications. - Generally speaking, it's true that the *count* of allocs is the main cost to worry about; - alloc *size* doesn't matter... in terms of time that's later going to cost via gc. - But these pointers are going to stay around for the life of the object. - That means for a struct with just one pointer field and lots of non-ptrs, - the total memory *for its lifetime, not just to the builder's lifetime* will rise sharply. - The words for the maybe-enum also will stick around! Ouch!! - (Scalars wouldn't encounter this themselves, so it's not death to the packed list-of-int case, but still, ouch.) - Wow... this would actually mean... using the pointers in the struct but enums in the builder... - is a doublespend in 100% of cases. - If that doesn't prompt a rethink, I don't know what does. - Jeez. - -*/ - -/* -Other syntax ideas, just for fun: - - ``` - Stroct__Content{ - f1: "foo", - f2: "bar", - }.Uncommonly( - Stroct_f3_Absent, - Stroct_f3_Null, - ).Build() - ``` - - ``` - Stroct__Content{ - f1: "foo", - f2: "bar", - }.Uncommonly( - Absent("f3"), - Null("f4"), - ).Build() - ``` - -Neither of these seems very pleasing, though. - -The former adds tonnes of exported symbols. -The latter makes it possible to misspell fields entirely. -Neither provides any useful compile-time checks. - -A third variant could address the misspelling problem, but is comically verbose: - - - ``` - Stroct__Content{ - f1: "foo", - f2: "bar", - }.Uncommonly( - Absent(TypeSystem.Stroct.Fields("f3")), - Null(TypeSystem.Stroct.Fields("f4")), - ).Build() - ``` - -... and also, actually didn't even solve the problem (unless we also add -generatation of field constants where we didn't previously have it), so, uh. - -*/ diff --git a/_rsrch/nodeassembler/nodeAssembler.go b/_rsrch/nodeassembler/nodeAssembler.go deleted file mode 100644 index b9b55aa2..00000000 --- a/_rsrch/nodeassembler/nodeAssembler.go +++ /dev/null @@ -1,134 +0,0 @@ -package science - -/* -A fairly substantial redraft of NodeBuilders -- in this one, -the recursion happens in such a way that you *don't* get a handle to a Node -immediately when completing every builder. - -The idea is that this might make it easier to build large recursive values -(both for caller ergonomics, and for internal efficiency) since we don't -have to be concerned with returning an immutable Node at high granularity at -almost every step throughout the process of building the larger tree. -But does it? Not sure yet. - -This exploration is triggered by two things: - -Firstly: in general, the NodeBuilder system at present is small-pieces-first... -and that's very bad for memory characteristics. In trying to spec behaviors -that fix it, we've come up with possible 'memory visibility' models which -let us have the memory amortization we want while keeping the current -small-pieces-first interfaces... but it's... getting arcane. -It's unclear if the effort is worth it -- what if we just admit it and -fully abandon the small-pieces-first model? - -Secondly: that increasingly-arcane pretends-to-be small-pieces-first model -is still failing in one critical place: handling keys for maps. -Making it possible to handle complex keys without heap allocs for -semiotically-unnecessary interface wrapping is turning out to be agnozing. -So maybe some different interfaces will make it easier. - -Maybe. Let's see. - -*/ - -type NodeAssembler interface { - BeginMap() MapAssembler - BeginList() ListAssembler - AssignNull() - AssignBool(bool) - AssignInt(int) - AssignFloat(float64) - AssignString(string) - AssignBytes([]byte) - - Assign(Node) - CheckError() error // where are these stored? when each child is done, could check this. and have it stored in each child. means each allocs (nonzero struct)... but isn't that true anyway? yeah. well, except now you're apparently getting that for scalars, which is bad. -} - -type MapAssembler interface { - AssembleKey() MapKeyAssembler - - Insert(string, Node) - Insert2(Node, Node) - - Done() -} -type MapKeyAssembler interface { - NodeAssembler - AssembleValue() MapValueAssembler -} -type MapValueAssembler interface { - NodeAssembler -} - -type ListAssembler interface { - AssembleValue() NodeAssembler - - Append(Node) - - Done() -} - -type NodeBuilder interface { - NodeAssembler - Build() (Node, error) -} - -type Node interface { - // all the familiar reader methods go here -} - -func demo() { - var nb NodeBuilder - func(mb MapAssembler) { - mb.AssembleKey().AssignString("key") - func(mb MapAssembler) { - mb.AssembleKey().AssignString("nested") - mb.AssembleValue().AssignBool(true) - mb.Done() - }(mb.AssembleValue().BeginMap()) - mb.AssembleKey().AssignString("secondkey") - mb.AssembleValue().AssignString("morevalue") - mb.Done() - }(nb.BeginMap()) - result, err := nb.Build() - _, _ = result, err -} - -/* - -Pros: - -- this nested pretty nicely. not shuffling returned nodes (and errors!) everywhere is actually... prettier to use than what we've got presently. -- having the 'Build' at the end seems... fine. -- notice the lack of childbuilder getter methods. it's just implied by normal operation. - - also means it's intensely obvious that none of the assemblers can be reused freely -- whereas with the child builder getters at present just returning a NodeBuilder, that's nonobvious. - -Cons: - -- not very clear where error handling should go. punting it *all* to the end is not great. - - this is a super big deal! - - when you have a typed map key, does the subsequent `AssembleValue` call trigger validating the key? - - when you have a typed map value, does the next `AssembleKey` call trigger validating value? - - what happens for the last value in a map? now we're really in trouble. the next action on the parent has to pick up the duty? no, I really don't think that's even viable. -- is every builder gonna need to have room inside to curry an error? that means a bunch of things might go from zero to nonzero struct size, which might be consequential. -- i really don't like that we have two different styles of usage appearing in the same interfaces (the 'Assemble' recursors vs 'Insert'/'Append'). - - ... maybe we can get rid of those now? `mb.AssembleKey().Assign(n1).Assign(n2)`? no, not quite a one-liner yet... - - ... yeah, I can't get a one-liner out of this. either the key or the value might require or design (respectively) a closure in order to flow well. the former complicates the core interface, and the latter can still be done from the outside but then just looks weird. -- building single scalar values got more annoying. it's at least two or three lines now: create builder, do assign, call build. - - question is whether this is the thing to worry about -- we traded this for fewer lines when making recursive structures, which we presumably do more often than not. - -Notes: - -- yes, also ditched the "amend" methods. those have been pretty consistently irritating; that said, I don't have a plan to replace their fastpath capabilities either. -- the types still don't particularly do much to force correct usage order. e.g., your logic must alternate calling AssembleKey and AssembleValue, etc. - - ...but as found in other explorations, there's a limit to what we can do at best anyway without linear types or rustacean 'move' semantics, etc. so if we already have to give up a meter shy of the dream, what's another millimeter? -- i don't think there's any strong incentive _not_ to panic throughout this code, performance-wise at least. something with this many vtables is already fractally uninlinable. -- interesting to note that if a user is creating map keys via a typed nodebuilder (presumably they're structs)... `Assign2(Node,Node)` **still** forces allocs for boxing. - - while the AssembleKey style of usage avoids a boxing, it's awkward to use if the user wants to use a natively typed builder (`AssembleKey().Assign(nowthis)`?) and then still forces a temp copy-by-value in the middle for no good reason. - - a natively-typed assign method that works by value is the only way to minimize all the costs at once. - - we do still need it though: `Assign2(Node,Node)` is the only way to copy an existing typed map key generically (without the temp-copy lamented above for the `AssembleKey.Assign` chain). -- the `Append` and `Assign` method names might be too terse -- we didn't leave space for the natively typed methods, which we generally want to be the shortest ones. -- 'Assign' being a symbol on both NodeAssemler and MapAssembler with different arity might be unfortunate -- would make it impossible to supply both with one concrete type. - -*/ diff --git a/_rsrch/nodestyle/nodeStyle.go b/_rsrch/nodestyle/nodeStyle.go deleted file mode 100644 index ae29a21b..00000000 --- a/_rsrch/nodestyle/nodeStyle.go +++ /dev/null @@ -1,109 +0,0 @@ -package nodestyle - -import ( - "context" - "io" -) - -type Kind uint8 - -type Node interface { - Kind() Kind - LookupByString(key string) (Node, error) - LookupByNode(key Node) (Node, error) - LookupByIndex(idx int) (Node, error) - Length() int - IsAbsent() bool - IsNull() bool - AsBool() (bool, error) - AsInt() (int, error) - AsFloat() (float64, error) - AsString() (string, error) - AsBytes() ([]byte, error) - AsLink() (Link, error) - - Prototype() NodePrototype // note! replaces `NodeBuilder` method! -} - -// Prototype is the information that lets you make more of them, and do some basic behavioral inspection; -// Type is the information that lets you understand how a group of nodes is related in a schema and rules it will follow. -type NodePrototype interface { - NewBuilder() NodeBuilder // allocs! (probably. sometimes the alloc is still later.) -} - -type NodePrototypeSupportingAmend interface { - AmendingBuilder(base Node) NodeBuilder -} - -// all the error methods here are still a serious question. i don't really like them. you can 'must' them away, but... squick? -// ... we should make a muster that stores them somewhere rather than panics. or takes a type parameter for its panic, or `func(error) boxedError`. or something. -type NodeBuilder interface { - BeginMap() (MapBuilder, error) // note the "amend" options are gone -- now do it with feature detection on NodePrototypeSupportingAmend, instead! - BeginList() (ListBuilder, error) // note the "amend" options are gone -- now do it with feature detection on NodePrototypeSupportingAmend, instead! - CreateNull() (Node, error) - CreateBool(bool) (Node, error) - CreateInt(int) (Node, error) - CreateFloat(float64) (Node, error) - CreateString(string) (Node, error) - CreateBytes([]byte) (Node, error) - CreateLink(Link) (Node, error) // fixme this is dumb and all links should already be nodes; either that or their creation should hinge here, rather than elsewhere and be awkwardly doubled. - - Prototype() NodePrototype // it's unlikely this will often be needed, i think, but it's here nonetheless. (maybe generic transform will find this easier to use than the one on the node? i think both should end up in reach on the stack, but not sure.) -} - -type MapBuilder interface { - // in question whether this needs error returns and/or possibly a 'Done' method at all - // philosophically: is it worse if this cursor make cause an error when a method is called on its parent object (vs if we just put all cursor behavior in one object flatly)? - - // how maps do key recursion is one major question; - // and whether the 'Done' method returns a Node is the other. - // the nodebuilder above seems to think things return Node, but that doesn't have to be. - // size hinting also got forgotten again. - - // problem with trying to put the results elsewhere is... where? - // the NodeBuilder above *doesn't have* a bind operation or Done method that could serve. - // didn't we have a draft somewhere that... did? - - // yeah, we did. that's the 'nodeassembler' draft. - // currently thinking: best hybrid is: - // - yes, nodeStyle - // - yes, nodeAssembler vs nodeBuilder -- BUT: - // - nodeAssembler still return error promptly all over the place. - // the reasons these are the preferable choices are: - // - nodeStyle still dekinks about a dozen things - // - not returning intermediate nodes simplifies the builder/freezing cycle radically (basically, removes it) and this means going faster and with less code. - // - returning errors promptly all over the place reduces intermediate assembler structs needing to store errors just to curry weirdly and temporarily (esp. on scalar/leaf node construction). - // - and yes, in most generic algorithms, we're going to want to return errors completely promptly -- the position in the other side of a hylomorphism is relevant. - // - these interfaces are mostly for high performance in generic algorithms. we can attempt to build additional friendliness for application programmers on at higher or alternative laters. - -} - -type ListBuilder interface { -} - -type Link interface { - // not exploring it here, but `LinkBuilder` might also make more sense if renamed to `LinkPrototype`, and split into - // but there's a lot of things about that interface that still don't "feel" friendly (even if they're correct). - // ... okay, exploring it here. - // ... it's possible that traversal.Config.LinkNodeBuilderChooser is actually still right; you don't need or want to see the NodePrototype there? - // unless we want to use the NodePrototype has the hub for feature detection for other fastpaths? which we probably... indeed might want. hm. - - Prototype() LinkPrototype -} - -type LinkPrototype interface { - // unsure what goes here, tbh. -} - -type StorageLoader func(ctx context.Context, lnk Link, lnkCtx LinkContext) (io.Reader, error) // just handles the concept of bytes -- might have an internal `(Link)->(filepath.Path)` func, but `Link` is otherwise opaque to it. - -type StorageWriter func(ctx context.Context, lnkCtx LinkContext) (io.Writer, StorageCommitter, error) -type StorageCommitter func(Link) error - -type LinkContext struct { - LinkPath Path - LinkNode Node // has the Link again, but also might have type info // always zero for writing new nodes, for obvi reasons. // dubious if this is needed; would rather make Link impls just also *be* Node. - ParentNode Node -} - -type Path string diff --git a/_rsrch/nodeworkshop/nodeWorkshop.go b/_rsrch/nodeworkshop/nodeWorkshop.go deleted file mode 100644 index 4629dd11..00000000 --- a/_rsrch/nodeworkshop/nodeWorkshop.go +++ /dev/null @@ -1,93 +0,0 @@ -package nodeworkshop - -/* - Experiment closed: we didn't reach a clearly better error handling - strategy that's ergonomic and performant, and what we did reach is - probably stil better implemented as a wrapper package like 'fluent'. -*/ -/* - The hypothesis I want to explore here is if having a "workshop" that - stores some global state and behaviors (and is very visibly passed down) - is a good idea. - - So far we don't have such a thing; even with the assembler design, - the interface doesn't really *say* much about state coming down with it. - - One particularly useful thing this would enable is storing any - error -- _and any error handling strategy_ -- in one clear place. - - This might also give us a place to store the "extras" tree in case of - tolerant unmarshal modes. - - Maybe we can store a pointer to a 'prior' node and do the "amend" features - this way, instead of having them appear at fractal depth? Would that help? - - Naming bikeshed: this isn't really about building *a* node anymore; - it's about building a whole tree of them at once. Maybe another name - could reflect that better. (We don't really have a term for "the tree of - nodes you get from a single block", yet. Maybe we would benefit from one.) -*/ - -type NodeWorkshop struct { - Err error // used to return errors - OnError func(error) // error will always be stored in `nw.Err`, but this also allows to react instantly (or, cancel it by nilling it). - - // making it non lexically obvious if error checking is required or not... no, we're not doing that; - // no builder and assembler methods should return errors anymore; this is purely an immediacy thing. - // (questionable whether the callback is needed, really. panicking is the only useful thing it can do. and is that useful, really? might be better to just add a 'MustBeUnerrored' checkpoint func.) -} - -type ErrInvalidKindForNodeStyle struct{} -type ErrValidationFailed struct{ nested error } // almost all typed errors go in here. even ErrInvalidStructKey, possibly? not sure on bind.Node with atlas miss. -type ErrInvalidStructKey struct{} -type ErrListOverrun struct{} // only really possible with struct types with list reprs, so... again, categorization questions. -type ErrMissingRequiredField struct{} // definitely valid to fit inside ErrValidationFailed. -type ErrInvalidKindForKindedUnion struct{} -type ErrInvalidUnionDiscriminant struct{} // could break this down further into like three different kinds of error (missing descrim key, missing content key, wrong descrim) and/or merge with above. -type ErrRepeatedMapKey struct{} -type ErrCannotBeNull struct{} // arguably either ErrInvalidKindForNodeStyle or ErrValidationFailed. - -// We had speculated previously about "unwinding" construction errors to provide context about where in the tree they occurred. -// We don't currently have a way to do that. - -/* - About ErrValidationFailed: - - - might be better to make this an interface? - - dubious: hard to imagine what code would branch on that. - - can we really even argue ErrInvalidKindForNodeStyle is not a validation error, if it comes up deep in a tree? - - for typed nodes... no, I don't think so. maybe typed nodes just shouldn't use that error (even though it exists, for bind nodes or other applications like free.justString). - - n.b. ErrInvalidKindForNodeStyle might be particularly likely to arise for (untyped) map keys. -*/ - -type Node interface { - // ELIDED: all the familiar reader methods -} - -type NodeAssembler interface { - // comes implicitly bound to some memory already - // is not terribly reusable because of the above -} - -type NodeBuilder interface { - // comes with knowledge of type but not already having bound memory - // is reusable because it starts the process -} - -func demo() { - //nsA. - nsB.Construct(field1nb, arg0scalar, arg1scalar, arg2scalar) - nsC.Construct(field2nb, arg0scalar, arg1scalar) - // i still can't get it to nest for a dang. - // we can make a flip like this, but that doesn't help nest. - // i literally don't know how to do this without some currying or context syntax. - - // oh. unless it returns a function pointer -- `func(Assembler) (sideeffecting)` -- in a reasonably cheap way. - // (i don't know if that's even possible: I doubt it is: it's a closure no matter how you do it; it _will_ shove an alloc somewhere.) - - // okay, you *can* also do it combined with deep-dotting syntax: - nsC.Construct(ws.MutA().MutB(), arg0scalar, arg1scalar) - // ... but it's not entirely clear how much this really buys you. - // I guess it means you can do one struct (at maxdepth-1) per line rather than roughly one field per line, and that's something. - // But this is still an entirely unnatural syntax that has nothing to do with how people would normally create structs in golang, so we're sorta barking after cars that are quickly vanishing down entirely the wrong highway. -} diff --git a/_rsrch/nozeros/crosspkg/zero_test.go b/_rsrch/nozeros/crosspkg/zero_test.go deleted file mode 100644 index 084b2e6f..00000000 --- a/_rsrch/nozeros/crosspkg/zero_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package crosspkg - -import ( - "testing" - - . "github.com/warpfork/go-wish" - - "github.com/ipld/go-ipld-prime/_rsrch/nozeros" -) - -func TestStuff(t *testing.T) { - _ = nozeros.ExportedAlias{} // undesirable - - // _ = nozeros.ExportedPtr{} // undesirable - // NOPE! (Success!) - // ./zero.go:14:25: invalid pointer type nozeros.ExportedPtr for composite literal (use &nozeros.internal instead) - - v := nozeros.NewExportedPtr("woo") - var typecheckMe interface{} = v - v2, ok := typecheckMe.(nozeros.ExportedPtr) - - Wish(t, ok, ShouldEqual, true) // well, duh. Mostly we wanted to know if even asking was allowed. - Wish(t, v2, ShouldEqual, v) // well, duh. But sanity check, I guess. - - v.Pow() // check that your IDE can autocomplete this, too. it should. - - // this is all the semantics we wanted; awesome. - // - // still unfortunate: Pow won't show up in docs, since it's on an unexported type. - - // exporting an alias of the non-pointer makes a hole in your guarantees, of course: - var hmm nozeros.ExportedPtr - hmm = &nozeros.ExportedAlias{} - _ = hmm -} - -func TestStranger(t *testing.T) { - var foo nozeros.Foo - // foo = &nozeros.FooData{} // undesirable - // NOPE! (Success!) - - foo = nozeros.Foo(nil) // possible, yes. but fairly irrelevant. - _ = foo - - v := nozeros.NewFoo("woo") - - Wish(t, v.Read(), ShouldEqual, "woo") - - v.Pow() - - Wish(t, v.Read(), ShouldEqual, "waht") - - v.Pow() - - t.Logf("%#v", v) // this will log the internal type name, not the exported alias. Arguably not ideal. -} diff --git a/_rsrch/nozeros/nozeros.go b/_rsrch/nozeros/nozeros.go deleted file mode 100644 index 8d3abc17..00000000 --- a/_rsrch/nozeros/nozeros.go +++ /dev/null @@ -1,43 +0,0 @@ -package nozeros - -type internal struct { - x string -} - -func (x *internal) Pow() {} - -// func (x ExportedPtr) Pow() {} // no, "invalid receiver type ExportedPtr (ExportedPtr is a pointer type)". -// wait, no, this was only illegal for `type ExportedPtr *internal` -- AHHAH - -type ExportedAlias = internal - -type ExportedPtr = *internal - -// type ExportedPtr *internal // ALMOST works... -// except somewhat bizarrely, 'Pow()' becomes undefined and invisible on the exported type. -// As far as I can tell, aside from that, it's identical to using the alias. - -func NewExportedPtr(v string) ExportedPtr { - return &internal{v} -} - -// --- - -type FooData struct { - x string -} - -func (x Foo) Pow() { - x.x = "waht" -} -func (x Foo) Read() string { - return x.x -} - -type foo FooData - -type Foo = *foo - -func NewFoo(v string) Foo { - return &foo{v} -} diff --git a/adl.go b/adl.go new file mode 100644 index 00000000..bb761896 --- /dev/null +++ b/adl.go @@ -0,0 +1,7 @@ +package ipld + +import ( + "github.com/ipld/go-ipld-prime/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/adl/rot13adl/example_test.go b/adl/rot13adl/example_test.go index e303dc40..70cc3f90 100644 --- a/adl/rot13adl/example_test.go +++ b/adl/rot13adl/example_test.go @@ -8,9 +8,10 @@ import ( "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/adl/rot13adl" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/ipld/go-ipld-prime/must" "github.com/ipld/go-ipld-prime/storage" @@ -66,14 +67,14 @@ func ExampleReify_loadingToADL() { storage := &storage.Memory{} linkSystem.StorageReadOpener = storage.OpenRead linkSystem.StorageWriteOpener = storage.OpenWrite - linkSystem.NodeReifier = func(_ ipld.LinkContext, nd ipld.Node, _ *ipld.LinkSystem) (ipld.Node, error) { + linkSystem.NodeReifier = func(_ linking.LinkContext, nd datamodel.Node, _ *linking.LinkSystem) (datamodel.Node, error) { return rot13adl.Reify(nd) } - lnk, err := linkSystem.Store(ipld.LinkContext{Ctx: context.Background()}, lp, substrateNode) + lnk, err := linkSystem.Store(linking.LinkContext{Ctx: context.Background()}, lp, substrateNode) fmt.Printf("storage error: %v\n", err) // reload from storage, but this time the NodeReifier function should give us the ADL - syntheticView, err := linkSystem.Load(ipld.LinkContext{Ctx: context.Background()}, lnk, rot13adl.Prototype.SubstrateRoot) + syntheticView, err := linkSystem.Load(linking.LinkContext{Ctx: context.Background()}, lnk, rot13adl.Prototype.SubstrateRoot) fmt.Printf("load error: %v\n", err) // We can inspect the synthetic ADL node like any other node! diff --git a/adl/rot13adl/rot13node.go b/adl/rot13adl/rot13node.go index dbd92abd..5217bbb2 100644 --- a/adl/rot13adl/rot13node.go +++ b/adl/rot13adl/rot13node.go @@ -15,20 +15,20 @@ - optionally, use `SubstrateRootPrototype` as the prototype for loading the raw substrate data; any kind of Node is a valid input to Reify, but this one will generally have optimal performance. - take the synthesized form and inspect its substrate data: - - the `Substrate()` method will return another ipld.Node which is the root of the raw substrate data, - and can be walked normally like any other ipld.Node. + - the `Substrate()` method will return another datamodel.Node which is the root of the raw substrate data, + and can be walked normally like any other datamodel.Node. */ package rot13adl import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" "github.com/ipld/go-ipld-prime/schema" ) // -- Node --> -var _ ipld.Node = (R13String)(nil) +var _ datamodel.Node = (R13String)(nil) type R13String = *_R13String @@ -37,25 +37,25 @@ type _R13String struct { synthesized string // the content that the ADL presents. calculated proactively from the original, in this implementation (though you could imagine implementing it lazily, in either direction, too). } -func (*_R13String) Kind() ipld.Kind { - return ipld.Kind_String +func (*_R13String) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (*_R13String) LookupByString(string) (ipld.Node, error) { +func (*_R13String) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.R13String"}.LookupByString("") } -func (*_R13String) LookupByNode(ipld.Node) (ipld.Node, error) { +func (*_R13String) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.R13String"}.LookupByNode(nil) } -func (*_R13String) LookupByIndex(idx int64) (ipld.Node, error) { +func (*_R13String) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.R13String"}.LookupByIndex(0) } -func (*_R13String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (*_R13String) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.R13String"}.LookupBySegment(seg) } -func (*_R13String) MapIterator() ipld.MapIterator { +func (*_R13String) MapIterator() datamodel.MapIterator { return nil } -func (*_R13String) ListIterator() ipld.ListIterator { +func (*_R13String) ListIterator() datamodel.ListIterator { return nil } func (*_R13String) Length() int64 { @@ -82,16 +82,16 @@ func (n *_R13String) AsString() (string, error) { func (*_R13String) AsBytes() ([]byte, error) { return mixins.String{TypeName: "rot13adl.R13String"}.AsBytes() } -func (*_R13String) AsLink() (ipld.Link, error) { +func (*_R13String) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "rot13adl.R13String"}.AsLink() } -func (*_R13String) Prototype() ipld.NodePrototype { +func (*_R13String) Prototype() datamodel.NodePrototype { return _R13String__Prototype{} } // -- NodePrototype --> -var _ ipld.NodePrototype = _R13String__Prototype{} +var _ datamodel.NodePrototype = _R13String__Prototype{} type _R13String__Prototype struct { // There's no configuration to this ADL. @@ -107,19 +107,19 @@ type _R13String__Prototype struct { // An ADL that does multi-block stuff might also need functions like a LinkLoader passed in through here. } -func (np _R13String__Prototype) NewBuilder() ipld.NodeBuilder { +func (np _R13String__Prototype) NewBuilder() datamodel.NodeBuilder { return &_R13String__Builder{} } // -- NodeBuilder --> -var _ ipld.NodeBuilder = (*_R13String__Builder)(nil) +var _ datamodel.NodeBuilder = (*_R13String__Builder)(nil) type _R13String__Builder struct { _R13String__Assembler } -func (nb *_R13String__Builder) Build() ipld.Node { +func (nb *_R13String__Builder) Build() datamodel.Node { if nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -131,17 +131,17 @@ func (nb *_R13String__Builder) Reset() { // -- NodeAssembler --> -var _ ipld.NodeAssembler = (*_R13String__Assembler)(nil) +var _ datamodel.NodeAssembler = (*_R13String__Assembler)(nil) type _R13String__Assembler struct { w *_R13String m schema.Maybe // REVIEW: if the package where this Maybe enum lives is maybe not the right home for it after all. Or should this line use something different? We're only using some of its values after all. } -func (_R13String__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_R13String__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.BeginMap(0) } -func (_R13String__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_R13String__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.BeginList(0) } func (na *_R13String__Assembler) AssignNull() error { @@ -172,10 +172,10 @@ func (na *_R13String__Assembler) AssignString(v string) error { func (_R13String__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignBytes(nil) } -func (_R13String__Assembler) AssignLink(ipld.Link) error { +func (_R13String__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignLink(nil) } -func (na *_R13String__Assembler) AssignNode(v ipld.Node) error { +func (na *_R13String__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -194,6 +194,6 @@ func (na *_R13String__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_R13String__Assembler) Prototype() ipld.NodePrototype { +func (_R13String__Assembler) Prototype() datamodel.NodePrototype { return _R13String__Prototype{} } diff --git a/adl/rot13adl/rot13node_test.go b/adl/rot13adl/rot13node_test.go index f0be475d..66895a67 100644 --- a/adl/rot13adl/rot13node_test.go +++ b/adl/rot13adl/rot13node_test.go @@ -5,8 +5,8 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestLogicalNodeRoundtrip(t *testing.T) { @@ -40,7 +40,7 @@ func TestReify(t *testing.T) { synth, err := Reify(sn) // Inspect the resulting high level node. Require(t, err, ShouldEqual, nil) - Wish(t, synth.Kind(), ShouldEqual, ipld.Kind_String) + Wish(t, synth.Kind(), ShouldEqual, datamodel.Kind_String) s, err := synth.AsString() Wish(t, err, ShouldEqual, nil) Wish(t, s, ShouldEqual, "abcd") @@ -54,7 +54,7 @@ func TestReify(t *testing.T) { synth, err := Reify(sn) // Inspect the resulting high level node. Require(t, err, ShouldEqual, nil) - Wish(t, synth.Kind(), ShouldEqual, ipld.Kind_String) + Wish(t, synth.Kind(), ShouldEqual, datamodel.Kind_String) s, err := synth.AsString() Wish(t, err, ShouldEqual, nil) Wish(t, s, ShouldEqual, "abcd") diff --git a/adl/rot13adl/rot13reification.go b/adl/rot13adl/rot13reification.go index ca7622db..5b323f45 100644 --- a/adl/rot13adl/rot13reification.go +++ b/adl/rot13adl/rot13reification.go @@ -3,7 +3,7 @@ package rot13adl import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Reify examines data in a Node to see if it matches the shape for valid substrate data for this ADL, @@ -40,7 +40,7 @@ import ( // Reification for multiblock ADLs might also need link loader systems as a parameter here // so they can capture them as config and hold them for use in future operations that do lazy loading. // -func Reify(maybeSubstrateRoot ipld.Node) (ipld.Node, error) { +func Reify(maybeSubstrateRoot datamodel.Node) (datamodel.Node, error) { // Reify is often very easy to implement, // especially if you have an IPLD Schema that specifies the shape of the substrate data: // We can just check if the data in maybeSubstrateRoot happens to already be exactly the right type, diff --git a/adl/rot13adl/rot13substrate.go b/adl/rot13adl/rot13substrate.go index 391006a4..511475ad 100644 --- a/adl/rot13adl/rot13substrate.go +++ b/adl/rot13adl/rot13substrate.go @@ -1,13 +1,13 @@ package rot13adl import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" "github.com/ipld/go-ipld-prime/schema" ) // Substrate returns the root node of the raw internal data form of the ADL's content. -func (n *_R13String) Substrate() ipld.Node { +func (n *_R13String) Substrate() datamodel.Node { // This is a very minor twist in the case of the rot13 ADL. // However, for larger ADLs (especially those relating to multi-block collections), // this could be quite a bit more involved, and would almost certainly be the root node of a larger tree. @@ -16,7 +16,7 @@ func (n *_R13String) Substrate() ipld.Node { // -- Node --> -var _ ipld.Node = (*_Substrate)(nil) +var _ datamodel.Node = (*_Substrate)(nil) // Somewhat unusually for an ADL, there's only one substrate node type, // and we actually made it have the same in-memory structure as the synthesized view node. @@ -30,25 +30,25 @@ type _Substrate _R13String // and I'm not sure what, if any, suffix actually makes meaningful sense to a user either. // I added the segment ".internal." to the middle of the name mangle; does this seem helpful? -func (*_Substrate) Kind() ipld.Kind { - return ipld.Kind_String +func (*_Substrate) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (*_Substrate) LookupByString(string) (ipld.Node, error) { +func (*_Substrate) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupByString("") } -func (*_Substrate) LookupByNode(ipld.Node) (ipld.Node, error) { +func (*_Substrate) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupByNode(nil) } -func (*_Substrate) LookupByIndex(idx int64) (ipld.Node, error) { +func (*_Substrate) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupByIndex(0) } -func (*_Substrate) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (*_Substrate) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupBySegment(seg) } -func (*_Substrate) MapIterator() ipld.MapIterator { +func (*_Substrate) MapIterator() datamodel.MapIterator { return nil } -func (*_Substrate) ListIterator() ipld.ListIterator { +func (*_Substrate) ListIterator() datamodel.ListIterator { return nil } func (*_Substrate) Length() int64 { @@ -75,34 +75,34 @@ func (n *_Substrate) AsString() (string, error) { func (*_Substrate) AsBytes() ([]byte, error) { return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsBytes() } -func (*_Substrate) AsLink() (ipld.Link, error) { +func (*_Substrate) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsLink() } -func (*_Substrate) Prototype() ipld.NodePrototype { +func (*_Substrate) Prototype() datamodel.NodePrototype { return _Substrate__Prototype{} } // -- NodePrototype --> -var _ ipld.NodePrototype = _Substrate__Prototype{} +var _ datamodel.NodePrototype = _Substrate__Prototype{} type _Substrate__Prototype struct { // There's no configuration to this ADL. } -func (np _Substrate__Prototype) NewBuilder() ipld.NodeBuilder { +func (np _Substrate__Prototype) NewBuilder() datamodel.NodeBuilder { return &_Substrate__Builder{} } // -- NodeBuilder --> -var _ ipld.NodeBuilder = (*_Substrate__Builder)(nil) +var _ datamodel.NodeBuilder = (*_Substrate__Builder)(nil) type _Substrate__Builder struct { _Substrate__Assembler } -func (nb *_Substrate__Builder) Build() ipld.Node { +func (nb *_Substrate__Builder) Build() datamodel.Node { if nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -114,17 +114,17 @@ func (nb *_Substrate__Builder) Reset() { // -- NodeAssembler --> -var _ ipld.NodeAssembler = (*_Substrate__Assembler)(nil) +var _ datamodel.NodeAssembler = (*_Substrate__Assembler)(nil) type _Substrate__Assembler struct { w *_Substrate m schema.Maybe // REVIEW: if the package where this Maybe enum lives is maybe not the right home for it after all. Or should this line use something different? We're only using some of its values after all. } -func (_Substrate__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Substrate__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.BeginMap(0) } -func (_Substrate__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Substrate__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.BeginList(0) } func (na *_Substrate__Assembler) AssignNull() error { @@ -155,10 +155,10 @@ func (na *_Substrate__Assembler) AssignString(v string) error { func (_Substrate__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignBytes(nil) } -func (_Substrate__Assembler) AssignLink(ipld.Link) error { +func (_Substrate__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignLink(nil) } -func (na *_Substrate__Assembler) AssignNode(v ipld.Node) error { +func (na *_Substrate__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -177,6 +177,6 @@ func (na *_Substrate__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_Substrate__Assembler) Prototype() ipld.NodePrototype { +func (_Substrate__Assembler) Prototype() datamodel.NodePrototype { return _Substrate__Prototype{} } diff --git a/codec.go b/codec.go new file mode 100644 index 00000000..26ed3b07 --- /dev/null +++ b/codec.go @@ -0,0 +1,10 @@ +package ipld + +import ( + "github.com/ipld/go-ipld-prime/codec" +) + +type ( + Encoder = codec.Encoder + Decoder = codec.Decoder +) diff --git a/codec/README.md b/codec/README.md index 8cc753ac..a2bb0e7b 100644 --- a/codec/README.md +++ b/codec/README.md @@ -7,8 +7,8 @@ The subpackages contains some codecs which reside in this repo. The codecs included here are our "batteries included" codecs, but they are not otherwise special. -It is not necessary for a codec to be a subpackage here to be a valid codec to use with go-ipld-prime; -anything that implements the `ipld.Encoder` and `ipld.Decoder` interfaces is fine. +It is not necessary for a codec to be a subpackage here to be a valid codec to use with go-ipld; +anything that implements the `codec.Encoder` and `codec.Decoder` interfaces is fine. Terminology diff --git a/codec/api.go b/codec/api.go index b61c4e07..6fa2c271 100644 --- a/codec/api.go +++ b/codec/api.go @@ -1,41 +1,113 @@ package codec import ( - "github.com/ipld/go-ipld-prime" + "io" + + "github.com/ipld/go-ipld-prime/datamodel" ) -// Encoder is defined in the root ipld package; this alias is just for documentation and discoverability. +// The following two types define the two directions of transform that a codec can be expected to perform: +// from Node to serial stream (aka "encoding", sometimes also described as "marshalling"), +// and from serial stream to Node (via a NodeAssembler) (aka "decoding", sometimes also described as "unmarshalling"). +// +// You'll find a couple of implementations matching this shape in subpackages of 'codec'. +// (These are the handful of encoders and decoders we ship as "batteries included".) +// Other encoder and decoder implementations can be found in other repositories/modules. +// It should also be easy to implement encodecs and decoders of your own! +// +// Encoder and Decoder functions can be used on their own, but are also often used via the `ipld/linking.LinkSystem` construction, +// which handles all the other related operations necessary for a content-addressed storage system at once. +// +// Encoder and Decoder functions can be registered in the multicodec table in the `ipld/multicodec` package +// if they're providing functionality that matches the expectations for a multicodec identifier. +// This table will be used by some common EncoderChooser and DecoderChooser implementations +// (namely, the ones in LinkSystems produced by the `linking/cid` package). +// It's not strictly necessary to register functions there, though; you can also just use them directly. // -// Encoder functions can be composed into an ipld.LinkSystem to provide -// a "one stop shop" API for handling content addressable storage. -// Encoder functions can also be used directly if you want to handle serial data streams. +// There are furthermore several conventions that codec packages are recommended to follow, but are only conventions: // -// Most codec packages will have a ReusableEncoder type -// (which contains any working memory needed by the encoder implementation, -// as well as any configuration options), -// and that type will have an Encode function matching this interface. +// Most codec packages should have a ReusableEncoder and ResuableDecoder type, +// which contain any working memory needed by the implementation, as well as any configuration options, +// and those types should have an Encode and Decode function respectively which match these function types. +// They may alternatively have EncoderConfig and DecoderConfig types, which have similar purpose, +// but aren't promising memory reuse if kept around. // -// By convention, codec packages that have a multicodec contract will also have -// a package-scope exported function called Encode which also matches this interface, -// and is the equivalent of creating a zero-value ReusableEncoder (aka, default config) -// and using its Encode method. -// This package-scope function will typically also internally use a sync.Pool +// By convention, a codec package that expects to fulfill a multicodec contract will also have +// a package-scope exported function called Encode or Decode which also matches this interface, +// and is the equivalent of creating a zero-value ReusableEncoder or ReusableDecoder (aka, default config) +// and using its Encode or Decode methods. +// This package-scope function may also internally use a sync.Pool // to keep some ReusableEncoder values on hand to avoid unnecesary allocations. // -// Note that a ReusableEncoder type that supports configuration options +// Note that an EncoderConfig or DecoderConfig type that supports configuration options // does not functionally expose those options when invoked by the multicodec system -- -// multicodec indicators do not provide room for extended configuration info. +// multicodec indicator codes do not provide room for extended configuration info. // Codecs that expose configuration options are doing so for library users to enjoy; // it does not mean those non-default configurations will necessarly be available // in all scenarios that use codecs indirectly. // There is also no standard interface for such configurations: by nature, -// if they exist at all, they vary per codec. -type Encoder = ipld.Encoder +// if they exist at all, they tend to vary per codec. +type ( + // Encoder defines the shape of a function which traverses a Node tree + // and emits its data in a serialized form into an io.Writer. + // + // The dual of Encoder is a Decoder, which takes a NodeAssembler + // and fills it with deserialized data consumed from an io.Reader. + // Typically, Decoder and Encoder functions will be found in pairs, + // and will be expected to be able to round-trip each other's data. + // + // Encoder functions can be used directly. + // Encoder functions are also often used via a LinkSystem when working with content-addressed storage. + // LinkSystem methods will helpfully handle the entire process of traversing a Node tree, + // encoding this data, hashing it, streaming it to the writer, and committing it -- all as one step. + // + // An Encoder works with Nodes. + // If you have a native golang structure, and want to serialize it using an Encoder, + // you'll need to figure out how to transform that golang structure into an ipld.Node tree first. + // + // It may be useful to understand "multicodecs" when working with Encoders. + // In IPLD, a system called "multicodecs" is typically used to describe encoding foramts. + // A "multicodec indicator" is a number which describes an encoding; + // the Link implementations used in IPLD (CIDs) store a multicodec indicator in the Link; + // and in this library, a multicodec registry exists in the `codec` package, + // and can be used to associate a multicodec indicator number with an Encoder function. + // The default EncoderChooser in a LinkSystem will use this multicodec registry to select Encoder functions. + // However, you can construct a LinkSystem that uses any EncoderChooser you want. + // It is also possible to have and use Encoder functions that aren't registered as a multicodec at all... + // we just recommend being cautious of this, because it may make your data less recognizable + // when working with other systems that use multicodec indicators as part of their communication. + Encoder func(datamodel.Node, io.Writer) error -// Decoder is defined in the root ipld package; this alias is just for documentation and discoverability. + // Decoder defines the shape of a function which produces a Node tree + // by reading serialized data from an io.Reader. + // (Decoder doesn't itself return a Node directly, but rather takes a NodeAssembler as an argument, + // because this allows the caller more control over the Node implementation, + // as well as some control over allocations.) + // + // The dual of Decoder is an Encoder, which takes a Node and + // emits its data in a serialized form into an io.Writer. + // Typically, Decoder and Encoder functions will be found in pairs, + // and will be expected to be able to round-trip each other's data. + // + // Decoder functions can be used directly. + // Decoder functions are also often used via a LinkSystem when working with content-addressed storage. + // LinkSystem methods will helpfully handle the entire process of opening block readers, + // verifying the hash of the data stream, and applying a Decoder to build Nodes -- all as one step. + // + // A Decoder works with Nodes. + // If you have a native golang structure, and want to populate it with data using a Decoder, + // you'll need to either get a NodeAssembler which proxies data into that structure directly, + // or assemble a Node as intermediate storage and copy the data to the native structure as a separate step. + // + // It may be useful to understand "multicodecs" when working with Decoders. + // See the documentation on the Encoder function interface for more discussion of multicodecs, + // the multicodec table, and how this is typically connected to linking. + Decoder func(datamodel.NodeAssembler, io.Reader) error +) + +// ------------------- +// Errors // -// Most of the documentation for Encoder also applies wholesale to the Decoder interface. -type Decoder = ipld.Decoder type ErrBudgetExhausted struct{} @@ -43,6 +115,10 @@ func (e ErrBudgetExhausted) Error() string { return "decoder resource budget exhausted (message too long or too complex)" } +// --------------------- +// Other valuable and reused constants +// + type MapSortMode uint8 const ( diff --git a/codec/cbor/multicodec.go b/codec/cbor/multicodec.go index 71335de8..d58de34f 100644 --- a/codec/cbor/multicodec.go +++ b/codec/cbor/multicodec.go @@ -3,14 +3,15 @@ package cbor import ( "io" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/codec" "github.com/ipld/go-ipld-prime/codec/dagcbor" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/multicodec" ) var ( - _ ipld.Decoder = Decode - _ ipld.Encoder = Encode + _ codec.Decoder = Decode + _ codec.Encoder = Encode ) func init() { @@ -18,21 +19,21 @@ func init() { multicodec.RegisterDecoder(0x51, Decode) } -// Decode deserializes data from the given io.Reader and feeds it into the given ipld.NodeAssembler. -// Decode fits the ipld.Decoder function interface. +// Decode deserializes data from the given io.Reader and feeds it into the given datamodel.NodeAssembler. +// Decode fits the codec.Decoder function interface. // // This is the function that will be registered in the default multicodec registry during package init time. -func Decode(na ipld.NodeAssembler, r io.Reader) error { +func Decode(na datamodel.NodeAssembler, r io.Reader) error { return dagcbor.DecodeOptions{ AllowLinks: false, }.Decode(na, r) } -// Encode walks the given ipld.Node and serializes it to the given io.Writer. -// Encode fits the ipld.Encoder function interface. +// Encode walks the given datamodel.Node and serializes it to the given io.Writer. +// Encode fits the codec.Encoder function interface. // // This is the function that will be registered in the default multicodec registry during package init time. -func Encode(n ipld.Node, w io.Writer) error { +func Encode(n datamodel.Node, w io.Writer) error { return dagcbor.EncodeOptions{ AllowLinks: false, }.Encode(n, w) diff --git a/codec/cbor/roundtrip_test.go b/codec/cbor/roundtrip_test.go index e6b95a43..1ae817f2 100644 --- a/codec/cbor/roundtrip_test.go +++ b/codec/cbor/roundtrip_test.go @@ -8,10 +8,10 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) -var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var n = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("map").CreateMap(2, func(na fluent.MapAssembler) { na.AssembleEntry("one").AssignInt(1) @@ -39,7 +39,7 @@ func TestRoundtrip(t *testing.T) { }) t.Run("decoding", func(t *testing.T) { buf := strings.NewReader(serial) - nb := basicnode.Prototype__Map{}.NewBuilder() + nb := basicnode.Prototype.Map.NewBuilder() err := Decode(nb, buf) Require(t, err, ShouldEqual, nil) Wish(t, nb.Build(), ShouldEqual, n) diff --git a/codec/codectools/token.go b/codec/codectools/token.go index d2299116..8ebdfdf6 100644 --- a/codec/codectools/token.go +++ b/codec/codectools/token.go @@ -3,31 +3,31 @@ package codectools import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type Token struct { Kind TokenKind - Length int64 // Present for MapOpen or ListOpen. May be -1 for "unknown" (e.g. a json tokenizer will yield this). - Bool bool // Value. Union: only has meaning if Kind is TokenKind_Bool. - Int int64 // Value. Union: only has meaning if Kind is TokenKind_Int. - Float float64 // Value. Union: only has meaning if Kind is TokenKind_Float. - Str string // Value. Union: only has meaning if Kind is TokenKind_String. ('Str' rather than 'String' to avoid collision with method.) - Bytes []byte // Value. Union: only has meaning if Kind is TokenKind_Bytes. - Link ipld.Link // Value. Union: only has meaning if Kind is TokenKind_Link. + Length int64 // Present for MapOpen or ListOpen. May be -1 for "unknown" (e.g. a json tokenizer will yield this). + Bool bool // Value. Union: only has meaning if Kind is TokenKind_Bool. + Int int64 // Value. Union: only has meaning if Kind is TokenKind_Int. + Float float64 // Value. Union: only has meaning if Kind is TokenKind_Float. + Str string // Value. Union: only has meaning if Kind is TokenKind_String. ('Str' rather than 'String' to avoid collision with method.) + Bytes []byte // Value. Union: only has meaning if Kind is TokenKind_Bytes. + Link datamodel.Link // Value. Union: only has meaning if Kind is TokenKind_Link. - Node ipld.Node // Direct pointer to the original data, if this token is used to communicate data during a walk of existing in-memory data. Absent when token is being used during deserialization. + Node datamodel.Node // Direct pointer to the original data, if this token is used to communicate data during a walk of existing in-memory data. Absent when token is being used during deserialization. // The following fields all track position and progress: // (These may be useful to copy into any error messages if errors arise.) // (Implementations may assume token reuse and treat these as state keeping; // you may experience position accounting accuracy problems if *not* reusing tokens or if zeroing these fields.) - pth []ipld.PathSegment // Set by token producers (whether marshallers or deserializers) to track logical position. - offset int64 // Set by deserializers (for both textual or binary formats alike) to track progress. - lineOffset int64 // Set by deserializers that work with textual data. May be ignored by binary deserializers. - columnOffset int64 // Set by deserializers that work with textual data. May be ignored by binary deserializers. + pth []datamodel.PathSegment // Set by token producers (whether marshallers or deserializers) to track logical position. + offset int64 // Set by deserializers (for both textual or binary formats alike) to track progress. + lineOffset int64 // Set by deserializers that work with textual data. May be ignored by binary deserializers. + columnOffset int64 // Set by deserializers that work with textual data. May be ignored by binary deserializers. } func (tk Token) String() string { diff --git a/codec/codectools/token_consumers.go b/codec/codectools/token_consumers.go index 03d61142..19e5b671 100644 --- a/codec/codectools/token_consumers.go +++ b/codec/codectools/token_consumers.go @@ -4,12 +4,12 @@ import ( "fmt" "io" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" ) -// TokenAssemble takes an ipld.NodeAssembler and a TokenReader, -// and repeatedly pumps the TokenReader for tokens and feeds their data into the ipld.NodeAssembler +// TokenAssemble takes an datamodel.NodeAssembler and a TokenReader, +// and repeatedly pumps the TokenReader for tokens and feeds their data into the datamodel.NodeAssembler // until it finishes a complete value. // // To compare and contrast to other token oriented tools: @@ -20,7 +20,7 @@ import ( // TokenAssemble does not enforce the "map keys must be strings" rule which is present in the Data Model; // it will also happily do even recursive structures in map keys, // meaning it can be used when handling schema values like maps with complex keys. -func TokenAssemble(na ipld.NodeAssembler, tr TokenReader, budget int64) error { +func TokenAssemble(na datamodel.NodeAssembler, tr TokenReader, budget int64) error { tk, err := tr(&budget) if err != nil { return err @@ -28,7 +28,7 @@ func TokenAssemble(na ipld.NodeAssembler, tr TokenReader, budget int64) error { return tokenAssemble(na, tk, tr, &budget) } -func tokenAssemble(na ipld.NodeAssembler, tk *Token, tr TokenReader, budget *int64) error { +func tokenAssemble(na datamodel.NodeAssembler, tk *Token, tr TokenReader, budget *int64) error { if *budget < 0 { return codec.ErrBudgetExhausted{} } @@ -132,17 +132,17 @@ type TokenAssembler struct { } type assemblerStackRow struct { - state uint8 // 0: assign this node; 1: continue list; 2: continue map with key; 3: continue map with value. - na ipld.NodeAssembler // Always present. - la ipld.ListAssembler // At most one of these is present. - ma ipld.MapAssembler // At most one of these is present. + state uint8 // 0: assign this node; 1: continue list; 2: continue map with key; 3: continue map with value. + na datamodel.NodeAssembler // Always present. + la datamodel.ListAssembler // At most one of these is present. + ma datamodel.MapAssembler // At most one of these is present. } type assemblerStack []assemblerStackRow func (stk assemblerStack) Tip() *assemblerStackRow { return &stk[len(stk)-1] } -func (stk *assemblerStack) Push(na ipld.NodeAssembler) { +func (stk *assemblerStack) Push(na datamodel.NodeAssembler) { *stk = append(*stk, assemblerStackRow{na: na}) } func (stk *assemblerStack) Pop() { @@ -152,7 +152,7 @@ func (stk *assemblerStack) Pop() { *stk = (*stk)[0 : len(*stk)-1] } -func (ta *TokenAssembler) Initialize(na ipld.NodeAssembler, budget int64) { +func (ta *TokenAssembler) Initialize(na datamodel.NodeAssembler, budget int64) { if ta.stk == nil { ta.stk = make(assemblerStack, 0, 10) } else { diff --git a/codec/codectools/token_producers.go b/codec/codectools/token_producers.go index b960ce7c..fbaa806d 100644 --- a/codec/codectools/token_producers.go +++ b/codec/codectools/token_producers.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // TokenWalk walks an ipld Node and repeatedly calls the visitFn, @@ -30,7 +30,7 @@ import ( // (e.g. anything other than a MapOpen or a ListOpen) has no effect. // // TokenAssembler is the rough dual of TokenWalk. -func TokenWalk(n ipld.Node, visitFn func(tk *Token) error) error { +func TokenWalk(n datamodel.Node, visitFn func(tk *Token) error) error { // TokenWalk would be trivial to implement over NodeTokenizer, // but we do a distinct implementation here because NodeTokenizer's resumable implementation means it needs a user-space stack, // and to reuse that would require allocations which this method (since it's not resumable in the same way) can easily avoid (or at least, keep on the stack). @@ -39,9 +39,9 @@ func TokenWalk(n ipld.Node, visitFn func(tk *Token) error) error { return tokenWalk(&tk, n, visitFn) } -func tokenWalk(tk *Token, n ipld.Node, visitFn func(*Token) error) error { +func tokenWalk(tk *Token, n datamodel.Node, visitFn func(*Token) error) error { switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: tk.Kind = TokenKind_MapOpen tk.Length = n.Length() tk.Node = n @@ -64,7 +64,7 @@ func tokenWalk(tk *Token, n ipld.Node, visitFn func(*Token) error) error { tk.Kind = TokenKind_MapClose tk.Node = n return visitFn(tk) - case ipld.Kind_List: + case datamodel.Kind_List: tk.Kind = TokenKind_ListOpen tk.Length = n.Length() tk.Node = n @@ -84,31 +84,31 @@ func tokenWalk(tk *Token, n ipld.Node, visitFn func(*Token) error) error { tk.Kind = TokenKind_ListClose tk.Node = n return visitFn(tk) - case ipld.Kind_Null: + case datamodel.Kind_Null: tk.Kind = TokenKind_Null return visitFn(tk) - case ipld.Kind_Bool: + case datamodel.Kind_Bool: tk.Kind = TokenKind_Bool tk.Bool, _ = n.AsBool() return visitFn(tk) - case ipld.Kind_Int: + case datamodel.Kind_Int: tk.Kind = TokenKind_Int i, _ := n.AsInt() tk.Int = int64(i) // TODO: upgrade all of ipld to use high precision int consistently return visitFn(tk) - case ipld.Kind_Float: + case datamodel.Kind_Float: tk.Kind = TokenKind_Float tk.Float, _ = n.AsFloat() return visitFn(tk) - case ipld.Kind_String: + case datamodel.Kind_String: tk.Kind = TokenKind_String tk.Str, _ = n.AsString() return visitFn(tk) - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: tk.Kind = TokenKind_Bytes tk.Bytes, _ = n.AsBytes() return visitFn(tk) - case ipld.Kind_Link: + case datamodel.Kind_Link: tk.Kind = TokenKind_Link tk.Link, _ = n.AsLink() return visitFn(tk) @@ -121,7 +121,7 @@ var TokenWalkSkip = errors.New("token walk: skip") // --- the stepwise token producer system (more complicated; has a userland stack) is below --> -// A TokenReader can be produced from any ipld.Node using NodeTokenizer. +// A TokenReader can be produced from any datamodel.Node using NodeTokenizer. // TokenReader are also commonly implemented by codec packages, // wherein they're created over a serial data stream and tokenize that stream when pumped. // @@ -146,7 +146,7 @@ type NodeTokenizer struct { stk nodeTokenizerStack } -func (nt *NodeTokenizer) Initialize(n ipld.Node) { +func (nt *NodeTokenizer) Initialize(n datamodel.Node) { if nt.stk == nil { nt.stk = make(nodeTokenizerStack, 0, 10) } else { @@ -156,11 +156,11 @@ func (nt *NodeTokenizer) Initialize(n ipld.Node) { } type nodeTokenizerStackRow struct { - state uint8 // 0: start this node; 1: continue list; 2: continue map with key; 3: continue map with value. - n ipld.Node // Always present. - litr ipld.ListIterator // At most one of these is present. - mitr ipld.MapIterator // At most one of these is present. - mval ipld.Node // The value to resume at when in state 3. + state uint8 // 0: start this node; 1: continue list; 2: continue map with key; 3: continue map with value. + n datamodel.Node // Always present. + litr datamodel.ListIterator // At most one of these is present. + mitr datamodel.MapIterator // At most one of these is present. + mval datamodel.Node // The value to resume at when in state 3. } type nodeTokenizerStack []nodeTokenizerStackRow @@ -168,7 +168,7 @@ type nodeTokenizerStack []nodeTokenizerStackRow func (stk nodeTokenizerStack) Tip() *nodeTokenizerStackRow { return &stk[len(stk)-1] } -func (stk *nodeTokenizerStack) Push(n ipld.Node) { +func (stk *nodeTokenizerStack) Push(n datamodel.Node) { *stk = append(*stk, nodeTokenizerStackRow{n: n}) } func (stk *nodeTokenizerStack) Pop() { @@ -195,51 +195,51 @@ func (nt *NodeTokenizer) ReadToken() (next *Token, err error) { switch tip.state { case 0: switch tip.n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: nt.tk.Kind = TokenKind_MapOpen nt.tk.Length = tip.n.Length() nt.tk.Node = tip.n tip.state = 2 tip.mitr = tip.n.MapIterator() return &nt.tk, nil - case ipld.Kind_List: + case datamodel.Kind_List: nt.tk.Kind = TokenKind_ListOpen nt.tk.Length = tip.n.Length() nt.tk.Node = tip.n tip.state = 1 tip.litr = tip.n.ListIterator() return &nt.tk, nil - case ipld.Kind_Null: + case datamodel.Kind_Null: nt.tk.Kind = TokenKind_Null nt.stk.Pop() return &nt.tk, nil - case ipld.Kind_Bool: + case datamodel.Kind_Bool: nt.tk.Kind = TokenKind_Bool nt.tk.Bool, _ = tip.n.AsBool() nt.stk.Pop() return &nt.tk, nil - case ipld.Kind_Int: + case datamodel.Kind_Int: nt.tk.Kind = TokenKind_Int i, _ := tip.n.AsInt() nt.tk.Int = int64(i) // TODO: upgrade all of ipld to use high precision int consistently nt.stk.Pop() return &nt.tk, nil - case ipld.Kind_Float: + case datamodel.Kind_Float: nt.tk.Kind = TokenKind_Float nt.tk.Float, _ = tip.n.AsFloat() nt.stk.Pop() return &nt.tk, nil - case ipld.Kind_String: + case datamodel.Kind_String: nt.tk.Kind = TokenKind_String nt.tk.Str, _ = tip.n.AsString() nt.stk.Pop() return &nt.tk, nil - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: nt.tk.Kind = TokenKind_Bytes nt.tk.Bytes, _ = tip.n.AsBytes() nt.stk.Pop() return &nt.tk, nil - case ipld.Kind_Link: + case datamodel.Kind_Link: nt.tk.Kind = TokenKind_Link nt.tk.Link, _ = tip.n.AsLink() nt.stk.Pop() diff --git a/codec/codectools/token_test.go b/codec/codectools/token_test.go index fdac573b..c8451c6d 100644 --- a/codec/codectools/token_test.go +++ b/codec/codectools/token_test.go @@ -1,14 +1,14 @@ package codectools import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) var tokenFixtures = []struct { - value ipld.Node + value datamodel.Node sequence []Token }{ { diff --git a/codec/dagcbor/doc.go b/codec/dagcbor/doc.go index fa240284..ba22121f 100644 --- a/codec/dagcbor/doc.go +++ b/codec/dagcbor/doc.go @@ -1,7 +1,7 @@ /* The dagcbor package provides a DAG-CBOR codec implementation. - The Encode and Decode functions match the ipld.Encoder and ipld.Decoder function interfaces, + The Encode and Decode functions match the codec.Encoder and codec.Decoder function interfaces, and can be registered with the go-ipld-prime/multicodec package for easy usage with systems such as CIDs. Importing this package will automatically have the side-effect of registering Encode and Decode diff --git a/codec/dagcbor/marshal.go b/codec/dagcbor/marshal.go index e8ce035c..903069b2 100644 --- a/codec/dagcbor/marshal.go +++ b/codec/dagcbor/marshal.go @@ -9,17 +9,17 @@ import ( "github.com/polydawn/refmt/shared" "github.com/polydawn/refmt/tok" - ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) // This file should be identical to the general feature in the parent package, -// except for the `case ipld.Kind_Link` block, +// except for the `case datamodel.Kind_Link` block, // which is dag-cbor's special sauce for schemafree links. // EncodeOptions can be used to customize the behavior of an encoding function. -// The Encode method on this struct fits the ipld.Encoder function interface. +// The Encode method on this struct fits the codec.Encoder function interface. type EncodeOptions struct { // If true, allow encoding of Link nodes as CBOR tag(42); // otherwise, reject them as unencodable. @@ -29,11 +29,11 @@ type EncodeOptions struct { MapSortMode codec.MapSortMode } -// Encode walks the given ipld.Node and serializes it to the given io.Writer. -// Encode fits the ipld.Encoder function interface. +// Encode walks the given datamodel.Node and serializes it to the given io.Writer. +// Encode fits the codec.Encoder function interface. // // The behavior of the encoder can be customized by setting fields in the EncodeOptions struct before calling this method. -func (cfg EncodeOptions) Encode(n ipld.Node, w io.Writer) error { +func (cfg EncodeOptions) Encode(n datamodel.Node, w io.Writer) error { // Probe for a builtin fast path. Shortcut to that if possible. type detectFastPath interface { EncodeDagCbor(io.Writer) error @@ -52,22 +52,22 @@ func (cfg EncodeOptions) Encode(n ipld.Node, w io.Writer) error { // Marshal is a deprecated function. // Please consider switching to EncodeOptions.Encode instead. -func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { +func Marshal(n datamodel.Node, sink shared.TokenSink, options EncodeOptions) error { var tk tok.Token return marshal(n, &tk, sink, options) } -func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOptions) error { +func marshal(n datamodel.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOptions) error { switch n.Kind() { - case ipld.Kind_Invalid: + case datamodel.Kind_Invalid: return fmt.Errorf("cannot traverse a node that is absent") - case ipld.Kind_Null: + case datamodel.Kind_Null: tk.Type = tok.TNull _, err := sink.Step(tk) return err - case ipld.Kind_Map: + case datamodel.Kind_Map: return marshalMap(n, tk, sink, options) - case ipld.Kind_List: + case datamodel.Kind_List: // Emit start of list. tk.Type = tok.TArrOpen l := n.Length() @@ -89,7 +89,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp tk.Type = tok.TArrClose _, err := sink.Step(tk) return err - case ipld.Kind_Bool: + case datamodel.Kind_Bool: v, err := n.AsBool() if err != nil { return err @@ -98,7 +98,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp tk.Bool = v _, err = sink.Step(tk) return err - case ipld.Kind_Int: + case datamodel.Kind_Int: v, err := n.AsInt() if err != nil { return err @@ -107,7 +107,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp tk.Int = int64(v) _, err = sink.Step(tk) return err - case ipld.Kind_Float: + case datamodel.Kind_Float: v, err := n.AsFloat() if err != nil { return err @@ -116,7 +116,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp tk.Float64 = v _, err = sink.Step(tk) return err - case ipld.Kind_String: + case datamodel.Kind_String: v, err := n.AsString() if err != nil { return err @@ -125,7 +125,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp tk.Str = v _, err = sink.Step(tk) return err - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: v, err := n.AsBytes() if err != nil { return err @@ -134,7 +134,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp tk.Bytes = v _, err = sink.Step(tk) return err - case ipld.Kind_Link: + case datamodel.Kind_Link: if !options.AllowLinks { return fmt.Errorf("cannot Marshal ipld links to CBOR") } @@ -159,7 +159,7 @@ func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOp } } -func marshalMap(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOptions) error { +func marshalMap(n datamodel.Node, tk *tok.Token, sink shared.TokenSink, options EncodeOptions) error { // Emit start of map. tk.Type = tok.TMapOpen tk.Length = int(n.Length()) // TODO: overflow check @@ -170,7 +170,7 @@ func marshalMap(n ipld.Node, tk *tok.Token, sink shared.TokenSink, options Encod // Collect map entries, then sort by key type entry struct { key string - value ipld.Node + value datamodel.Node } entries := []entry{} for itr := n.MapIterator(); !itr.Done(); { diff --git a/codec/dagcbor/multicodec.go b/codec/dagcbor/multicodec.go index c09daf66..b15ee30b 100644 --- a/codec/dagcbor/multicodec.go +++ b/codec/dagcbor/multicodec.go @@ -3,14 +3,14 @@ package dagcbor import ( "io" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/multicodec" ) var ( - _ ipld.Decoder = Decode - _ ipld.Encoder = Encode + _ codec.Decoder = Decode + _ codec.Encoder = Encode ) func init() { @@ -18,29 +18,29 @@ func init() { multicodec.RegisterDecoder(0x71, Decode) } -// Decode deserializes data from the given io.Reader and feeds it into the given ipld.NodeAssembler. -// Decode fits the ipld.Decoder function interface. +// Decode deserializes data from the given io.Reader and feeds it into the given datamodel.NodeAssembler. +// Decode fits the codec.Decoder function interface. // // A similar function is available on DecodeOptions type if you would like to customize any of the decoding details. // This function uses the defaults for the dag-cbor codec // (meaning: links (indicated by tag 42) are decoded). // // This is the function that will be registered in the default multicodec registry during package init time. -func Decode(na ipld.NodeAssembler, r io.Reader) error { +func Decode(na datamodel.NodeAssembler, r io.Reader) error { return DecodeOptions{ AllowLinks: true, }.Decode(na, r) } -// Encode walks the given ipld.Node and serializes it to the given io.Writer. -// Encode fits the ipld.Encoder function interface. +// Encode walks the given datamodel.Node and serializes it to the given io.Writer. +// Encode fits the codec.Encoder function interface. // // A similar function is available on EncodeOptions type if you would like to customize any of the encoding details. // This function uses the defaults for the dag-cbor codec // (meaning: links are encoded, and map keys are sorted (with RFC7049 ordering!) during encode). // // This is the function that will be registered in the default multicodec registry during package init time. -func Encode(n ipld.Node, w io.Writer) error { +func Encode(n datamodel.Node, w io.Writer) error { return EncodeOptions{ AllowLinks: true, MapSortMode: codec.MapSortMode_RFC7049, diff --git a/codec/dagcbor/roundtripCidlink_test.go b/codec/dagcbor/roundtripCidlink_test.go index a66ce85f..2da7edee 100644 --- a/codec/dagcbor/roundtripCidlink_test.go +++ b/codec/dagcbor/roundtripCidlink_test.go @@ -8,9 +8,10 @@ import ( . "github.com/warpfork/go-wish" cid "github.com/ipfs/go-cid" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestRoundtripCidlink(t *testing.T) { @@ -23,17 +24,17 @@ func TestRoundtripCidlink(t *testing.T) { lsys := cidlink.DefaultLinkSystem() buf := bytes.Buffer{} - lsys.StorageWriteOpener = func(lnkCtx ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error) { - return &buf, func(lnk ipld.Link) error { return nil }, nil + lsys.StorageWriteOpener = func(lnkCtx linking.LinkContext) (io.Writer, linking.BlockWriteCommitter, error) { + return &buf, func(lnk datamodel.Link) error { return nil }, nil } - lsys.StorageReadOpener = func(lnkCtx ipld.LinkContext, lnk ipld.Link) (io.Reader, error) { + lsys.StorageReadOpener = func(lnkCtx linking.LinkContext, lnk datamodel.Link) (io.Reader, error) { return bytes.NewReader(buf.Bytes()), nil } - lnk, err := lsys.Store(ipld.LinkContext{}, lp, n) + lnk, err := lsys.Store(linking.LinkContext{}, lp, n) Require(t, err, ShouldEqual, nil) - n2, err := lsys.Load(ipld.LinkContext{}, lnk, basicnode.Prototype.Any) + n2, err := lsys.Load(linking.LinkContext{}, lnk, basicnode.Prototype.Any) Require(t, err, ShouldEqual, nil) Wish(t, n2, ShouldEqual, nSorted) } diff --git a/codec/dagcbor/roundtrip_test.go b/codec/dagcbor/roundtrip_test.go index 8710e0f1..64b4a0b6 100644 --- a/codec/dagcbor/roundtrip_test.go +++ b/codec/dagcbor/roundtrip_test.go @@ -11,10 +11,10 @@ import ( "github.com/ipld/go-ipld-prime/fluent" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) -var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var n = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("map").CreateMap(2, func(na fluent.MapAssembler) { na.AssembleEntry("one").AssignInt(1) @@ -30,7 +30,7 @@ var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAss }) }) }) -var nSorted = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var nSorted = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("map").CreateMap(2, func(na fluent.MapAssembler) { na.AssembleEntry("one").AssignInt(1) na.AssembleEntry("two").AssignInt(2) @@ -57,7 +57,7 @@ func TestRoundtrip(t *testing.T) { }) t.Run("decoding", func(t *testing.T) { buf := strings.NewReader(serial) - nb := basicnode.Prototype__Map{}.NewBuilder() + nb := basicnode.Prototype.Map.NewBuilder() err := Decode(nb, buf) Require(t, err, ShouldEqual, nil) Wish(t, nb.Build(), ShouldEqual, nSorted) @@ -91,7 +91,7 @@ func TestRoundtripLinksAndBytes(t *testing.T) { MhLength: 4, }}.BuildLink([]byte{1, 2, 3, 4}) // dummy value, content does not matter to this test. - var linkByteNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { + var linkByteNode = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { nva := na.AssembleEntry("Link") nva.AssignLink(lnk) nva = na.AssembleEntry("Bytes") @@ -103,7 +103,7 @@ func TestRoundtripLinksAndBytes(t *testing.T) { buf := bytes.Buffer{} err := Encode(linkByteNode, &buf) Require(t, err, ShouldEqual, nil) - nb := basicnode.Prototype__Map{}.NewBuilder() + nb := basicnode.Prototype.Map.NewBuilder() err = Decode(nb, &buf) Require(t, err, ShouldEqual, nil) reconstructed := nb.Build() diff --git a/codec/dagcbor/unmarshal.go b/codec/dagcbor/unmarshal.go index b4bef240..8fa44372 100644 --- a/codec/dagcbor/unmarshal.go +++ b/codec/dagcbor/unmarshal.go @@ -11,7 +11,7 @@ import ( "github.com/polydawn/refmt/shared" "github.com/polydawn/refmt/tok" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) @@ -30,17 +30,17 @@ const ( // which has dag-cbor's special sauce for detecting schemafree links. // DecodeOptions can be used to customize the behavior of a decoding function. -// The Decode method on this struct fits the ipld.Decoder function interface. +// The Decode method on this struct fits the codec.Decoder function interface. type DecodeOptions struct { // If true, parse DAG-CBOR tag(42) as Link nodes, otherwise reject them AllowLinks bool } -// Decode deserializes data from the given io.Reader and feeds it into the given ipld.NodeAssembler. -// Decode fits the ipld.Decoder function interface. +// Decode deserializes data from the given io.Reader and feeds it into the given datamodel.NodeAssembler. +// Decode fits the codec.Decoder function interface. // // The behavior of the decoder can be customized by setting fields in the DecodeOptions struct before calling this method. -func (cfg DecodeOptions) Decode(na ipld.NodeAssembler, r io.Reader) error { +func (cfg DecodeOptions) Decode(na datamodel.NodeAssembler, r io.Reader) error { // Probe for a builtin fast path. Shortcut to that if possible. type detectFastPath interface { DecodeDagCbor(io.Reader) error @@ -59,7 +59,7 @@ func (cfg DecodeOptions) Decode(na ipld.NodeAssembler, r io.Reader) error { // Unmarshal is a deprecated function. // Please consider switching to DecodeOptions.Decode instead. -func Unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource, options DecodeOptions) error { +func Unmarshal(na datamodel.NodeAssembler, tokSrc shared.TokenSource, options DecodeOptions) error { // Have a gas budget, which will be decremented as we allocate memory, and an error returned when execeeded (or about to be exceeded). // This is a DoS defense mechanism. // It's *roughly* in units of bytes (but only very, VERY roughly) -- it also treats words as 1 in many cases. @@ -68,7 +68,7 @@ func Unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource, options DecodeO return unmarshal1(na, tokSrc, &gas, options) } -func unmarshal1(na ipld.NodeAssembler, tokSrc shared.TokenSource, gas *int, options DecodeOptions) error { +func unmarshal1(na datamodel.NodeAssembler, tokSrc shared.TokenSource, gas *int, options DecodeOptions) error { var tk tok.Token done, err := tokSrc.Step(&tk) if err != nil { @@ -82,7 +82,7 @@ func unmarshal1(na ipld.NodeAssembler, tokSrc shared.TokenSource, gas *int, opti // starts with the first token already primed. Necessary to get recursion // to flow right without a peek+unpeek system. -func unmarshal2(na ipld.NodeAssembler, tokSrc shared.TokenSource, tk *tok.Token, gas *int, options DecodeOptions) error { +func unmarshal2(na datamodel.NodeAssembler, tokSrc shared.TokenSource, tk *tok.Token, gas *int, options DecodeOptions) error { // FUTURE: check for schema.TypedNodeBuilder that's going to parse a Link (they can slurp any token kind they want). switch tk.Type { case tok.TMapOpen: diff --git a/codec/dagcbor/unmarshal_test.go b/codec/dagcbor/unmarshal_test.go index c373c341..b19d91e5 100644 --- a/codec/dagcbor/unmarshal_test.go +++ b/codec/dagcbor/unmarshal_test.go @@ -6,7 +6,7 @@ import ( . "github.com/warpfork/go-wish" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestFunBlocks(t *testing.T) { diff --git a/codec/dagjson/marshal.go b/codec/dagjson/marshal.go index 371e8e1f..be8cf52f 100644 --- a/codec/dagjson/marshal.go +++ b/codec/dagjson/marshal.go @@ -10,17 +10,17 @@ import ( "github.com/polydawn/refmt/shared" "github.com/polydawn/refmt/tok" - ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) // This should be identical to the general feature in the parent package, -// except for the `case ipld.Kind_Link` block, +// except for the `case datamodel.Kind_Link` block, // which is dag-json's special sauce for schemafree links. // EncodeOptions can be used to customize the behavior of an encoding function. -// The Encode method on this struct fits the ipld.Encoder function interface. +// The Encode method on this struct fits the codec.Encoder function interface. type EncodeOptions struct { // If true, will encode nodes with a Link kind using the DAG-JSON // `{"/":"cid string"}` form. @@ -34,11 +34,11 @@ type EncodeOptions struct { MapSortMode codec.MapSortMode } -// Encode walks the given ipld.Node and serializes it to the given io.Writer. -// Encode fits the ipld.Encoder function interface. +// Encode walks the given datamodel.Node and serializes it to the given io.Writer. +// Encode fits the codec.Encoder function interface. // // The behavior of the encoder can be customized by setting fields in the EncodeOptions struct before calling this method. -func (cfg EncodeOptions) Encode(n ipld.Node, w io.Writer) error { +func (cfg EncodeOptions) Encode(n datamodel.Node, w io.Writer) error { return Marshal(n, json.NewEncoder(w, json.EncodeOptions{}), cfg) } @@ -49,16 +49,16 @@ func (cfg EncodeOptions) Encode(n ipld.Node, w io.Writer) error { // Marshal is a deprecated function. // Please consider switching to EncodeOptions.Encode instead. -func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { +func Marshal(n datamodel.Node, sink shared.TokenSink, options EncodeOptions) error { var tk tok.Token switch n.Kind() { - case ipld.Kind_Invalid: + case datamodel.Kind_Invalid: return fmt.Errorf("cannot traverse a node that is absent") - case ipld.Kind_Null: + case datamodel.Kind_Null: tk.Type = tok.TNull _, err := sink.Step(&tk) return err - case ipld.Kind_Map: + case datamodel.Kind_Map: // Emit start of map. tk.Type = tok.TMapOpen tk.Length = int(n.Length()) // TODO: overflow check @@ -69,7 +69,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { // Collect map entries, then sort by key type entry struct { key string - value ipld.Node + value datamodel.Node } entries := []entry{} for itr := n.MapIterator(); !itr.Done(); { @@ -134,7 +134,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { tk.Type = tok.TMapClose _, err := sink.Step(&tk) return err - case ipld.Kind_List: + case datamodel.Kind_List: // Emit start of list. tk.Type = tok.TArrOpen l := n.Length() @@ -156,7 +156,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { tk.Type = tok.TArrClose _, err := sink.Step(&tk) return err - case ipld.Kind_Bool: + case datamodel.Kind_Bool: v, err := n.AsBool() if err != nil { return err @@ -165,7 +165,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { tk.Bool = v _, err = sink.Step(&tk) return err - case ipld.Kind_Int: + case datamodel.Kind_Int: v, err := n.AsInt() if err != nil { return err @@ -174,7 +174,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { tk.Int = int64(v) _, err = sink.Step(&tk) return err - case ipld.Kind_Float: + case datamodel.Kind_Float: v, err := n.AsFloat() if err != nil { return err @@ -183,7 +183,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { tk.Float64 = v _, err = sink.Step(&tk) return err - case ipld.Kind_String: + case datamodel.Kind_String: v, err := n.AsString() if err != nil { return err @@ -192,7 +192,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { tk.Str = v _, err = sink.Step(&tk) return err - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: v, err := n.AsBytes() if err != nil { return err @@ -238,7 +238,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink, options EncodeOptions) error { _, err = sink.Step(&tk) return err } - case ipld.Kind_Link: + case datamodel.Kind_Link: if !options.EncodeLinks { return fmt.Errorf("cannot Marshal ipld links to JSON") } diff --git a/codec/dagjson/multicodec.go b/codec/dagjson/multicodec.go index d2931eb0..2b82c0db 100644 --- a/codec/dagjson/multicodec.go +++ b/codec/dagjson/multicodec.go @@ -3,14 +3,14 @@ package dagjson import ( "io" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/multicodec" ) var ( - _ ipld.Decoder = Decode - _ ipld.Encoder = Encode + _ codec.Decoder = Decode + _ codec.Encoder = Encode ) func init() { @@ -18,30 +18,30 @@ func init() { multicodec.RegisterDecoder(0x0129, Decode) } -// Decode deserializes data from the given io.Reader and feeds it into the given ipld.NodeAssembler. -// Decode fits the ipld.Decoder function interface. +// Decode deserializes data from the given io.Reader and feeds it into the given datamodel.NodeAssembler. +// Decode fits the codec.Decoder function interface. // // A similar function is available on DecodeOptions type if you would like to customize any of the decoding details. // This function uses the defaults for the dag-json codec // (meaning: links are decoded, and bytes are decoded). // // This is the function that will be registered in the default multicodec registry during package init time. -func Decode(na ipld.NodeAssembler, r io.Reader) error { +func Decode(na datamodel.NodeAssembler, r io.Reader) error { return DecodeOptions{ ParseLinks: true, ParseBytes: true, }.Decode(na, r) } -// Encode walks the given ipld.Node and serializes it to the given io.Writer. -// Encode fits the ipld.Encoder function interface. +// Encode walks the given datamodel.Node and serializes it to the given io.Writer. +// Encode fits the codec.Encoder function interface. // // A similar function is available on EncodeOptions type if you would like to customize any of the encoding details. // This function uses the defaults for the dag-json codec // (meaning: links are encoded, bytes are encoded, and map keys are sorted during encode). // // This is the function that will be registered in the default multicodec registry during package init time. -func Encode(n ipld.Node, w io.Writer) error { +func Encode(n datamodel.Node, w io.Writer) error { return EncodeOptions{ EncodeLinks: true, EncodeBytes: true, diff --git a/codec/dagjson/roundtripBytes_test.go b/codec/dagjson/roundtripBytes_test.go index 45f545ba..18814f70 100644 --- a/codec/dagjson/roundtripBytes_test.go +++ b/codec/dagjson/roundtripBytes_test.go @@ -8,14 +8,14 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) -var byteNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var byteNode = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("bytes").AssignBytes([]byte("deadbeef")) }) -var byteNodeSorted = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var byteNodeSorted = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("bytes").AssignBytes([]byte("deadbeef")) na.AssembleEntry("plain").AssignString("olde string") }) @@ -30,14 +30,14 @@ func TestRoundtripBytes(t *testing.T) { }) t.Run("decoding", func(t *testing.T) { buf := strings.NewReader(byteSerial) - nb := basicnode.Prototype__Map{}.NewBuilder() + nb := basicnode.Prototype.Map.NewBuilder() err := Decode(nb, buf) Require(t, err, ShouldEqual, nil) Wish(t, nb.Build(), ShouldEqual, byteNodeSorted) }) } -var encapsulatedNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { +var encapsulatedNode = fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry("/").CreateMap(1, func(sa fluent.MapAssembler) { sa.AssembleEntry("bytes").AssignBytes([]byte("deadbeef")) }) @@ -53,7 +53,7 @@ func TestEncapsulatedBytes(t *testing.T) { }) t.Run("decoding", func(t *testing.T) { buf := strings.NewReader(encapsulatedSerial) - nb := basicnode.Prototype__Map{}.NewBuilder() + nb := basicnode.Prototype.Map.NewBuilder() err := Decode(nb, buf) Require(t, err, ShouldEqual, nil) Wish(t, nb.Build(), ShouldEqual, encapsulatedNode) diff --git a/codec/dagjson/roundtripCidlink_test.go b/codec/dagjson/roundtripCidlink_test.go index 4f739687..03e25fd0 100644 --- a/codec/dagjson/roundtripCidlink_test.go +++ b/codec/dagjson/roundtripCidlink_test.go @@ -9,9 +9,10 @@ import ( . "github.com/warpfork/go-wish" cid "github.com/ipfs/go-cid" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestRoundtripCidlink(t *testing.T) { @@ -24,17 +25,17 @@ func TestRoundtripCidlink(t *testing.T) { lsys := cidlink.DefaultLinkSystem() buf := bytes.Buffer{} - lsys.StorageWriteOpener = func(lnkCtx ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error) { - return &buf, func(lnk ipld.Link) error { return nil }, nil + lsys.StorageWriteOpener = func(lnkCtx linking.LinkContext) (io.Writer, linking.BlockWriteCommitter, error) { + return &buf, func(lnk datamodel.Link) error { return nil }, nil } - lsys.StorageReadOpener = func(lnkCtx ipld.LinkContext, lnk ipld.Link) (io.Reader, error) { + lsys.StorageReadOpener = func(lnkCtx linking.LinkContext, lnk datamodel.Link) (io.Reader, error) { return bytes.NewReader(buf.Bytes()), nil } - lnk, err := lsys.Store(ipld.LinkContext{}, lp, n) + lnk, err := lsys.Store(linking.LinkContext{}, lp, n) Require(t, err, ShouldEqual, nil) - n2, err := lsys.Load(ipld.LinkContext{}, lnk, basicnode.Prototype.Any) + n2, err := lsys.Load(linking.LinkContext{}, lnk, basicnode.Prototype.Any) Require(t, err, ShouldEqual, nil) Wish(t, n2, ShouldEqual, nSorted) } @@ -56,12 +57,12 @@ func TestUnmarshalTrickyMapContainingLink(t *testing.T) { tricky := `{"/":{"/":"` + lnk.String() + `"}}` // Unmarshal. Hopefully we get a map with a link in it. - nb := basicnode.Prototype__Any{}.NewBuilder() + nb := basicnode.Prototype.Any.NewBuilder() err := Decode(nb, strings.NewReader(tricky)) Require(t, err, ShouldEqual, nil) n := nb.Build() - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) n2, err := n.LookupByString("/") Require(t, err, ShouldEqual, nil) - Wish(t, n2.Kind(), ShouldEqual, ipld.Kind_Link) + Wish(t, n2.Kind(), ShouldEqual, datamodel.Kind_Link) } diff --git a/codec/dagjson/roundtrip_test.go b/codec/dagjson/roundtrip_test.go index 4bfd4f6d..8b88a1bb 100644 --- a/codec/dagjson/roundtrip_test.go +++ b/codec/dagjson/roundtrip_test.go @@ -8,10 +8,10 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) -var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var n = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("map").CreateMap(2, func(na fluent.MapAssembler) { na.AssembleEntry("one").AssignInt(1) @@ -27,7 +27,7 @@ var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAss }) }) }) -var nSorted = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { +var nSorted = fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("list").CreateList(2, func(na fluent.ListAssembler) { na.AssembleValue().AssignString("three") na.AssembleValue().AssignString("four") @@ -54,7 +54,7 @@ func TestRoundtrip(t *testing.T) { }) t.Run("decoding", func(t *testing.T) { buf := strings.NewReader(serial) - nb := basicnode.Prototype__Map{}.NewBuilder() + nb := basicnode.Prototype.Map.NewBuilder() err := Decode(nb, buf) Require(t, err, ShouldEqual, nil) Wish(t, nb.Build(), ShouldEqual, nSorted) diff --git a/codec/dagjson/unmarshal.go b/codec/dagjson/unmarshal.go index 2dcdeff4..4b7d5bf9 100644 --- a/codec/dagjson/unmarshal.go +++ b/codec/dagjson/unmarshal.go @@ -10,7 +10,7 @@ import ( "github.com/polydawn/refmt/shared" "github.com/polydawn/refmt/tok" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) @@ -23,7 +23,7 @@ import ( // tokens before deciding what kind of value to create). // DecodeOptions can be used to customize the behavior of a decoding function. -// The Decode method on this struct fits the ipld.Decoder function interface. +// The Decode method on this struct fits the codec.Decoder function interface. type DecodeOptions struct { // If true, parse DAG-JSON `{"/":"cid string"}` as a Link kind node rather // than a plain map @@ -34,11 +34,11 @@ type DecodeOptions struct { ParseBytes bool } -// Decode deserializes data from the given io.Reader and feeds it into the given ipld.NodeAssembler. -// Decode fits the ipld.Decoder function interface. +// Decode deserializes data from the given io.Reader and feeds it into the given datamodel.NodeAssembler. +// Decode fits the codec.Decoder function interface. // // The behavior of the decoder can be customized by setting fields in the DecodeOptions struct before calling this method. -func (cfg DecodeOptions) Decode(na ipld.NodeAssembler, r io.Reader) error { +func (cfg DecodeOptions) Decode(na datamodel.NodeAssembler, r io.Reader) error { err := Unmarshal(na, json.NewDecoder(r), cfg) if err != nil { return err @@ -75,7 +75,7 @@ func (cfg DecodeOptions) Decode(na ipld.NodeAssembler, r io.Reader) error { // Unmarshal is a deprecated function. // Please consider switching to DecodeOptions.Decode instead. -func Unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource, options DecodeOptions) error { +func Unmarshal(na datamodel.NodeAssembler, tokSrc shared.TokenSource, options DecodeOptions) error { var st unmarshalState st.options = options done, err := tokSrc.Step(&st.tk[0]) @@ -172,7 +172,7 @@ func (st *unmarshalState) ensure(tokSrc shared.TokenSource, lookahead int) error // in case of error, the error should just rise. // If the bool return is true, we got a link, and you should not // continue to attempt to build a map. -func (st *unmarshalState) linkLookahead(na ipld.NodeAssembler, tokSrc shared.TokenSource) (bool, error) { +func (st *unmarshalState) linkLookahead(na datamodel.NodeAssembler, tokSrc shared.TokenSource) (bool, error) { // Peek next token. If it's a "/" string, link is still a possibility if err := st.ensure(tokSrc, 1); err != nil { return false, err @@ -214,7 +214,7 @@ func (st *unmarshalState) linkLookahead(na ipld.NodeAssembler, tokSrc shared.Tok return true, nil } -func (st *unmarshalState) bytesLookahead(na ipld.NodeAssembler, tokSrc shared.TokenSource) (bool, error) { +func (st *unmarshalState) bytesLookahead(na datamodel.NodeAssembler, tokSrc shared.TokenSource) (bool, error) { // Peek next token. If it's a "/" string, bytes is still a possibility if err := st.ensure(tokSrc, 1); err != nil { return false, err @@ -278,7 +278,7 @@ func (st *unmarshalState) bytesLookahead(na ipld.NodeAssembler, tokSrc shared.To // starts with the first token already primed. Necessary to get recursion // to flow right without a peek+unpeek system. -func (st *unmarshalState) unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource) error { +func (st *unmarshalState) unmarshal(na datamodel.NodeAssembler, tokSrc shared.TokenSource) error { // FUTURE: check for schema.TypedNodeBuilder that's going to parse a Link (they can slurp any token kind they want). switch st.tk[0].Type { case tok.TMapOpen: diff --git a/codec/dagjson2/json_unmarshaller.go b/codec/dagjson2/json_unmarshaller.go index 8490414f..521aad34 100644 --- a/codec/dagjson2/json_unmarshaller.go +++ b/codec/dagjson2/json_unmarshaller.go @@ -3,9 +3,9 @@ package dagjson import ( "io" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/codectools" jsontoken "github.com/ipld/go-ipld-prime/codec/dagjson2/token" + "github.com/ipld/go-ipld-prime/datamodel" ) // Unmarshal reads data from input, parses it as DAG-JSON, @@ -17,7 +17,7 @@ import ( // // This function is the same as the function found for DAG-JSON // in the default multicodec registry. -func Unmarshal(into ipld.NodeAssembler, input io.Reader) error { +func Unmarshal(into datamodel.NodeAssembler, input io.Reader) error { // FUTURE: consider doing a whole sync.Pool jazz around this. r := ReusableUnmarshaller{} r.SetDecoderConfig(jsontoken.DecoderConfig{ @@ -49,7 +49,7 @@ func (r *ReusableUnmarshaller) SetInitialBudget(budget int64) { r.InitialBudget = budget } -func (r *ReusableUnmarshaller) Unmarshal(into ipld.NodeAssembler, input io.Reader) error { +func (r *ReusableUnmarshaller) Unmarshal(into datamodel.NodeAssembler, input io.Reader) error { r.d.Init(input) return codectools.TokenAssemble(into, r.d.Step, r.InitialBudget) } diff --git a/codec/json/multicodec.go b/codec/json/multicodec.go index fb58578f..20a08544 100644 --- a/codec/json/multicodec.go +++ b/codec/json/multicodec.go @@ -5,15 +5,15 @@ import ( rfmtjson "github.com/polydawn/refmt/json" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/multicodec" ) var ( - _ ipld.Decoder = Decode - _ ipld.Encoder = Encode + _ codec.Decoder = Decode + _ codec.Encoder = Encode ) func init() { @@ -21,22 +21,22 @@ func init() { multicodec.RegisterDecoder(0x0200, Decode) } -// Decode deserializes data from the given io.Reader and feeds it into the given ipld.NodeAssembler. -// Decode fits the ipld.Decoder function interface. +// Decode deserializes data from the given io.Reader and feeds it into the given datamodel.NodeAssembler. +// Decode fits the codec.Decoder function interface. // // This is the function that will be registered in the default multicodec registry during package init time. -func Decode(na ipld.NodeAssembler, r io.Reader) error { +func Decode(na datamodel.NodeAssembler, r io.Reader) error { return dagjson.DecodeOptions{ ParseLinks: false, ParseBytes: false, }.Decode(na, r) } -// Encode walks the given ipld.Node and serializes it to the given io.Writer. -// Encode fits the ipld.Encoder function interface. +// Encode walks the given datamodel.Node and serializes it to the given io.Writer. +// Encode fits the codec.Encoder function interface. // // This is the function that will be registered in the default multicodec registry during package init time. -func Encode(n ipld.Node, w io.Writer) error { +func Encode(n datamodel.Node, w io.Writer) error { // Shell out directly to generic inspection path. // (There's not really any fastpaths of note for json.) // Write another function if you need to tune encoding options about whitespace. diff --git a/codec/jst/demo/main.go b/codec/jst/demo/main.go index a90f14ff..2073068f 100644 --- a/codec/jst/demo/main.go +++ b/codec/jst/demo/main.go @@ -7,7 +7,7 @@ import ( "github.com/ipld/go-ipld-prime/codec/dagjson" "github.com/ipld/go-ipld-prime/codec/jst" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func main() { diff --git a/codec/jst/jst.go b/codec/jst/jst.go index 438b5aa3..42a3127e 100644 --- a/codec/jst/jst.go +++ b/codec/jst/jst.go @@ -37,13 +37,13 @@ import ( "bytes" "io" - ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" "github.com/ipld/go-ipld-prime/codec/json" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" ) -func Marshal(n ipld.Node, w io.Writer) error { +func Marshal(n datamodel.Node, w io.Writer) error { ctx := state{ cfg: Config{ Indent: []byte{' ', ' '}, @@ -58,7 +58,7 @@ func Marshal(n ipld.Node, w io.Writer) error { return marshal(&ctx, n, w) } -func MarshalConfigured(cfg Config, n ipld.Node, w io.Writer) error { +func MarshalConfigured(cfg Config, n datamodel.Node, w io.Writer) error { ctx := state{ cfg: cfg, } @@ -74,7 +74,7 @@ func MarshalConfigured(cfg Config, n ipld.Node, w io.Writer) error { type state struct { cfg Config - path []ipld.PathSegment // TODO replace with PathBuffer... once you, you know, write it. + path []datamodel.PathSegment // TODO replace with PathBuffer... once you, you know, write it. stack []step tables map[tableGroupID]*table spare bytes.Buffer @@ -172,12 +172,12 @@ func (tab *table) Finalize() { } } -func (tab *table) IsRow(n ipld.Node) bool { +func (tab *table) IsRow(n datamodel.Node) bool { // FUTURE: this entire function's behavior might be *heavily* redirected by config. // Having it attached to the table struct might not even be sensible by the end of the day. // Alternately: unclear if we need this function at all, if the "trailing" and "ownLine" entryStyle can simply carry the day for all userstories like comments and etc. switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: if n.Length() < 1 { return false } @@ -187,7 +187,7 @@ func (tab *table) IsRow(n ipld.Node) bool { return true } return columnName(ks) == tab.cols[0] - case ipld.Kind_List: + case datamodel.Kind_List: // FUTURE: maybe this could be 'true', but it requires very different logic. And it's not in my first-draft pareto priority choices. return false default: @@ -198,19 +198,19 @@ func (tab *table) IsRow(n ipld.Node) bool { // Discerns if the given node starts a table, and if so, what string to use as tableGroupID for cross-table alignment. // By default, the tableGroupID is just the first key in the first row. // (We might extend the tableGroupID heuristic later, perhaps to also include the last key we saw on the path here, etc). -func peekMightBeTable(ctx *state, n ipld.Node) (bool, tableGroupID) { +func peekMightBeTable(ctx *state, n datamodel.Node) (bool, tableGroupID) { // FUTURE: might need to apply a selector or other rules from ctx.cfg to say additonal "no"s. // FUTURE: the ctx.cfg can also override what the tableGroupID is. switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: // TODO: maps can definitely be tables! but gonna come back to this. and by default, they're not. return false, "" - case ipld.Kind_List: + case datamodel.Kind_List: if n.Length() < 1 { return false, "" } n0, _ := n.LookupByIndex(0) - if n0.Kind() != ipld.Kind_Map { + if n0.Kind() != datamodel.Kind_Map { return false, "" } if n0.Length() < 1 { @@ -226,11 +226,11 @@ func peekMightBeTable(ctx *state, n ipld.Node) (bool, tableGroupID) { // Applies itself and other stride functions recursively (have to, because: // some row values might themselves be tables, // which removes them from the column flow and changes our size counting). -func stride(ctx *state, n ipld.Node) error { +func stride(ctx *state, n datamodel.Node) error { switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: panic("todo") - case ipld.Kind_List: + case datamodel.Kind_List: return strideList(ctx, n) default: // There's never anything we need to record for scalars that their parents don't already note. @@ -238,7 +238,7 @@ func stride(ctx *state, n ipld.Node) error { } } -func strideList(ctx *state, listNode ipld.Node) error { +func strideList(ctx *state, listNode datamodel.Node) error { isTable, tgid := peekMightBeTable(ctx, listNode) if !isTable { return nil @@ -281,11 +281,11 @@ func strideList(ctx *state, listNode ipld.Node) error { return nil } -func marshal(ctx *state, n ipld.Node, w io.Writer) error { +func marshal(ctx *state, n datamodel.Node, w io.Writer) error { switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: panic("todo") - case ipld.Kind_List: + case datamodel.Kind_List: return marshalList(ctx, n, w) default: return marshalPlain(ctx, n, w) @@ -295,7 +295,7 @@ func marshal(ctx *state, n ipld.Node, w io.Writer) error { // this function is probably a placeholder. // It doesn't colorize or anything else. To replace it with something clever that does, // we'll have to tear deeper into the plumbing level of json serializers; will, but later. -func marshalPlain(ctx *state, n ipld.Node, w io.Writer) error { +func marshalPlain(ctx *state, n datamodel.Node, w io.Writer) error { err := dagjson.Encode(n, w) // never indent here: these values will always end up being emitted mid-line. if err != nil { return recordErrorPosition(ctx, err) @@ -303,7 +303,7 @@ func marshalPlain(ctx *state, n ipld.Node, w io.Writer) error { return nil } -func marshalList(ctx *state, listNode ipld.Node, w io.Writer) error { +func marshalList(ctx *state, listNode datamodel.Node, w io.Writer) error { isTab, tgid := peekMightBeTable(ctx, listNode) if !isTab { return marshalPlain(ctx, listNode, w) @@ -331,8 +331,8 @@ func marshalList(ctx *state, listNode ipld.Node, w io.Writer) error { w.Write([]byte{']'}) return nil } -func marshalListValue(ctx *state, tab *table, row ipld.Node, w io.Writer) error { - if row.Kind() != ipld.Kind_Map { +func marshalListValue(ctx *state, tab *table, row datamodel.Node, w io.Writer) error { + if row.Kind() != datamodel.Kind_Map { // TODO make this a lot more open... scalars aren't exactly "rows" for example but we can surely print them just fine. panic("table rows can only be maps at present") } @@ -463,7 +463,7 @@ func marshalListValue(ctx *state, tab *table, row ipld.Node, w io.Writer) error return nil } -func emitKey(ctx *state, k ipld.Node, w io.Writer) error { +func emitKey(ctx *state, k datamodel.Node, w io.Writer) error { if ctx.cfg.Color.Enabled { w.Write(ctx.cfg.Color.KeyHighlight) } diff --git a/codec/jst/jst_test.go b/codec/jst/jst_test.go index d17c45fe..085fe8e7 100644 --- a/codec/jst/jst_test.go +++ b/codec/jst/jst_test.go @@ -8,7 +8,7 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipld/go-ipld-prime/codec/dagjson" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestSimple(t *testing.T) { diff --git a/codec/jst/util.go b/codec/jst/util.go index febab16b..afd7580d 100644 --- a/codec/jst/util.go +++ b/codec/jst/util.go @@ -4,7 +4,7 @@ import ( "fmt" "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) func max(a, b int) int { // honestly golang @@ -14,7 +14,7 @@ func max(a, b int) int { // honestly golang return b } -func mustFirstKeyAsString(mapNode ipld.Node) string { +func mustFirstKeyAsString(mapNode datamodel.Node) string { itr := mapNode.MapIterator() k, _, err := itr.Next() if err != nil { @@ -37,7 +37,7 @@ func indexOf(list []columnName, cn columnName) int { } type codecAborted struct { - p ipld.Path + p datamodel.Path e error } @@ -50,7 +50,7 @@ func (e codecAborted) Error() string { // a better system might also count byte and line offsets in the serial form (but this would require also integrating with the serial code pretty closely). // a spectacularly general system might be ready to count serial offsets *twice* *or* path offsets *twice* (but this is simply waiting for someone's enthusiasm). func recordErrorPosition(ctx *state, e error) error { - return codecAborted{ipld.Path{ /*TODO*/ }, e} + return codecAborted{datamodel.Path{ /*TODO*/ }, e} } // not yet used, but you'd probably want this for better error position purposes. diff --git a/codec/marshal.go b/codec/marshal.go deleted file mode 100644 index 4dc9f846..00000000 --- a/codec/marshal.go +++ /dev/null @@ -1,140 +0,0 @@ -package codec - -import ( - "fmt" - - "github.com/polydawn/refmt/shared" - "github.com/polydawn/refmt/tok" - - ipld "github.com/ipld/go-ipld-prime" -) - -// Future work: we would like to remove the Marshal function, -// and in particular, stop seeing types from refmt (like shared.TokenSink) be visible. - -// Marshal is a deprecated function. -// Please consider switching to one of the Encode functions of one of the subpackages instead. -// -// Marshal provides a very general node-to-tokens marshalling feature. -// It can handle either cbor or json by being combined with a refmt TokenSink. -// -// It is valid for all the data model types except links, which are only -// supported if the nodes are typed and provide additional information -// to clarify how links should be encoded through their type info. -// (The dag-cbor and dag-json formats can be used if links are of CID -// implementation and need to be encoded in a schemafree way.) -func Marshal(n ipld.Node, sink shared.TokenSink) error { - var tk tok.Token - return marshal(n, &tk, sink) -} - -func marshal(n ipld.Node, tk *tok.Token, sink shared.TokenSink) error { - switch n.Kind() { - case ipld.Kind_Invalid: - return fmt.Errorf("cannot traverse a node that is absent") - case ipld.Kind_Null: - tk.Type = tok.TNull - _, err := sink.Step(tk) - return err - case ipld.Kind_Map: - // Emit start of map. - tk.Type = tok.TMapOpen - tk.Length = int(n.Length()) // TODO: overflow check - if _, err := sink.Step(tk); err != nil { - return err - } - // Emit map contents (and recurse). - for itr := n.MapIterator(); !itr.Done(); { - k, v, err := itr.Next() - if err != nil { - return err - } - tk.Type = tok.TString - tk.Str, err = k.AsString() - if err != nil { - return err - } - if _, err := sink.Step(tk); err != nil { - return err - } - if err := marshal(v, tk, sink); err != nil { - return err - } - } - // Emit map close. - tk.Type = tok.TMapClose - _, err := sink.Step(tk) - return err - case ipld.Kind_List: - // Emit start of list. - tk.Type = tok.TArrOpen - l := n.Length() - tk.Length = int(l) // TODO: overflow check - if _, err := sink.Step(tk); err != nil { - return err - } - // Emit list contents (and recurse). - for i := int64(0); i < l; i++ { - v, err := n.LookupByIndex(i) - if err != nil { - return err - } - if err := marshal(v, tk, sink); err != nil { - return err - } - } - // Emit list close. - tk.Type = tok.TArrClose - _, err := sink.Step(tk) - return err - case ipld.Kind_Bool: - v, err := n.AsBool() - if err != nil { - return err - } - tk.Type = tok.TBool - tk.Bool = v - _, err = sink.Step(tk) - return err - case ipld.Kind_Int: - v, err := n.AsInt() - if err != nil { - return err - } - tk.Type = tok.TInt - tk.Int = int64(v) - _, err = sink.Step(tk) - return err - case ipld.Kind_Float: - v, err := n.AsFloat() - if err != nil { - return err - } - tk.Type = tok.TFloat64 - tk.Float64 = v - _, err = sink.Step(tk) - return err - case ipld.Kind_String: - v, err := n.AsString() - if err != nil { - return err - } - tk.Type = tok.TString - tk.Str = v - _, err = sink.Step(tk) - return err - case ipld.Kind_Bytes: - v, err := n.AsBytes() - if err != nil { - return err - } - tk.Type = tok.TBytes - tk.Bytes = v - _, err = sink.Step(tk) - return err - case ipld.Kind_Link: - return fmt.Errorf("link emission not supported by this codec without a schema! (maybe you want dag-cbor or dag-json)") - default: - panic("unreachable") - } -} diff --git a/codec/raw/codec.go b/codec/raw/codec.go index 1cb41daf..4eb00420 100644 --- a/codec/raw/codec.go +++ b/codec/raw/codec.go @@ -3,7 +3,7 @@ // // The codec can be used with any node which supports AsBytes and AssignBytes. // In general, it only makes sense to use this codec on a plain "bytes" node -// such as github.com/ipld/go-ipld-prime/node/basic.Prototype.Bytes. +// such as github.com/ipld/go-ipld-prime/node/basicnode.Prototype.Bytes. package raw import ( @@ -11,16 +11,17 @@ import ( "io" "io/ioutil" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/multicodec" ) -// TODO(mvdan): make go-ipld-prime use go-multicodec soon +// TODO(mvdan): make go-ipld use go-multicodec soon const rawMulticodec = 0x55 var ( - _ ipld.Decoder = Decode - _ ipld.Encoder = Encode + _ codec.Decoder = Decode + _ codec.Encoder = Encode ) func init() { @@ -40,7 +41,7 @@ func init() { // with an io.Reader: // // Decode([...], struct{io.Reader}{buf}) -func Decode(am ipld.NodeAssembler, r io.Reader) error { +func Decode(am datamodel.NodeAssembler, r io.Reader) error { var data []byte if buf, ok := r.(interface{ Bytes() []byte }); ok { data = buf.Bytes() @@ -58,7 +59,7 @@ func Decode(am ipld.NodeAssembler, r io.Reader) error { // // Note that Encode won't copy the node's bytes as returned by AsBytes, but the // call to Write will typically have to copy the bytes anyway. -func Encode(node ipld.Node, w io.Writer) error { +func Encode(node datamodel.Node, w io.Writer) error { data, err := node.AsBytes() if err != nil { return err diff --git a/codec/raw/codec_test.go b/codec/raw/codec_test.go index 215c8ea9..1403d2e9 100644 --- a/codec/raw/codec_test.go +++ b/codec/raw/codec_test.go @@ -8,9 +8,10 @@ import ( qt "github.com/frankban/quicktest" "github.com/ipfs/go-cid" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) var tests = []struct { @@ -58,17 +59,17 @@ func TestRoundtripCidlink(t *testing.T) { lsys := cidlink.DefaultLinkSystem() buf := bytes.Buffer{} - lsys.StorageWriteOpener = func(lnkCtx ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error) { - return &buf, func(lnk ipld.Link) error { return nil }, nil + lsys.StorageWriteOpener = func(lnkCtx linking.LinkContext) (io.Writer, linking.BlockWriteCommitter, error) { + return &buf, func(lnk datamodel.Link) error { return nil }, nil } - lsys.StorageReadOpener = func(lnkCtx ipld.LinkContext, lnk ipld.Link) (io.Reader, error) { + lsys.StorageReadOpener = func(lnkCtx linking.LinkContext, lnk datamodel.Link) (io.Reader, error) { return bytes.NewReader(buf.Bytes()), nil } - lnk, err := lsys.Store(ipld.LinkContext{}, lp, node) + lnk, err := lsys.Store(linking.LinkContext{}, lp, node) qt.Assert(t, err, qt.IsNil) - newNode, err := lsys.Load(ipld.LinkContext{}, lnk, basicnode.Prototype__Any{}) + newNode, err := lsys.Load(linking.LinkContext{}, lnk, basicnode.Prototype.Any) qt.Assert(t, err, qt.IsNil) qt.Assert(t, newNode, qt.DeepEquals, node) } diff --git a/codec/unmarshal.go b/codec/unmarshal.go deleted file mode 100644 index 99d4cc3f..00000000 --- a/codec/unmarshal.go +++ /dev/null @@ -1,158 +0,0 @@ -package codec - -import ( - "fmt" - "math" - - "github.com/polydawn/refmt/shared" - "github.com/polydawn/refmt/tok" - - ipld "github.com/ipld/go-ipld-prime" -) - -// Future work: we would like to remove the Unmarshal function, -// and in particular, stop seeing types from refmt (like shared.TokenSource) be visible. - -// wishlist: if we could reconstruct the ipld.Path of an error while -// *unwinding* from that error... that'd be nice. -// (trying to build it proactively would waste tons of allocs on the happy path.) -// we can do this; it just requires well-typed errors and a bunch of work. - -// Tests for all this are in the ipld.Node impl tests! -// They're effectively doing double duty: testing the builders, too. -// (Is that sensible? Should it be refactored? Not sure; maybe!) - -// Unmarshal is a deprecated function. -// Please consider switching to one of the Decode functions of one of the subpackages instead. -// -// Unmarshal provides a very general tokens-to-node unmarshalling feature. -// It can handle either cbor or json by being combined with a refmt TokenSink. -// -// The unmarshalled data is fed to the given NodeAssembler, which accumulates it; -// at the end, any error is returned from the Unmarshal method, -// and the user can pick up the finished Node from wherever their assembler has it. -// Typical usage might look like the following: -// -// nb := basicnode.Prototype__Any{}.NewBuilder() -// err := codec.Unmarshal(nb, json.Decoder(reader)) -// n := nb.Build() -// -// It is valid for all the data model types except links, which are only -// supported if the nodes are typed and provide additional information -// to clarify how links should be decoded through their type info. -// (The dag-cbor and dag-json formats can be used if links are of CID -// implementation and need to be decoded in a schemafree way.) -func Unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource) error { - var tk tok.Token - done, err := tokSrc.Step(&tk) - if err != nil { - return err - } - if done && !tk.Type.IsValue() { - return fmt.Errorf("unexpected eof") - } - return unmarshal(na, tokSrc, &tk) -} - -// starts with the first token already primed. Necessary to get recursion -// to flow right without a peek+unpeek system. -func unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource, tk *tok.Token) error { - // FUTURE: check for schema.TypedNodeBuilder that's going to parse a Link (they can slurp any token kind they want). - switch tk.Type { - case tok.TMapOpen: - expectLen := tk.Length - allocLen := tk.Length - if tk.Length == -1 { - expectLen = math.MaxInt32 - allocLen = 0 - } - ma, err := na.BeginMap(int64(allocLen)) - if err != nil { - return err - } - observedLen := 0 - for { - _, err := tokSrc.Step(tk) - if err != nil { - return err - } - switch tk.Type { - case tok.TMapClose: - if expectLen != math.MaxInt32 && observedLen != expectLen { - return fmt.Errorf("unexpected mapClose before declared length") - } - return ma.Finish() - case tok.TString: - // continue - default: - return fmt.Errorf("unexpected %s token while expecting map key", tk.Type) - } - observedLen++ - if observedLen > expectLen { - return fmt.Errorf("unexpected continuation of map elements beyond declared length") - } - mva, err := ma.AssembleEntry(tk.Str) - if err != nil { // return in error if the key was rejected - return err - } - err = Unmarshal(mva, tokSrc) - if err != nil { // return in error if some part of the recursion errored - return err - } - } - case tok.TMapClose: - return fmt.Errorf("unexpected mapClose token") - case tok.TArrOpen: - expectLen := tk.Length - allocLen := tk.Length - if tk.Length == -1 { - expectLen = math.MaxInt32 - allocLen = 0 - } - la, err := na.BeginList(int64(allocLen)) - if err != nil { - return err - } - observedLen := 0 - for { - _, err := tokSrc.Step(tk) - if err != nil { - return err - } - switch tk.Type { - case tok.TArrClose: - if expectLen != math.MaxInt32 && observedLen != expectLen { - return fmt.Errorf("unexpected arrClose before declared length") - } - return la.Finish() - default: - observedLen++ - if observedLen > expectLen { - return fmt.Errorf("unexpected continuation of array elements beyond declared length") - } - err := unmarshal(la.AssembleValue(), tokSrc, tk) - if err != nil { // return in error if some part of the recursion errored - return err - } - } - } - case tok.TArrClose: - return fmt.Errorf("unexpected arrClose token") - case tok.TNull: - return na.AssignNull() - case tok.TString: - return na.AssignString(tk.Str) - case tok.TBytes: - return na.AssignBytes(tk.Bytes) - case tok.TBool: - return na.AssignBool(tk.Bool) - case tok.TInt: - return na.AssignInt(tk.Int) - case tok.TUint: - return na.AssignInt(int64(tk.Uint)) // FIXME overflow check - case tok.TFloat64: - return na.AssignFloat(tk.Float64) - default: - panic("unreachable") - } -} diff --git a/datamodel.go b/datamodel.go new file mode 100644 index 00000000..888114e9 --- /dev/null +++ b/datamodel.go @@ -0,0 +1,114 @@ +package ipld + +import ( + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" + "github.com/ipld/go-ipld-prime/schema" +) + +type ( + Kind = datamodel.Kind + Node = datamodel.Node + NodeAssembler = datamodel.NodeAssembler + NodeBuilder = datamodel.NodeBuilder + NodePrototype = datamodel.NodePrototype + MapIterator = datamodel.MapIterator + MapAssembler = datamodel.MapAssembler + ListIterator = datamodel.ListIterator + ListAssembler = datamodel.ListAssembler + + Link = datamodel.Link + LinkPrototype = datamodel.LinkPrototype + + Path = datamodel.Path + PathSegment = datamodel.PathSegment +) + +var ( + Null = datamodel.Null + Absent = datamodel.Absent +) + +const ( + Kind_Invalid = datamodel.Kind_Invalid + Kind_Map = datamodel.Kind_Map + Kind_List = datamodel.Kind_List + Kind_Null = datamodel.Kind_Null + Kind_Bool = datamodel.Kind_Bool + Kind_Int = datamodel.Kind_Int + Kind_Float = datamodel.Kind_Float + Kind_String = datamodel.Kind_String + Kind_Bytes = datamodel.Kind_Bytes + Kind_Link = datamodel.Kind_Link +) + +// Future: These aliases for the `KindSet_*` values may be dropped someday. +// I don't think they're very important to have cluttering up namespace here. +// They're included for a brief transitional period, largely for the sake of codegen things which have referred to them, but may disappear in the future. +var ( + KindSet_Recursive = datamodel.KindSet_Recursive + KindSet_Scalar = datamodel.KindSet_Scalar + KindSet_JustMap = datamodel.KindSet_JustMap + KindSet_JustList = datamodel.KindSet_JustList + KindSet_JustNull = datamodel.KindSet_JustNull + KindSet_JustBool = datamodel.KindSet_JustBool + KindSet_JustInt = datamodel.KindSet_JustInt + KindSet_JustFloat = datamodel.KindSet_JustFloat + KindSet_JustString = datamodel.KindSet_JustString + KindSet_JustBytes = datamodel.KindSet_JustBytes + KindSet_JustLink = datamodel.KindSet_JustLink +) + +// Future: These error type aliases may be dropped someday. +// Being able to see them as having more than one package name is not helpful to clarity. +// They are left here for now for a brief transitional period, because it was relatively easy to do so. +type ( + ErrWrongKind = datamodel.ErrWrongKind + ErrNotExists = datamodel.ErrNotExists + ErrRepeatedMapKey = datamodel.ErrRepeatedMapKey + ErrInvalidSegmentForList = datamodel.ErrInvalidSegmentForList + ErrIteratorOverread = datamodel.ErrIteratorOverread + ErrInvalidKey = schema.ErrInvalidKey + ErrMissingRequiredField = schema.ErrMissingRequiredField + ErrHashMismatch = linking.ErrHashMismatch +) + +// Future: a bunch of these alias methods for path creation may be dropped someday. +// They don't hurt anything, but I don't think they add much clarity either, vs the amount of namespace noise they create; +// many of the high level convenience functions we add here in the root package will probably refer to datamodel.Path, and that should be sufficient to create clarity for new users for where to look for more on pathing. +// They are here for now for a transitional period, but may eventually be revisited and perhaps removed. + +// NewPath is an alias for datamodel.NewPath. +// +// Pathing is a concept defined in the data model layer of IPLD. +func NewPath(segments []PathSegment) Path { + return datamodel.NewPath(segments) +} + +// ParsePath is an alias for datamodel.ParsePath. +// +// Pathing is a concept defined in the data model layer of IPLD. +func ParsePath(pth string) Path { + return datamodel.ParsePath(pth) +} + +// ParsePathSegment is an alias for datamodel.ParsePathSegment. +// +// Pathing is a concept defined in the data model layer of IPLD. +func ParsePathSegment(s string) PathSegment { + return datamodel.ParsePathSegment(s) +} + +// PathSegmentOfString is an alias for datamodel.PathSegmentOfString. +// +// Pathing is a concept defined in the data model layer of IPLD. +func PathSegmentOfString(s string) PathSegment { + return datamodel.PathSegmentOfString(s) +} + +// PathSegmentOfInt is an alias for datamodel.PathSegmentOfInt. +// +// Pathing is a concept defined in the data model layer of IPLD. +func PathSegmentOfInt(i int64) PathSegment { + return datamodel.PathSegmentOfInt(i) +} diff --git a/datamodel/doc.go b/datamodel/doc.go new file mode 100644 index 00000000..c37021e3 --- /dev/null +++ b/datamodel/doc.go @@ -0,0 +1,14 @@ +// The datamodel package defines the most essential interfaces for describing IPLD Data -- +// such as Node, NodePrototype, NodeBuilder, Link, and Path. +// +// Note that since interfaces in this package are the core of the library, +// choices made here maximize correctness and performance -- these choices +// are *not* always the choices that would maximize ergonomics. +// (Ergonomics can come on top; performance generally can't.) +// You'll want to check out other packages for functions with more ergonomics; +// for example, 'fluent' and its subpackages provide lots of ways to work with data; +// 'traversal' provides some ergonomic features for walking around data graphs; +// any use of schemas will provide a bunch of useful data validation options; +// or you can make your own function decorators that do what *you* need. +// +package datamodel diff --git a/equal.go b/datamodel/equal.go similarity index 99% rename from equal.go rename to datamodel/equal.go index c16ce73e..2ad05f29 100644 --- a/equal.go +++ b/datamodel/equal.go @@ -1,4 +1,4 @@ -package ipld +package datamodel // DeepEqual reports whether x and y are "deeply equal" as IPLD nodes. // This is similar to reflect.DeepEqual, but based around the Node interface. diff --git a/equal_test.go b/datamodel/equal_test.go similarity index 68% rename from equal_test.go rename to datamodel/equal_test.go index 61ed2b03..7750aece 100644 --- a/equal_test.go +++ b/datamodel/equal_test.go @@ -1,28 +1,28 @@ -package ipld_test +package datamodel_test import ( "testing" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent/qp" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basic "github.com/ipld/go-ipld-prime/node/basic" // shorter name for the tests + basic "github.com/ipld/go-ipld-prime/node/basicnode" // shorter name for the tests ) var ( globalNode = basic.NewString("global") - globalLink = func() ipld.Link { + globalLink = func() datamodel.Link { someCid, _ := cid.Cast([]byte{1, 85, 0, 5, 0, 1, 2, 3, 4}) return cidlink.Link{Cid: someCid} }() - globalLink2 = func() ipld.Link { + globalLink2 = func() datamodel.Link { someCid, _ := cid.Cast([]byte{1, 85, 0, 5, 0, 5, 6, 7, 8}) return cidlink.Link{Cid: someCid} }() ) -func qpMust(node ipld.Node, err error) ipld.Node { +func qpMust(node datamodel.Node, err error) datamodel.Node { if err != nil { panic(err) } @@ -31,7 +31,7 @@ func qpMust(node ipld.Node, err error) ipld.Node { var deepEqualTests = []struct { name string - left, right ipld.Node + left, right datamodel.Node want bool }{ {"MismatchingKinds", basic.NewBool(true), basic.NewInt(3), false}, @@ -40,8 +40,8 @@ var deepEqualTests = []struct { // Repeated basicnode.New invocations might return different pointers. {"SameNodeDiffPointer", basic.NewString("same"), basic.NewString("same"), true}, - {"SameKindNull", ipld.Null, ipld.Null, true}, - {"DiffKindNull", ipld.Null, ipld.Absent, false}, + {"SameKindNull", datamodel.Null, datamodel.Null, true}, + {"DiffKindNull", datamodel.Null, datamodel.Absent, false}, {"SameKindBool", basic.NewBool(true), basic.NewBool(true), true}, {"DiffKindBool", basic.NewBool(true), basic.NewBool(false), false}, {"SameKindInt", basic.NewInt(12), basic.NewInt(12), true}, @@ -57,11 +57,11 @@ var deepEqualTests = []struct { { "SameKindList", - qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am ipld.ListAssembler) { + qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am datamodel.ListAssembler) { qp.ListEntry(am, qp.Int(7)) qp.ListEntry(am, qp.Int(8)) })), - qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am ipld.ListAssembler) { + qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am datamodel.ListAssembler) { qp.ListEntry(am, qp.Int(7)) qp.ListEntry(am, qp.Int(8)) })), @@ -69,22 +69,22 @@ var deepEqualTests = []struct { }, { "DiffKindList_length", - qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am ipld.ListAssembler) { + qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am datamodel.ListAssembler) { qp.ListEntry(am, qp.Int(7)) qp.ListEntry(am, qp.Int(8)) })), - qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am ipld.ListAssembler) { + qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am datamodel.ListAssembler) { qp.ListEntry(am, qp.Int(7)) })), false, }, { "DiffKindList_elems", - qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am ipld.ListAssembler) { + qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am datamodel.ListAssembler) { qp.ListEntry(am, qp.Int(7)) qp.ListEntry(am, qp.Int(8)) })), - qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am ipld.ListAssembler) { + qpMust(qp.BuildList(basic.Prototype.Any, -1, func(am datamodel.ListAssembler) { qp.ListEntry(am, qp.Int(3)) qp.ListEntry(am, qp.Int(2)) })), @@ -93,11 +93,11 @@ var deepEqualTests = []struct { { "SameKindMap", - qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am ipld.MapAssembler) { + qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am datamodel.MapAssembler) { qp.MapEntry(am, "foo", qp.Int(7)) qp.MapEntry(am, "bar", qp.Int(8)) })), - qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am ipld.MapAssembler) { + qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am datamodel.MapAssembler) { qp.MapEntry(am, "foo", qp.Int(7)) qp.MapEntry(am, "bar", qp.Int(8)) })), @@ -105,22 +105,22 @@ var deepEqualTests = []struct { }, { "DiffKindMap_length", - qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am ipld.MapAssembler) { + qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am datamodel.MapAssembler) { qp.MapEntry(am, "foo", qp.Int(7)) qp.MapEntry(am, "bar", qp.Int(8)) })), - qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am ipld.MapAssembler) { + qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am datamodel.MapAssembler) { qp.MapEntry(am, "foo", qp.Int(7)) })), false, }, { "DiffKindMap_elems", - qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am ipld.MapAssembler) { + qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am datamodel.MapAssembler) { qp.MapEntry(am, "foo", qp.Int(7)) qp.MapEntry(am, "bar", qp.Int(8)) })), - qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am ipld.MapAssembler) { + qpMust(qp.BuildMap(basic.Prototype.Any, -1, func(am datamodel.MapAssembler) { qp.MapEntry(am, "foo", qp.Int(3)) qp.MapEntry(am, "baz", qp.Int(8)) })), @@ -138,7 +138,7 @@ func TestDeepEqual(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() - got := ipld.DeepEqual(tc.left, tc.right) + got := datamodel.DeepEqual(tc.left, tc.right) if got != tc.want { t.Fatalf("DeepEqual got %v, want %v", got, tc.want) } diff --git a/errors.go b/datamodel/errors.go similarity index 50% rename from errors.go rename to datamodel/errors.go index 2376d94b..037ad390 100644 --- a/errors.go +++ b/datamodel/errors.go @@ -1,8 +1,7 @@ -package ipld +package datamodel import ( "fmt" - "strings" ) // ErrWrongKind may be returned from functions on the Node interface when @@ -41,6 +40,8 @@ func (e ErrWrongKind) Error() string { } } +// TODO: revisit the claim below about ErrNoSuchField. I think we moved back away from that, or want to. + // ErrNotExists may be returned from the lookup functions of the Node interface // to indicate a missing value. // @@ -71,35 +72,6 @@ func (e ErrRepeatedMapKey) Error() string { return fmt.Sprintf("cannot repeat map key %q", e.Key) } -// ErrInvalidKey indicates a key is invalid for some reason. -// -// This is only possible for typed nodes; specifically, it may show up when -// handling struct types, or maps with interesting key types. -// (Other kinds of key invalidity that happen for untyped maps -// fall under ErrRepeatedMapKey or ErrWrongKind.) -// (Union types use ErrInvalidUnionDiscriminant instead of ErrInvalidKey, -// even when their representation strategy is maplike.) -type ErrInvalidKey struct { - // TypeName will indicate the named type of a node the function was called on. - TypeName string - - // Key is the key that was rejected. - Key Node - - // Reason, if set, may provide details (for example, the reason a key couldn't be converted to a type). - // If absent, it'll be presumed "no such field". - // ErrUnmatchable may show up as a reason for typed maps with complex keys. - Reason error -} - -func (e ErrInvalidKey) Error() string { - if e.Reason == nil { - return fmt.Sprintf("invalid key for map %s: %q: no such field", e.TypeName, e.Key) - } else { - return fmt.Sprintf("invalid key for map %s: %q: %s", e.TypeName, e.Key, e.Reason) - } -} - // ErrInvalidSegmentForList is returned when using Node.LookupBySegment and the // given PathSegment can't be applied to a list because it's unparsable as a number. type ErrInvalidSegmentForList struct { @@ -123,44 +95,6 @@ func (e ErrInvalidSegmentForList) Error() string { return v + fmt.Sprintf(": %q: %s", e.TroubleSegment.s, e.Reason) } -// ErrHashMismatch is the error returned when loading data and verifying its hash -// and finding that the loaded data doesn't re-hash to the expected value. -// It is typically seen returned by functions like LinkSystem.Load or LinkSystem.Fill. -type ErrHashMismatch struct { - Actual Link - Expected Link -} - -func (e ErrHashMismatch) Error() string { - return fmt.Sprintf("hash mismatch! %v (actual) != %v (expected)", e.Actual, e.Expected) -} - -// ErrUnmatchable is the error raised when processing data with IPLD Schemas and -// finding data which cannot be matched into the schema. -// It will be returned by NodeAssemblers and NodeBuilders when they are fed unmatchable data. -// As a result, it will also often be seen returned from unmarshalling -// when unmarshalling into schema-constrained NodeAssemblers. -// -// ErrUnmatchable provides the name of the type in the schema that data couldn't be matched to, -// and wraps another error as the more detailed reason. -type ErrUnmatchable struct { - // TypeName will indicate the named type of a node the function was called on. - TypeName string - - // Reason must always be present. ErrUnmatchable doesn't say much otherwise. - Reason error -} - -func (e ErrUnmatchable) Error() string { - return fmt.Sprintf("matching data to schema of %s rejected: %s", e.TypeName, e.Reason) -} - -// Reasonf returns a new ErrUnmatchable with a Reason field set to the Errorf of the arguments. -// It's a helper function for creating untyped error reasons without importing the fmt package. -func (e ErrUnmatchable) Reasonf(format string, a ...interface{}) ErrUnmatchable { - return ErrUnmatchable{e.TypeName, fmt.Errorf(format, a...)} -} - // ErrIteratorOverread is returned when calling 'Next' on a MapIterator or // ListIterator when it is already done. type ErrIteratorOverread struct{} @@ -168,18 +102,3 @@ type ErrIteratorOverread struct{} func (e ErrIteratorOverread) Error() string { return "iterator overread" } - -type ErrCannotBeNull struct{} // Review: arguably either ErrInvalidKindForNodePrototype. - -// ErrMissingRequiredField is returned when calling 'Finish' on a NodeAssembler -// for a Struct that has not has all required fields set. -type ErrMissingRequiredField struct { - Missing []string -} - -func (e ErrMissingRequiredField) Error() string { - return "missing required fields: " + strings.Join(e.Missing, ",") -} - -type ErrListOverrun struct{} // only possible for typed nodes -- specifically, struct types with list (aka tuple) representations. -type ErrInvalidUnionDiscriminant struct{} // only possible for typed nodes -- specifically, union types. diff --git a/kind.go b/datamodel/kind.go similarity index 99% rename from kind.go rename to datamodel/kind.go index 3e5e1af3..567d6022 100644 --- a/kind.go +++ b/datamodel/kind.go @@ -1,4 +1,4 @@ -package ipld +package datamodel // Kind represents the primitive kind in the IPLD data model. // All of these kinds map directly onto serializable data. diff --git a/link.go b/datamodel/link.go similarity index 59% rename from link.go rename to datamodel/link.go index 104fbbd0..e1c193a4 100644 --- a/link.go +++ b/datamodel/link.go @@ -1,8 +1,4 @@ -package ipld - -import ( - "context" -) +package datamodel // Link is a special kind of value in IPLD which can be "loaded" to access more nodes. // @@ -13,7 +9,7 @@ import ( // but when "loaded", the result can be any other IPLD kind: // maps, lists, strings, etc. // -// Link is an interface in the go-ipld-prime implementation, +// Link is an interface in the go-ipld implementation, // but the most common instantiation of it comes from the `linking/cid` package, // and represents CIDs (see https://github.com/multiformats/cid). // @@ -43,7 +39,7 @@ type Link interface { // LinkPrototype encapsulates any implementation details and parameters // necessary for creating a Link, expect for the hash result itself. // -// LinkPrototype, like Link, is an interface in go-ipld-prime, +// LinkPrototype, like Link, is an interface in go-ipld, // but the most common instantiation of it comes from the `linking/cid` package, // and represents CIDs (see https://github.com/multiformats/cid). // If using CIDs as an implementation, LinkPrototype will encapsulate information @@ -57,43 +53,3 @@ type LinkPrototype interface { // The hashsum reference must not be retained (the caller is free to reuse it). BuildLink(hashsum []byte) Link } - -// LinkContext is a structure carrying ancilary information that may be used -// while loading or storing data -- see its usage in BlockReadOpener, BlockWriteOpener, -// and in the methods on LinkSystem which handle loading and storing data. -// -// A zero value for LinkContext is generally acceptable in any functions that use it. -// In this case, any operations that need a Context will use Context.Background -// (thus being uncancellable) and simply have no additional information to work with. -type LinkContext struct { - // Ctx is the familiar golang Context pattern. - // Use this for cancellation, or attaching additional info - // (for example, perhaps to pass auth tokens through to the storage functions). - Ctx context.Context - - // Path where the link was encountered. May be zero. - // - // Functions in the traversal package will set this automatically. - LinkPath Path - - // When traversing data or encoding: the Node containing the link -- - // it may have additional type info, etc, that can be accessed. - // When building / decoding: not present. - // - // Functions in the traversal package will set this automatically. - LinkNode Node - - // When building data or decoding: the NodeAssembler that will be receiving the link -- - // it may have additional type info, etc, that can be accessed. - // When traversing / encoding: not present. - // - // Functions in the traversal package will set this automatically. - LinkNodeAssembler NodeAssembler - - // Parent of the LinkNode. May be zero. - // - // Functions in the traversal package will set this automatically. - ParentNode Node - - // REVIEW: ParentNode in LinkContext -- so far, this has only ever been hypothetically useful. Keep or drop? -} diff --git a/node.go b/datamodel/node.go similarity index 96% rename from node.go rename to datamodel/node.go index 0c3ddf87..600dc25d 100644 --- a/node.go +++ b/datamodel/node.go @@ -1,4 +1,4 @@ -package ipld +package datamodel // Node represents a value in IPLD. Any point in a tree of data is a node: // scalar values (like int64, string, etc) are nodes, and @@ -41,7 +41,7 @@ package ipld // // For concrete implementations of Node, check out the "./node/" folder, // and the packages within it. -// "node/basic" should probably be your first start; the Node and NodeBuilder +// "node/basicnode" should probably be your first start; the Node and NodeBuilder // implementations in that package work for any data. // Other packages are optimized for specific use-cases. // Codegen tools can also be used to produce concrete implementations of Node; @@ -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. // diff --git a/nodeBuilder.go b/datamodel/nodeBuilder.go similarity index 99% rename from nodeBuilder.go rename to datamodel/nodeBuilder.go index 7b197ccf..c29bea1c 100644 --- a/nodeBuilder.go +++ b/datamodel/nodeBuilder.go @@ -1,4 +1,4 @@ -package ipld +package datamodel // NodeAssembler is the interface that describes all the ways we can set values // in a node that's under construction. diff --git a/path.go b/datamodel/path.go similarity index 99% rename from path.go rename to datamodel/path.go index 9a49bdac..4dacc70d 100644 --- a/path.go +++ b/datamodel/path.go @@ -1,4 +1,4 @@ -package ipld +package datamodel import ( "strings" diff --git a/pathSegment.go b/datamodel/pathSegment.go similarity index 99% rename from pathSegment.go rename to datamodel/pathSegment.go index 94badb78..cd9bd890 100644 --- a/pathSegment.go +++ b/datamodel/pathSegment.go @@ -1,4 +1,4 @@ -package ipld +package datamodel import ( "strconv" diff --git a/path_test.go b/datamodel/path_test.go similarity index 98% rename from path_test.go rename to datamodel/path_test.go index ea7e7342..1e1e6121 100644 --- a/path_test.go +++ b/datamodel/path_test.go @@ -1,4 +1,4 @@ -package ipld +package datamodel import ( "testing" diff --git a/unit.go b/datamodel/unit.go similarity index 73% rename from unit.go rename to datamodel/unit.go index 8cc4647f..afc2e3e1 100644 --- a/unit.go +++ b/datamodel/unit.go @@ -1,5 +1,11 @@ -package ipld +package datamodel +// Null is the one kind of node we can have a true singleton implementation of. +// This is that value. +// The Null Node has Kind() == Kind_Null, returns IsNull() == true, +// returns ErrWrongKind to most other inquiries (as you'd expect), +// and returns a NodePrototype with a NewBuilder method that simply panics +// (because why would you ever try to build a new "null"?). var Null Node = nullNode{} type nullNode struct{} @@ -59,9 +65,26 @@ func (nullNode) Prototype() NodePrototype { type nullPrototype struct{} func (nullPrototype) NewBuilder() NodeBuilder { - panic("cannot build null nodes") // TODO: okay, fine, we could grind out a simple closing of the loop here. + panic("cannot build null nodes") } +// Absent is the _other_ kind of node (besides Null) we can have a true singleton implementation of. +// This is the singleton value for Absent. +// The Absent Node has Kind() == Kind_Null, returns IsNull() == false (!), +// returns IsAbsent() == true, +// returns ErrWrongKind to most other inquiries (as you'd expect), +// and returns a NodePrototype with a NewBuilder method that simply panics +// (because why would you ever try to build a new "nothing"?). +// +// Despite its presence in the datamodel package, "absent" is not really a data model concept. +// Absent should not really be seen in any datamodel Node implementations, for example. +// Absent is seen used in the realm of schemas and typed data, because there, +// there's a concept of data that has been described, and yet is not currently present; +// it is this concept that "absent" is used to express. +// Absent also sometimes shows up as a distinct case in codecs or other diagnostic printing, +// and suchlike miscellaneous places; it is for these reasons that it's here in the datamodel package, +// because it would end up imported somewhat universally for those diagnostic purposes anyway. +// (This may be worth a design review at some point, but holds up well enough for now.) var Absent Node = absentNode{} type absentNode struct{} @@ -121,5 +144,5 @@ func (absentNode) Prototype() NodePrototype { type absentPrototype struct{} func (absentPrototype) NewBuilder() NodeBuilder { - panic("cannot build absent nodes") // this definitely stays true. + panic("cannot build absent nodes") } diff --git a/doc.go b/doc.go index da07eef1..08633bce 100644 --- a/doc.go +++ b/doc.go @@ -1,11 +1,8 @@ // go-ipld-prime is a series of go interfaces for manipulating IPLD data. // -// See https://github.com/ipld/specs for more information about the basics +// See https://ipld.io/ for more information about the basics // of "What is IPLD?". // -// See https://github.com/ipld/go-ipld-prime/tree/master/doc/README.md -// for more documentation about go-ipld-prime's architecture and usage. -// // Here in the godoc, the first couple of types to look at should be: // // - Node @@ -43,30 +40,30 @@ // Methods on the LinkSystem then provide the functions typically used // to get data in and out of Nodes so you can work with it. // -// This root package only provides the essential interfaces, -// as well as a Path implementation, and a variety of error types. -// Most actual functionality is found in subpackages. +// This root package gathers some of the most important ease-of-use functions +// all in one place, but is mostly aliases out to features originally found +// in other more specific sub-packages. (If you're interested in keeping +// your binary sizes small, and don't use some of the features of this library, +// you'll probably want to look into using the relevant sub-packages directly.) // // Particularly interesting subpackages include: // -// - node/* -- various Node + NodeBuilder implementations -// - node/basic -- the first Node implementation you should try -// - codec/* -- functions for serializing and deserializing Nodes -// - linking/* -- various Link + LinkBuilder implementations -// - traversal -- functions for walking Node graphs (including -// automatic link loading) and visiting -// - must -- helpful functions for streamlining error handling -// - fluent -- alternative Node interfaces that flip errors to panics -// - schema -- interfaces for working with IPLD Schemas and Nodes -// which use Schema types and constraints -// -// Note that since interfaces in this package are the core of the library, -// choices made here maximize correctness and performance -- these choices -// are *not* always the choices that would maximize ergonomics. -// (Ergonomics can come on top; performance generally can't.) -// You can check out the 'must' or 'fluent' packages for more ergonomics; -// 'traversal' provides some ergnomics features for certain uses; -// any use of schemas with codegen tooling will provide more ergnomic options; -// or you can make your own function decorators that do what *you* need. +// - datamodel -- the most essential interfaces for describing data live here, +// describing Node, NodePrototype, NodeBuilder, Link, and Path. +// - node/* -- various Node + NodeBuilder implementations. +// - node/basicnode -- the first Node implementation you should try. +// - codec/* -- functions for serializing and deserializing Nodes. +// - linking -- the LinkSystem, which is a facade to all data loading and storing and hashing. +// - linking/* -- ways to bind concrete Link implementations (namely, +// the linking/cidlink package, which connects the go-cid library to our datamodel.Link interface). +// - traversal -- functions for walking Node graphs (including automatic link loading) +// and visiting them programmatically. +// - traversal/selector -- functions for working with IPLD Selectors, +// which are a language-agnostic declarative format for describing graph walks. +// - fluent/* -- various options for making datamodel Node and NodeBuilder easier to work with. +// - schema -- interfaces for working with IPLD Schemas, which can bring constraints +// and validation systems to otherwise schemaless and unstructured IPLD data. +// - adl/* -- examples of creating and using Advanced Data Layouts (in short, custom Node implementations) +// to do complex data structures transparently within the IPLD Data Model. // package ipld diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index bbd52736..00000000 --- a/doc/README.md +++ /dev/null @@ -1,29 +0,0 @@ -- [IPLD Big Picture](./big-picture.md) -- [Nodes](./nodes.md) - - [Node interface overview](./nodes.md#the-node-interface) - - [Node implementation diversity](./nodes.md#node-implementations) - - [how to use NodeBuilder](./nodes.md#using-nodebuilder) - - [intro to typed nodes](./nodes.md#typed-nodes) -- [using the fluent API](./fluent.md) -- operationals - - focus & paths - - traverse & selectors - - transform - - constructing other operations -- storing, loading, and linking - - encoding - - (this covers only cbor and json builtins) - - (brief description of how to build-your-own (either with refmt tokens or nodewalking)) - - cids are links - - linkloader and linkbuilder - - automatical link loading in operationals -- [IPLD Schemas](./schema.md) - - [Goals](./schema.md#goals) - - [Features](./schema.md#features) - - [Implementation](./schema.md#implementation) - - [Migration Techniques](./schema.md#schemas-and-migration) -- [Advanced Data Layouts](./advLayout.md) - ---- - -- [Development notes: on Node implementations](./dev/node-implementations.md) diff --git a/doc/advLayout.md b/doc/advLayout.md deleted file mode 100644 index 967c8465..00000000 --- a/doc/advLayout.md +++ /dev/null @@ -1,86 +0,0 @@ -Advanced Data Layouts -===================== - -// Note: Advanced Data Layouts are an open research topic at present. -// Comments here are speculative and subject to change as implementations emerge. - -IPLD Schemas may sometimes specify types which are annotated with an -Advanced Layout (for example, "HAMT"). -The advanced layout is a special value which must be known to the parsing program. -The syntax of such a type still indicates what essential kind it is (namely, -map or array (-- Future: bytes?)). - -For example: - -```ipldsch -type FancyMap map {String:String} -``` - -Types with an advanced layout are still manipulated with the semantics usual for -their essential kind (e.g. `{String:String}` is still fundamentally a map -and handled as such), but may be internally composed of a more structurally -complex layout of many nodes, and these nodes may even span multiple blocks -(connected by Links (CIDs)). - -Advanced Layouts allow data to be *sharded*, which allows extremely large -collections of data to be managed. By sharding large collections of data -across several blocks, it becomes possible to transport those blocks separately, -which in turn enables incremental transfer of large collections, -transfering and loading only subsets of the data as necessary, and so on. -Advanced Layouts give us the best of sharding's performance capabilities -while still presenting the exact same interface to application logic. - - -Using Advanced Layouts without a Schema ---------------------------------------- - -Although we introduced Advanced Layouts by way of the schema system, the -implementation doesn't strictly depend on the schema system, -and Advanced Layouts can be used directly by interacting with the library code: -an Advanced Layout is just another implementation of `Node`! - -TODO: more docs when we have implementations :) - - -Handling data without understanding the Advanced Layout -------------------------------------------------------- - -All data can be interpreted with *or without* the Advanced Layout information. - -Generally speaking, parsing some data with a schema in hand that provides -the Advanced Layout will allow traversal of the advanced structure transparently -(a single path segment may jump across as many internal nodes as the advanced -layout algorithm determines); and parsing some data without a schema is still -entirely possible at the Data Model layer. - -Being able to handle all data as completely normal Data Model content even when -at the application layer it may be seen with an Advanced Layout means we can -make all kinds of content addressing, data transfer, pinning, etc features work -in general: all these low level systems work without any need of schemas or -any specific understanding of any advanced layout algorithm. - -This duality can also be used intentionally: for example, even when knowing full -well what the schema is for UnixFS, a program may want to sometimes use that -schema (to traverse directories transparently, even when sharded, for example), -and also sometimes disregard it and see the raw structures (so it can fetch -the left-most leaves of a sharded file, for example -- which would effectively -translate to the "start" of a "file"). - - -Other notes ------------ - -Note that Advanced Layout types may not be used in nested type definitions in -schemas (e.g., a struct field may have a type `{String:String}`, -but *not* `[{String:String}]`). -There is no reason for this limitation other than limiting syntactic complexity. -(Imagine the readability of error messages regarding advanced layout contents -if there's no short clear type name for the root of the advanced layout -- terse -is critical usability feature here.) - -Note that often Advanced Layout implementation will still use a simple map or -array rather than linked objects when the content of the value is small enough. -(This is a popular optimization based on the understanding that introducing more -intermediate nodes and blocks and link traversal necessarily carries some -additional coordination and overhead costs.) However, not all Advanced Layouts -will do this, and it should not be relied upon in general. diff --git a/doc/big-picture.md b/doc/big-picture.md deleted file mode 100644 index 67fd154c..00000000 --- a/doc/big-picture.md +++ /dev/null @@ -1,69 +0,0 @@ -IPLD Big Picture -================ - -IPLD is a system for describing, storing, sharing, and hashing data. - - -Layers ------- - -IPLD comes in two distinct layers: - -1. The IPLD Data Model -2. The IPLD Schema system - -The IPLD Data Model is a specification of the core serializable types of data. -You can think of it as roughly isomorphic to the familiar JSON and CBOR -serialization systems (and yes, those parsers usually work "out of the box"). -You can read more about -[the Data Model specification in the Specs repo](https://github.com/ipld/specs/blob/master/IPLD-Data-Model-v1.md). - -The IPLD Schema system builds atop the IPLD Data Model to add a system of -user-defined types. These type schema are meant to be easy to write, easy to -read, and easy for the machine to parse and check efficiently. -IPLD Schema bring common concepts like "structs" with named "fields", as well -as "enums" and even "unions" -- and make clear definitions of how to map all of -these concepts onto the basic serializable types of the Data Model. - -You can use IPLD at either of these levels as you prefer. We recommend having a -schema for your data, because it makes validity checking, sanitization, -migration, and documentation all easier in the long run -- but the Data Model -is also absolutely usable stand-alone. - -Some of the most exciting features of IPLD come from the crossover between -the two layers: for example, it's possible to create two distinct Schema specs, -and easily flip data between them since all the data on both sides consistently -fits in the Data Model; migration logic can be written as functions operating -purely on the Data Model layer to handle even complex structural changes. -The ability to freely mix and match strong validation with generic data handling -makes programs possible which would otherwise be cumbersome with either alone. - - -Nodes, operations, encoding, & linking --------------------------------------- - -Three (or four) big picture groups of concepts you'll want to keep in mind when -reading the rest of the docs are nodes, operations, encoding, and linking. - -Nodes: every piece of data in IPLD can be handled as a "node". -Strings are nodes; ints are nodes; maps are nodes; etc. -[Nodes have their own full chapter of the documentation](./nodes.md). - -Operations: some basic computation we can do *on* a node is an operation. -Traversals and simple updates have built-in functions; more advanced operations -can be built with some use of callbacks. -[Operations have their own full chapter of the documentation](./operations.md). - -Encoding: every piece of data in IPLD is serializable. Any node can be -converted to a tokenized representation, and several built-in serialization -systems are supported, plus a pluggable mechanism for implementing more. -[Encoding has its own full chapter of the documentation](./encoding.md) - -Linking: every piece of data in IPLD is serializable ***and hashable***... -and can be linked by those hashes. These links can be manipulated explicitly, -and also used transparently by some of the built-in operation support. -[Linking has its own full chapter of the documentation](./linking.md) - -All of these features work on both the Data Model (unityped) layer -and also with Schema layer (typed) nodes. - diff --git a/doc/dev/node-implementations.md b/doc/dev/node-implementations.md deleted file mode 100644 index 482dd511..00000000 --- a/doc/dev/node-implementations.md +++ /dev/null @@ -1,130 +0,0 @@ -Dev Notes: on Node implementations -================================== - -> (This document is aimed for developers and contributors to the library; -> if you're only using the library, it should not be necessary to read this.) - -The concept of "Node" in IPLD is defined by the -[IPLD Data Model](https://github.com/ipld/specs/tree/master/data-model-layer), -and the interface of `ipld.Node` in this library is designed to make this -model manipulable in Golang. - -`Node` is an interface rather than a concrete implementation because -there are many different performance tradeoffs which can be made, -and we have multiple implementations that make them! -Codegenerated types also necessitate having a `Node` interface they can conform to. - - - -Designing a Node Implementation -------------------------------- - -Concerns: - -- 0. Correctness -- 1. Immutablity -- 2. Performance - -A `Node` implementation must of course conform with the Data Model. -Some nodes (especially, those that also implement `schema.TypedNode`) may also -have additional constraints. - -A `Node` implementation must maintain immutablity, or it shatters abstractions -and breaks features that build upon the assumption of immutable nodes (e.g. caches). - -A `Node` implementation should be as fast as possible. -(How fast this is, of course, varies -- and different implementations may make -different tradeoffs, e.g. often at the loss of generality.) - -Note that "generality" is not on the list. Some `Node` implementations are -concerned with being usable to store any shape of data; some are not. -(A `Node` implementation will usually document which camp it falls into.) - - -### Castability - -Castability refers to whether the `Node` abstraction can be added or removed -(also referred to as "boxing" and "unboxing") -by use of a cast by user code outside the library. - -Castability relates to all three of Correctness, Immutablity, and Performance. - -- if something can be unboxed via cast, and thence become mutable, we have an Immutablity problem. -- if something mutable can be boxed via cast, staying mutable, we have an Immutablity problem. -- if something can be boxed via cast, and thence skip a validator, we have a Correctness problem. - -(The relationship to performance is less black-and-white: though performance -considerations should always be backed up by benchmarks, casting can do well.) - -If castability would run into one of these problems, -then a Node implementation must avoid it. -(A typical way to do this is to make a single-field struct.) - -Whether a `Node` implementation will encounter these problems varies primarily on -the kind (literally, per `reflect.Kind`) of golang type is used in the implementation, -and whether the `Node` is "general" or can have an addition validators and constraints. - -#### Castability cases by example - -Castability for strings is safe when the `Node` is "general" (i.e. has no constraints). -With no constraints, there's no Correctness concern; -and since strings are immutable, there's no Immutablity concern. - -Castability for strings is often *unsafe* when the `Node` is a `schema.TypedNode`. -Typed nodes may have additional constraints, so we would have a Correctness problem. -(Note that the way we handle constraints in codegeneration means users can add -them *after* the code is generated, so the generation system can't presume -the absense of constraints.) - -Castability for other scalar types (int, float, etc) are safe when the `Node` is "general" -for the same reasons it's safe for strings: all these things are pass-by-value -in golang, so they're effectively immutable, and thus we have no concerns. - -Castability for bytes is a trickier topic. -See also [#when-performance-wins-over-immutablity]. -(TODO: the recommended course of action here is not yet clear. -I'd default to suggesting it should use a `struct{[]byte}` wrapping, -but if the performance cost of that is high, the value may be dubious.) - -#### Zero values - -If a `Node` is implemented as a golang struct, zero values may be a concern. - -If the struct type is unexported, the concern is absolved: -the zero value can't be initialized outside the package. - -If the `Node` implementation has no other constraints -(e.g., it's not also a `schema.TypedNode` in addition to just an `ipld.Node`), -the concern is (alomst certainly) absolved: -the zero value is simply a valid value. - -For the remaining cases: it's possible that the zero value is not valid. -This is problematic, because in the system as a whole, we use the existence -of a value that's boxed into a `Node` as the statement that the value is valid, -rather than suffering the need for "defensive" checks cropping up everywhere. - -(TODO: the recommended course of action here is not yet clear. -Making the type unexported and instead making an exported interface with a -single implementation may be one option, and it's possible it won't even be -noticably expensive if we already have to fit `Node`, but I'm not sure I've -reconnoitered all the other costs of that (e.g., godoc effects?). -It's possible this will be such a corner case in practice that we might -relegate the less-ergonomic mode to being an adjunct option for codegen.) - - - -When Performance wins over Immutablity --------------------------------------- - -Ideally? Never. In practice? Unfortunately, sometimes. - - -### bytes - -There is no way to have immutable byte slices in Go. -Defensive copying is also ridiculously costly. - -Methods that return byte slices typically do so without defensive copy. - -Methods doing this should consistently document that -"It is not lawful to mutate the slice returned by this function". diff --git a/doc/fluent.md b/doc/fluent.md deleted file mode 100644 index e51cd8be..00000000 --- a/doc/fluent.md +++ /dev/null @@ -1,13 +0,0 @@ -Fluent APIs -=========== - -The "fluent" APIs are replicates of most of the core interfaces -- e.g. Node, -NodeBuilder, etc -- which return single values. This makes things easier -to compose in a functional/point-free style. - -Errors in the fluent interfaces are handled by panicking. These errors are -boxed in a `fluent.Error` type, which can be unwrapped into the original error. -`fluent.Recover` can wrap any function with automatic recovery of these errors, -and returns them back to normal flow. Thus, we can write large blocks of code -using the fluent APIs, and handle all the errors in one place. Just as easily, -we can use nested sets of `fluent.Recover` as desired for granular handling. diff --git a/doc/nodes.md b/doc/nodes.md deleted file mode 100644 index 4c12e8e3..00000000 --- a/doc/nodes.md +++ /dev/null @@ -1,135 +0,0 @@ -Nodes -===== - -Everything is a Node. Maps are a node. Arrays are node. Ints are a node. -Everything in the IPLD Data Model is a Node. - -Nodes are traversable. Given a node which is one of the recursive kinds -(e.g. map or array), you can list child indexes, and you can traverse that -index to get another Node. - -Nodes are trees. It is not permissible to make a cycle of Node references. - -(Go programmers already familiar with the standard library `reflect` package -may find it useful to think of `ipld.Node` as similar to `reflect.Value`.) - - -Overview of Important Types ---------------------------- - -- `ipld.Node` -- see the section on Nodes above; this is *the* interface. -- `ipld.NodeBuilder` -- an interface for building new Nodes. -- `ipld.Kind` -- this enumeration describes all the major kinds at the Data Model layer. -- `fluent.Node` -- similar to `ipld.Node`, but methods don't return errors, instead - carrying them until actually checked and/or using panics, making them easy to compose - in long expressions. See the full page for [Fluent APIs](./fluent.md) for more. - - -the Node interface ------------------- - -Node is an interface for inspecting single values in IPLD. -It has methods for -extracting go primitive values for all the scalar node kinds, -'traverse' methods for maps and lists which return individual child nodes, -and iterator methods for maps. - -Node exposes only reader methods -- A Node is immutable. - -See the [godocs for Node](https://godoc.org/github.com/ipld/go-ipld-prime#Node). - - -### kinds - -The `Node.Kind()` method returns an `ipld.Kind` enum value describing what -kind of data this node contains in terms of the IPLD Data Model. - -The validity of many other methods can be anticipated by switching on the kind: -for example, `AsString` is definitely going to error if `Kind() == ipld.Kind_Map`, -and `LookupByString` is definitely going to error if `Kind() == ipld.Kind_String`. - -See the [godocs for Kind](https://godoc.org/github.com/ipld/go-ipld-prime#Kind). - - -Node implementations --------------------- - -Since `Node` is an interface, it can have many implementations. -We use different implementations to satisfy different performance objectives. -There are several implementations in the core library, and users can bring their own. - -In go-ipld-prime, we have several implementations: - -- `impl/free` (imports as `ipldfree`) -- a generic unspecialized implementation - of `Node` which can contain any kind of content, internally using Go wildcard types. -- `impl/bind` (imports as `ipldbind`) -- an implementation of `Node` which uses - reflection to bind to existing Go native objects and present them as nodes. -- `impl/cbor` (imports as `ipldcbor`) -- an implementation of `Node` which stores - all content as cbor-encoded bytes -- interesting primarily because when doing - a bulk parse of cbor data, this can effectively defer parsing of values until - they're actually inspected, sometimes enabling considerable processing saving. -- `typed` -- Typed nodes add a few more features onto the base Node interface - and add additional logical constraints to their contents -- more on this later - in the [Typed Nodes](#typed-nodes) section. - -Different Node implementations can be mixed freely! - -For example: we can use `ipldcbor.Decode` to get an `ipldcbor.Node` -(which internally is a sort of skip-list over the original CBOR byte slices), -use `traverse.Transform` to replace just *some* nodes internally with new data -we build out of an `ipldfree.NodeBuilder`, and then use `ipldcbor.Encode` again -to emit the updated CBOR. In this case, we are both able to use whatever kind -of Node we want for our new data, and since we're keeping the rest of the tree -in an `ipldcbor.Node` form we were able to skip all parsing of parts of the tree -we aren't interested in, and when emitting bytes again we can recycle all the -byte slices from the very first read -- in other words, zero copy operation -(except for specifically the parts we've updated). This is pretty neat! - -> Note: 'cbor' and 'bind' nodes are not yet fully supported. - - -using NodeBuilder ------------------ - -NodeBuilder is an interface that describes creating new Node instances. -NodeBuilders are a typical builder pattern: they are mutable and stateful. - -See the [godocs for NodeBuilder](https://godoc.org/github.com/ipld/go-ipld-prime#NodeBuilder). - -Each package exporting a `Node` implementation will generally also export a -corresponding `NodeBuilder()` factory func which can be used to start producing -nodes of that implementation type. - -Also note the `Node.NodeBuilder()` method, which returns a NodeBuilder from any Node. -NodeBuilder instances obtained from these methods produce new nodes of the same -implementation type (e.g., if it's an `ipldcbor.Node`, it'll give you an -`ipldcbor.NodeBuilder`). - -NodeBuilder instances derived from `Node.NodeBuilder()` have several uses: - -1. In the `traversal.Transform` system, this mechanism for getting a NodeBuilder - is how we pick an implementation for creating new nodes as we propagate - updates through the parents of mutation point. -2. For typed nodes, NodeBuilder instances obtained from `Node.NodeBuilder()` - also continue to carry type constraints matching the node they came from. -3. Finally, builders from `Node.NodeBuilder()` have some interesting powers - for the recursive kinds (maps and lists): they can "append"! Such appends - are still copy-on-write (e.g., won't mutate the original Node), but can often - save on memory use. - - -Typed Nodes ------------ - -TODO - -Everything in the IPLD *Schema* layer is *also* a node. -This sometimes means you'll jump over *several* nodes in the raw Data Model -representation of the data when traversing one link in the Schema layer. - -NodeBuilder for typed nodes functions the same as other NodeBuilder instances, -but again with more constraints on correct usage: NodeBuilder for typed nodes -will enforce the constraint of their associated type when used. -`typed.Type` has a `Type.NodeBuilder` method to yield appropriately constrained -builder instances; and `Node.NodeBuilder` on existing nodes will continue to -carry on the same constraints as the node its derived from. diff --git a/doc/schema-syntax.md b/doc/schema-syntax.md deleted file mode 100644 index 1ae959d1..00000000 --- a/doc/schema-syntax.md +++ /dev/null @@ -1,97 +0,0 @@ -Schema Syntax -============= - -Kinds ------ - -Kinds in schemas are a superset of the kinds already known at the Data Model layer: - -- "representation kinds" are map, array, string, bytes, boolean, integer, etc -- all of these are clear at the Data Model layer. -- "perceived kinds" include struct, union, and enum -- these are introduced at the Schema layer! - -Perceived kinds are not inherently representable; rather, they're a way we look -at data in the other representation kinds and constrain their behaviors to be -easier to work with. Schemas can declare types which are the perceived kinds, -but to do so, the schema simultaneously has to declare how to map that type onto -representation kinds. - -Maps and lists at the schema level are more constrained than their equivalents -at the Data Model layer. At the Data Model layer, heterogenous contents are -always allowed; in the Schema system, key and value types must be declared! -(Structs still typically describe heterogenous-content maps (or lists). -Wildcard types can also be used for value types explicitly when necessary.) - - -Types ------ - -Types are declared with a name, which of the kinds it is, any details of the -type (e.g., fields in a struct; value types in a list; etc), and a representation. - -The type declaration syntax varies by kind (e.g. unions and maps use visually -distinctive syntaxes) and follow a variety of rules: - -- Types of recursive kinds (maps and lists) have terse declaration syntaxes: - `[valueType]` defines arrays, and `{keyType:valueType}` defines maps. -- Struct fields may be declared to contain any named type, or alternatively may - be declared to contain an anonymous type for which the definition is inlined - (e.g. arrays can be defined inline for a struct field's type: `fieldName [Type]`). -- Recursive kind types may also use inline definitions - (e.g. `type Foo {Bar:[Baz]}` is a map containing lists containing `Baz` elements). -- Struct fields, map values, and array values can be defined as "nullable". -- Struct fields can also be defined as "optional" (distinct from nullable: the - key may be absent, but if present, the value must be non-null). - -By example: - -```ipldsch -type MyString string // "type" is a keyword; "MyString" is the name; "string" is the kind. -type MyInt int // "type" is a keyword; "MyInt" is the name; "int" is the kind. -``` - -Recursive types have more details: - -```ipldsch -type MyList [String] // "MyList" is the name; brackets indicate list kind; - // and "String" is the contained value type. -type MyMap {String:String} // Curly-braces indicate map kind. -``` - -Note that in the above examples, `String` is capitalized, not lowercase: -this is because these are references to the string *type*, not a bare *kind*. -(`String` is a built-in/default type: `type String string`.) - -We can also have structs, which are composed of fields: - -```ipldsch -type MyStruct struct { - AnInt Int // "AnInt" is the field name; "Int" is the type. - AString String // "AString" is the field name; "String" is the type. -} -``` - -TODO introduce examples of anonymous recursive types - -TODO introduce examples of non-default representation - -TODO introduce examples of nullable - -TODO introduce examples of optional - -TODO introduce examples of enums - -TODO introduce examples of unions (in all their representations) - - -Fully Worked Examples ---------------------- - -See the self-representing Schema schema: - -- [Schema schema in Schema DSL format](../typed/declaration/schema-schema.ipldsch) -- [Schema schema in IPLD-over-JSON format](../typed/declaration/schema-schema.ipldsch.json) - -See also some other example schema: - -- [Example schema in Schema DSL format](../typed/declaration/examples.ipldsch) -- [Example schema in IPLD-over-JSON format](../typed/declaration/examples.ipldsch.json) diff --git a/doc/schema.md b/doc/schema.md deleted file mode 100644 index 9886b08b..00000000 --- a/doc/schema.md +++ /dev/null @@ -1,316 +0,0 @@ -IPLD Schema system -================== - -// Disclaimer: This document will eventually move to the `ipld/specs` repo. -It's currently incubating here in the same repo as the first implementation -for practical developmental flow reasons. - - -Goals ------ - -1. Provide a reasonable, easy to use, general type system for declaring - useful properties about data. -2. Compose nicely over IPLD Data Model. -3. Be efficient to verify (e.g. roughly linear in the size of the data - and schema; and absolutely not turing complete). -4. Be language-agnostic: many compatible implementations of the schema - checker tools should exist, as well as bindings for every language. -5. Assist rather than obstruct migration. (We expect data to exist from - *before* the current schemas; we need to work well on this case.) - - -Features --------- - -Well-understood basics (sum types, product types, some specific recursive types): - -- typed maps (e.g. `{Foo:Bar}`) -- typed arrays (e.g. `[Foo]`) -- typedef'd primitives (e.g. `type Foo int`) -- typed structs (e.g. `struct{ f Foo; b Bar }`) -- typed unions (several styles) -- enums (over strings) -- "advanced layouts" (more on that later) - -Bonus features: - -- simple syntax for 'maybe' (e.g. `struct{ f nullable Foo }` or `[nullable Foo]`) -- clear syntax for non-required fields (e.g. `struct { f optional Foo }`) - -Some non-features: - -- [dependent types](https://en.wikipedia.org/wiki/Dependent_type) -- anything that would introduce turing-completeness or otherwise unpredictable - computational complexity to the checking process. - -(n.b. It's not that we don't think dependent types are cool -- they are -- just -that this is not the place for them. A dependently typed system which can -reason about and produce declarations in the IPLD Schema system would be -extremely neat!) - -All types are defacto *structural*, rather than *nominative*. -Because we expect data to exist independently of the schema, it follows that -every part of the system has to start by checking that the data matches the -schema. This doesn't mean you can't have nominative-style behaviors: it's -just that you get them by using features like typed unions, which effectively -give you a nominative-style behavior while leaving the configuration of it -clearly in the hands of your schema. -(See the "Using Schema Match checking" section below for more discussion of how -to produce nominative-style behaviors.) - - -Syntax ------- - -Schemas can be represented in multiple isomorphic ways: there is both a schema -DSL (for human reading and writing), and a canonical representation in IPLD itself. -(The canonical IPLD representation is also self-describing!) - -See the [Schema Syntax](./schema-syntax.md) document for more details as well -as fully-worked examples. - - -Implementation --------------- - -There are three major components of the implementation: -the schema declaration, -the reified schema, -and schema adjuncts. - -### Schema Declaration - -The schema declaration implementation lives in `go-ipld-prime//typed/declaration`, -and includes all of the golang types for containing the schema declaration itself. -Subpackages of this package include the mechanisms for parsing the schema DSL. - -All of the types in the schema declaration implementation are serializable by -nature. (This implies that all references to other types are by name, not by -pointer... which brings us to why there's a Reified Schema implementation.) - -### Reified Schema - -Reified schema refers to parts of the code which handle the fully processed -schema info -- it's distinct from the Schema Representation code because it's -allowed to contain pointers (including cyclic references), etc. - -The reified schema can be computed purely from the schema declaration. - -The reified schema implementation lives in `go-ipld-prime//typed/system`, -and `go-ipld-prime//schema.TypedNode` notably has a `Type() typesystem.Type` method -which provides the reified schema information for any typed node. - -Note that multiple disjoint `typesystem.Universe` instances can exist in the -same program that's manipulating IPLD data and types! Types with the same names -may exist in separate universes. Nodes of such types are not interchangable... -but you can move data from one node type to another by handling it at the -Data Model layer! - -### Schema Adjuncts - -Schema Adjuncts are more properties which can be attached to a Reified schema. -Adjuncts are -- as the name suggests -- adjoined to the schema, but technically -not entirely a part of it. Adjunct data includes anything which changes how we -interact with the schema (including generating code, etc) but doesn't change the -essential cardinality of any schema data definitions. Adjunct data can include -language-specific details (e.g., overriding the names of fields in generated -code for a specific language falls under the umbrella of adjunct data.) - -// todo: document behavior tree patterns for handling concepts like "defaults", -schema stack probing, options for programmatic callbacks (for fancy migrations), -etc - - -Excursions ----------- - -Some literature in type theory refers to "open" vs "closed" types, particularly -in regard to unions and enumerations (sum types). - -Roughly, "closed" types are those where *all* values are known and countable; -"open" types allow a "default" case for handling unknown values. - -Aside from this introduction, we won't use the terms "open" and "closed" much. -All schema types are *like* "closed"; but they're also inherently "open" since -we are of course handling data which may have existed outside of the schema. - -In IPLD, the data at the Data Model layer is always "open" in nature; and -at the Schema layer we treat it as "closed". As such, we don't spend much -futher time with the "open"/"closed" distinction; it's simply "does this data -match the schema or not?". - -Most go-ipld-prime APIs for handling typed data will frontload the schema match -checking -- by the time a handle to the document has been returned, the entire -piece of data is verified to match the schema. -There are also some optional ways to use the library which -defer the open->closed mapping until midway through your handling of data, -in exchange for the schema mismatch error becoming something that needs handling -at that point in your code rather than up front. - - -Schemas and Migration ---------------------- - -Fundamental to our approach to schemas is an understanding: - -> Data Never Changes. Only our interpretation varies. - -Data can be created under one schema, and interpreted later under another. -Data may predate or be created without any kind of schema at all. -All of this needs to be fine. - -Moreover, before talking about migration, it's important to note that we -don't allow the comforting, easy notion that migration is a one-way process, -or can be carried out atomically at one magically instantaneous point in time. -Because data is immutable, and producing updated versions of it doesn't make -the older version of the data go away, migration is less a thing that you do; -and more a state of mind. Migration has to be seamless at any time. - -Migration comes in two parts: - -1. Understand what data we have; -2. and having a process to map it into the format of data we want. - -We'll spend a few sections on part 1, and then get on to part 2. - -### Using Schema Match checking as Version Detection - -We don't include any built-in/blessed concepts of versioning in IPLD Schemas. -It's not necessary: we have rich primitives which can be used to build -either explicit versioning or version detection, at your option. - -Since it's easy to check if a schema fits over a piece of data, it's -easy to simply probe a series of schemas until finding one that fits. -Therefore, any constraint a schema makes has the potential to be used -for version detection! - -There are a handful of recognizable patterns that are used frequently: - -- Using a dummy union to get nominative typing at the document root. - - e.g. `{"foo": {...}}`, using "foo" as the type+version hint. - The union is has only single member, and we use this in concert with - multiple schemas and probing: it returns quickly in the case of a non-match. - - Any union representation will do. - - Keyed unions: `{"foo-v2": {...}}` - - Envelope unions: `{"version": "2", "content":{...}}` - - Inline unions: `{"version": "2", ...}` - - A single-member struct would also fit the pattern, being functionally - equivalent to a keyed union. - - See the schema-schema for an example of this! -- Using a "version" union (with multiple members). - - e.g. `{"version": "1.2.3", "data":{...}}` - - Any union representation will do. - - This might not be the best approach: in this approach, the multiple versions - are implemented *within* one schema! Typically it's considered easier to - work with and more maintainable to use a separate schema per version. -- Using a struct with "version" field(s), then a second unpacking. - - Two phases of matching allow user-specified decisions in the middle: - - First a simple schema is used, containing some struct fields for version - info, plus some ignored fields which will contain the further content. - This simple schema is assumed to match completely. - - Secondly, using information from that first pass, user-specified logic - selects a complete schema, which is then used to handle the full data. - -(Currently, this probing is left to the library user. More built-in features -around this are expected to come in the future.) - -Any of these approaches may also be composed. For example, you might choose -to use a dummy union at the root of a document to sanity-check what general -type of data you're processing; and use an inline union inside that for more -specific version matching, and so forth. - -(In the future, we may also be able to construct some specialized schemas that -suggest jumping to another schema specifically and directly (rather than -linear probing); some research required. (Ideally this would work consistently -regardless of the ordering of fields in the arriving data, but there's some -tension between that and performance.) It might also be possible to construct -these as a user already!) - -NOTE that these conventions are easy to adopt even by systems not implemented -using IPLD Schemas! If you're working on a system which hasn't started using -IPLD Schemas yet, and you aim to in the future, *start using version hinting* -based on these designs *now*; the benefits can be reaped later. - -### Some comments on versioning-theory - -There are different philosophies of versioning: namely, explicit versioning -labels and version detection; which to use is a choice. - -In short, explicit versioning with labels takes a prescriptive approach, -requiring coordinated labelling choices up front, and thus tends towards -fragility and is not particularly fork/community/decentralization-friendly. -Version detection -- also known as its generalized cousin, *Feature* detection --- is strictly more powerful, but can be more complex. -Neither can be deployed to reliable effect without a plan. - -Explicit versioning labelling is prone to treating the version label as a -semantic junk drawer, upon which we can heap unbounded amounts of -not-necessarily-related semantics. -This is a temptation which can be migitated through diligence, but the -fundamental incentive is always there: like global variables in programming, -a document-global explicit version allows lazy coding and fosters presumptions. - -Version/feature detection has the potential to become a fractal. -Using it well thus *also* requires diligence. However, there is no built-in -siren temptation to misuse them in the same way as explicit versioning; the -trade-offs in complexity tend to be make themselves fairly pronounced and -as such are relatively easily communicated. - -It's impossible to make a blanket prescription of how to associate version -information with data. Different choices have different tradeoffs. -IPLD Schemas aim to make either choice (or hybrids of approach!) viable. - -### Strongly linked Schemas - -It is possible to have a document which links directly to its own Schema! -Since IPLD Schemas are themselves representable in IPLD, it's outright trivial -to make an object containing a CID linking to a Schema. - -This may be useful -- in particular, it certainly solves any issue of chosing -unique version strings in using explicit versioning! -- but it is also worth -noting that is is not a solution to *migration*: while having a specific schema -explicitly linked is certainly one way to address the need to -"understand what data we have", remember that the definition of migration has a -second half: "having a process to map data into the format we want". - -Unless it just so *happens* that this exact schema is the one you want, and have -already build your application logic against, etc... an explicitly linked schema -doesn't necessarily provide more value in terms of migration than any of the -other forms of versioning; it's essentially the same as using explicit labels. - -### Actually Migrating! - -... Okay, this was a little bit of bait-and-switch. -IPLD Schemas aren't completely magic. - -Some part of migration is inevitably left up to application logic. -Almost by definition, "a process to map data into the format of data we want" -is at its most general going to be a turing-complete operation. - -However, IPLD can still help: the relationship between the Data Model versus -the Schema provides a foundation for writing maintainable migrations. - -Any migration logic can be expressed as a function from `Node` to `Node`. -These nodes may each be checking Schema validity -- against two different -schemas! -- but the code for transposing data from one node to the other -can operate entirely within Data Model. The result is the ability to write -code that's effectively handling multiple disjoin type systems... without -any real issues. - -Thus, a valid strategy for longlived application design is to handle each -major change to a schema by copying/forking the current one; keeping it -around for use as a recognizer for old versions of data; and writing a -quick function that can flip data from the old schema format to the new one. -When parsing data, try the newer schema first; if it's rejected, try the old -one, and use the migration function as necessary. - -If you're using codegen based on the schema, note that you'll probably only -need to use codegen for the most recent / most preferred version of the schema. -(This is a good thing! We wouldn't want tons of generated code per version -to start stacking up in our repos.) -Parsing of data for other versions can be handled by ipldcbor.Node or other -such implementations which are optimized for handling serial data; the -migration function is a natural place to build the codegenerated native typed -Nodes, and so each half of the process can easily use the Node implementation -that is best suited. diff --git a/examples_test.go b/examples_test.go index b79a7dbb..080cd685 100644 --- a/examples_test.go +++ b/examples_test.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/ipld/go-ipld-prime/codec/dagjson" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) // Example_createDataAndMarshal shows how you can feed data into a NodeBuilder, diff --git a/fluent/bench_test.go b/fluent/bench_test.go index 1c627af2..519a8313 100644 --- a/fluent/bench_test.go +++ b/fluent/bench_test.go @@ -4,22 +4,22 @@ import ( "strings" "testing" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/fluent/qp" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func BenchmarkQp(b *testing.B) { b.ReportAllocs() - f2 := func(na ipld.NodeAssembler, a string, b string, c string, d []string) { - qp.Map(4, func(ma ipld.MapAssembler) { + f2 := func(na datamodel.NodeAssembler, a string, b string, c string, d []string) { + qp.Map(4, func(ma datamodel.MapAssembler) { qp.MapEntry(ma, "destination", qp.String(a)) qp.MapEntry(ma, "type", qp.String(b)) qp.MapEntry(ma, "source", qp.String(c)) - qp.MapEntry(ma, "options", qp.List(int64(len(d)), func(la ipld.ListAssembler) { + qp.MapEntry(ma, "options", qp.List(int64(len(d)), func(la datamodel.ListAssembler) { for _, s := range d { qp.ListEntry(la, qp.String(s)) } @@ -27,7 +27,7 @@ func BenchmarkQp(b *testing.B) { })(na) } for i := 0; i < b.N; i++ { - n, err := qp.BuildList(basicnode.Prototype.Any, -1, func(la ipld.ListAssembler) { + n, err := qp.BuildList(basicnode.Prototype.Any, -1, func(la datamodel.ListAssembler) { f2(la.AssembleValue(), // TODO: forgot to check error? "/", "overlay", @@ -49,7 +49,7 @@ func BenchmarkQp(b *testing.B) { func BenchmarkUnmarshal(b *testing.B) { b.ReportAllocs() - var n ipld.Node + var n datamodel.Node var err error serial := `[{ "destination": "/", @@ -77,7 +77,7 @@ func BenchmarkUnmarshal(b *testing.B) { func BenchmarkFluent(b *testing.B) { b.ReportAllocs() - var n ipld.Node + var n datamodel.Node var err error for i := 0; i < b.N; i++ { n, err = fluent.BuildList(basicnode.Prototype.Any, -1, func(la fluent.ListAssembler) { @@ -102,7 +102,7 @@ func BenchmarkFluent(b *testing.B) { func BenchmarkReflect(b *testing.B) { b.ReportAllocs() - var n ipld.Node + var n datamodel.Node var err error val := []interface{}{ map[string]interface{}{ @@ -128,7 +128,7 @@ func BenchmarkReflect(b *testing.B) { func BenchmarkReflectIncludingInitialization(b *testing.B) { b.ReportAllocs() - var n ipld.Node + var n datamodel.Node var err error for i := 0; i < b.N; i++ { n, err = fluent.Reflect(basicnode.Prototype.Any, []interface{}{ @@ -153,7 +153,7 @@ func BenchmarkReflectIncludingInitialization(b *testing.B) { func BenchmarkAgonizinglyBare(b *testing.B) { b.ReportAllocs() - var n ipld.Node + var n datamodel.Node var err error for i := 0; i < b.N; i++ { n, err = fab() @@ -164,7 +164,7 @@ func BenchmarkAgonizinglyBare(b *testing.B) { } } -func fab() (ipld.Node, error) { +func fab() (datamodel.Node, error) { nb := basicnode.Prototype.Any.NewBuilder() la1, err := nb.BeginList(-1) if err != nil { diff --git a/fluent/fluentBuilder.go b/fluent/fluentBuilder.go index 5ffd08f6..ea7f7907 100644 --- a/fluent/fluentBuilder.go +++ b/fluent/fluentBuilder.go @@ -1,10 +1,10 @@ package fluent import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) -func Build(np ipld.NodePrototype, fn func(NodeAssembler)) (ipld.Node, error) { +func Build(np datamodel.NodePrototype, fn func(NodeAssembler)) (datamodel.Node, error) { nb := np.NewBuilder() fna := WrapAssembler(nb) err := Recover(func() { @@ -15,26 +15,26 @@ func Build(np ipld.NodePrototype, fn func(NodeAssembler)) (ipld.Node, error) { } return nb.Build(), nil } -func BuildMap(np ipld.NodePrototype, sizeHint int64, fn func(MapAssembler)) (ipld.Node, error) { +func BuildMap(np datamodel.NodePrototype, sizeHint int64, fn func(MapAssembler)) (datamodel.Node, error) { return Build(np, func(fna NodeAssembler) { fna.CreateMap(sizeHint, fn) }) } -func BuildList(np ipld.NodePrototype, sizeHint int64, fn func(ListAssembler)) (ipld.Node, error) { +func BuildList(np datamodel.NodePrototype, sizeHint int64, fn func(ListAssembler)) (datamodel.Node, error) { return Build(np, func(fna NodeAssembler) { fna.CreateList(sizeHint, fn) }) } -func MustBuild(np ipld.NodePrototype, fn func(NodeAssembler)) ipld.Node { +func MustBuild(np datamodel.NodePrototype, fn func(NodeAssembler)) datamodel.Node { nb := np.NewBuilder() fn(WrapAssembler(nb)) return nb.Build() } -func MustBuildMap(np ipld.NodePrototype, sizeHint int64, fn func(MapAssembler)) ipld.Node { +func MustBuildMap(np datamodel.NodePrototype, sizeHint int64, fn func(MapAssembler)) datamodel.Node { return MustBuild(np, func(fna NodeAssembler) { fna.CreateMap(sizeHint, fn) }) } -func MustBuildList(np ipld.NodePrototype, sizeHint int64, fn func(ListAssembler)) ipld.Node { +func MustBuildList(np datamodel.NodePrototype, sizeHint int64, fn func(ListAssembler)) datamodel.Node { return MustBuild(np, func(fna NodeAssembler) { fna.CreateList(sizeHint, fn) }) } -func WrapAssembler(na ipld.NodeAssembler) NodeAssembler { +func WrapAssembler(na datamodel.NodeAssembler) NodeAssembler { return &nodeAssembler{na} } @@ -52,10 +52,10 @@ type NodeAssembler interface { AssignFloat(float64) AssignString(string) AssignBytes([]byte) - AssignLink(ipld.Link) - AssignNode(ipld.Node) + AssignLink(datamodel.Link) + AssignNode(datamodel.Node) - Prototype() ipld.NodePrototype + Prototype() datamodel.NodePrototype } // MapAssembler is the same as the interface in the core package, except: @@ -69,8 +69,8 @@ type MapAssembler interface { AssembleEntry(k string) NodeAssembler - KeyPrototype() ipld.NodePrototype - ValuePrototype(k string) ipld.NodePrototype + KeyPrototype() datamodel.NodePrototype + ValuePrototype(k string) datamodel.NodePrototype } // ListAssembler is the same as the interface in the core package, except: @@ -81,11 +81,11 @@ type MapAssembler interface { type ListAssembler interface { AssembleValue() NodeAssembler - ValuePrototype(idx int64) ipld.NodePrototype + ValuePrototype(idx int64) datamodel.NodePrototype } type nodeAssembler struct { - na ipld.NodeAssembler + na datamodel.NodeAssembler } func (fna *nodeAssembler) CreateMap(sizeHint int64, fn func(MapAssembler)) { @@ -138,22 +138,22 @@ func (fna *nodeAssembler) AssignBytes(v []byte) { panic(Error{err}) } } -func (fna *nodeAssembler) AssignLink(v ipld.Link) { +func (fna *nodeAssembler) AssignLink(v datamodel.Link) { if err := fna.na.AssignLink(v); err != nil { panic(Error{err}) } } -func (fna *nodeAssembler) AssignNode(v ipld.Node) { +func (fna *nodeAssembler) AssignNode(v datamodel.Node) { if err := fna.na.AssignNode(v); err != nil { panic(Error{err}) } } -func (fna *nodeAssembler) Prototype() ipld.NodePrototype { +func (fna *nodeAssembler) Prototype() datamodel.NodePrototype { return fna.na.Prototype() } type mapNodeAssembler struct { - ma ipld.MapAssembler + ma datamodel.MapAssembler } func (fma *mapNodeAssembler) AssembleKey() NodeAssembler { @@ -169,20 +169,20 @@ func (fma *mapNodeAssembler) AssembleEntry(k string) NodeAssembler { } return &nodeAssembler{va} } -func (fma *mapNodeAssembler) KeyPrototype() ipld.NodePrototype { +func (fma *mapNodeAssembler) KeyPrototype() datamodel.NodePrototype { return fma.ma.KeyPrototype() } -func (fma *mapNodeAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (fma *mapNodeAssembler) ValuePrototype(k string) datamodel.NodePrototype { return fma.ma.ValuePrototype(k) } type listNodeAssembler struct { - la ipld.ListAssembler + la datamodel.ListAssembler } func (fla *listNodeAssembler) AssembleValue() NodeAssembler { return &nodeAssembler{fla.la.AssembleValue()} } -func (fla *listNodeAssembler) ValuePrototype(idx int64) ipld.NodePrototype { +func (fla *listNodeAssembler) ValuePrototype(idx int64) datamodel.NodePrototype { return fla.la.ValuePrototype(idx) } diff --git a/fluent/fluentBuilder_test.go b/fluent/fluentBuilder_test.go index 1306a30b..2a9242dd 100644 --- a/fluent/fluentBuilder_test.go +++ b/fluent/fluentBuilder_test.go @@ -5,10 +5,10 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestBuild(t *testing.T) { @@ -16,13 +16,13 @@ func TestBuild(t *testing.T) { n := fluent.MustBuild(basicnode.Prototype__String{}, func(fna fluent.NodeAssembler) { fna.AssignString("fine") }) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_String) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_String) v2, err := n.AsString() Wish(t, err, ShouldEqual, nil) Wish(t, v2, ShouldEqual, "fine") }) t.Run("map build should work", func(t *testing.T) { - n := fluent.MustBuild(basicnode.Prototype__Map{}, func(fna fluent.NodeAssembler) { + n := fluent.MustBuild(basicnode.Prototype.Map, func(fna fluent.NodeAssembler) { fna.CreateMap(3, func(fma fluent.MapAssembler) { fma.AssembleEntry("k1").AssignString("fine") fma.AssembleEntry("k2").AssignString("super") @@ -33,7 +33,7 @@ func TestBuild(t *testing.T) { }) }) }) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(3)) Wish(t, must.String(must.Node(n.LookupByString("k1"))), ShouldEqual, "fine") Wish(t, must.String(must.Node(n.LookupByString("k2"))), ShouldEqual, "super") @@ -44,7 +44,7 @@ func TestBuild(t *testing.T) { Wish(t, must.String(must.Node(n.LookupByString("k33"))), ShouldEqual, "asking") }) t.Run("list build should work", func(t *testing.T) { - n := fluent.MustBuild(basicnode.Prototype__List{}, func(fna fluent.NodeAssembler) { + n := fluent.MustBuild(basicnode.Prototype.List, func(fna fluent.NodeAssembler) { fna.CreateList(1, func(fla fluent.ListAssembler) { fla.AssembleValue().CreateList(1, func(fla fluent.ListAssembler) { fla.AssembleValue().CreateList(1, func(fla fluent.ListAssembler) { @@ -55,19 +55,19 @@ func TestBuild(t *testing.T) { }) }) }) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(1)) n = must.Node(n.LookupByIndex(0)) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(1)) n = must.Node(n.LookupByIndex(0)) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(1)) n = must.Node(n.LookupByIndex(0)) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(1)) n = must.Node(n.LookupByIndex(0)) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Int) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Int) Wish(t, must.Int(n), ShouldEqual, int64(2)) }) } diff --git a/fluent/fluentRecover_test.go b/fluent/fluentRecover_test.go index 975f6d92..aef3f945 100644 --- a/fluent/fluentRecover_test.go +++ b/fluent/fluentRecover_test.go @@ -5,9 +5,9 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestRecover(t *testing.T) { @@ -20,7 +20,7 @@ func TestRecover(t *testing.T) { t.Fatal("should not be reached") }), ShouldEqual, - fluent.Error{ipld.ErrWrongKind{TypeName: "string", MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_String}}, + fluent.Error{datamodel.ErrWrongKind{TypeName: "string", MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_String}}, ) }) t.Run("correct build should return nil", func(t *testing.T) { diff --git a/fluent/qp/example_test.go b/fluent/qp/example_test.go index f6cc2a7a..3f5c8829 100644 --- a/fluent/qp/example_test.go +++ b/fluent/qp/example_test.go @@ -3,23 +3,23 @@ package qp_test import ( "os" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent/qp" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) // TODO: can we make ListEntry/MapEntry less verbose? func Example() { - n, err := qp.BuildMap(basicnode.Prototype.Any, 4, func(ma ipld.MapAssembler) { + n, err := qp.BuildMap(basicnode.Prototype.Any, 4, func(ma datamodel.MapAssembler) { qp.MapEntry(ma, "some key", qp.String("some value")) qp.MapEntry(ma, "another key", qp.String("another value")) - qp.MapEntry(ma, "nested map", qp.Map(2, func(ma ipld.MapAssembler) { + qp.MapEntry(ma, "nested map", qp.Map(2, func(ma datamodel.MapAssembler) { qp.MapEntry(ma, "deeper entries", qp.String("deeper values")) qp.MapEntry(ma, "more deeper entries", qp.String("more deeper values")) })) - qp.MapEntry(ma, "nested list", qp.List(2, func(la ipld.ListAssembler) { + qp.MapEntry(ma, "nested list", qp.List(2, func(la datamodel.ListAssembler) { qp.ListEntry(la, qp.Int(1)) qp.ListEntry(la, qp.Int(2)) })) diff --git a/fluent/qp/qp.go b/fluent/qp/qp.go index e5f74762..82906cf6 100644 --- a/fluent/qp/qp.go +++ b/fluent/qp/qp.go @@ -9,19 +9,19 @@ // Finally, functions like MapEntry and ListEntry allow inserting into maps and // lists. // -// These all use the same IPLD interfaces such as NodePrototype and +// These all use the same IPLD datamodel interfaces such as NodePrototype and // NodeAssembler, but with some magic to reduce verbosity. package qp import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) -type Assemble = func(ipld.NodeAssembler) +type Assemble = func(datamodel.NodeAssembler) -func BuildMap(np ipld.NodePrototype, sizeHint int64, fn func(ipld.MapAssembler)) (_ ipld.Node, err error) { +func BuildMap(np datamodel.NodePrototype, sizeHint int64, fn func(datamodel.MapAssembler)) (_ datamodel.Node, err error) { defer func() { if r := recover(); r != nil { if rerr, ok := r.(error); ok { @@ -39,10 +39,10 @@ func BuildMap(np ipld.NodePrototype, sizeHint int64, fn func(ipld.MapAssembler)) type mapParams struct { sizeHint int64 - fn func(ipld.MapAssembler) + fn func(datamodel.MapAssembler) } -func (mp mapParams) Assemble(na ipld.NodeAssembler) { +func (mp mapParams) Assemble(na datamodel.NodeAssembler) { ma, err := na.BeginMap(mp.sizeHint) if err != nil { panic(err) @@ -53,11 +53,11 @@ func (mp mapParams) Assemble(na ipld.NodeAssembler) { } } -func Map(sizeHint int64, fn func(ipld.MapAssembler)) Assemble { +func Map(sizeHint int64, fn func(datamodel.MapAssembler)) Assemble { return mapParams{sizeHint, fn}.Assemble } -func MapEntry(ma ipld.MapAssembler, k string, fn Assemble) { +func MapEntry(ma datamodel.MapAssembler, k string, fn Assemble) { na, err := ma.AssembleEntry(k) if err != nil { panic(err) @@ -65,7 +65,7 @@ func MapEntry(ma ipld.MapAssembler, k string, fn Assemble) { fn(na) } -func BuildList(np ipld.NodePrototype, sizeHint int64, fn func(ipld.ListAssembler)) (_ ipld.Node, err error) { +func BuildList(np datamodel.NodePrototype, sizeHint int64, fn func(datamodel.ListAssembler)) (_ datamodel.Node, err error) { defer func() { if r := recover(); r != nil { if rerr, ok := r.(error); ok { @@ -83,10 +83,10 @@ func BuildList(np ipld.NodePrototype, sizeHint int64, fn func(ipld.ListAssembler type listParams struct { sizeHint int64 - fn func(ipld.ListAssembler) + fn func(datamodel.ListAssembler) } -func (lp listParams) Assemble(na ipld.NodeAssembler) { +func (lp listParams) Assemble(na datamodel.NodeAssembler) { la, err := na.BeginList(lp.sizeHint) if err != nil { panic(err) @@ -97,17 +97,17 @@ func (lp listParams) Assemble(na ipld.NodeAssembler) { } } -func List(sizeHint int64, fn func(ipld.ListAssembler)) Assemble { +func List(sizeHint int64, fn func(datamodel.ListAssembler)) Assemble { return listParams{sizeHint, fn}.Assemble } -func ListEntry(la ipld.ListAssembler, fn Assemble) { +func ListEntry(la datamodel.ListAssembler, fn Assemble) { fn(la.AssembleValue()) } type nullParam struct{} -func (s nullParam) Assemble(na ipld.NodeAssembler) { +func (s nullParam) Assemble(na datamodel.NodeAssembler) { if err := na.AssignNull(); err != nil { panic(err) } @@ -119,7 +119,7 @@ func Null() Assemble { type boolParam bool -func (s boolParam) Assemble(na ipld.NodeAssembler) { +func (s boolParam) Assemble(na datamodel.NodeAssembler) { if err := na.AssignBool(bool(s)); err != nil { panic(err) } @@ -131,7 +131,7 @@ func Bool(b bool) Assemble { type intParam int64 -func (i intParam) Assemble(na ipld.NodeAssembler) { +func (i intParam) Assemble(na datamodel.NodeAssembler) { if err := na.AssignInt(int64(i)); err != nil { panic(err) } @@ -143,7 +143,7 @@ func Int(i int64) Assemble { type floatParam float64 -func (f floatParam) Assemble(na ipld.NodeAssembler) { +func (f floatParam) Assemble(na datamodel.NodeAssembler) { if err := na.AssignFloat(float64(f)); err != nil { panic(err) } @@ -155,7 +155,7 @@ func Float(f float64) Assemble { type stringParam string -func (s stringParam) Assemble(na ipld.NodeAssembler) { +func (s stringParam) Assemble(na datamodel.NodeAssembler) { if err := na.AssignString(string(s)); err != nil { panic(err) } @@ -167,7 +167,7 @@ func String(s string) Assemble { type bytesParam []byte -func (p bytesParam) Assemble(na ipld.NodeAssembler) { +func (p bytesParam) Assemble(na datamodel.NodeAssembler) { if err := na.AssignBytes([]byte(p)); err != nil { panic(err) } @@ -178,29 +178,29 @@ func Bytes(p []byte) Assemble { } type linkParam struct { - x ipld.Link + x datamodel.Link } -func (l linkParam) Assemble(na ipld.NodeAssembler) { - if err := na.AssignLink(ipld.Link(l.x)); err != nil { +func (l linkParam) Assemble(na datamodel.NodeAssembler) { + if err := na.AssignLink(datamodel.Link(l.x)); err != nil { panic(err) } } -func Link(l ipld.Link) Assemble { +func Link(l datamodel.Link) Assemble { return linkParam{l}.Assemble } type nodeParam struct { - x ipld.Node + x datamodel.Node } -func (n nodeParam) Assemble(na ipld.NodeAssembler) { - if err := na.AssignNode(ipld.Node(n.x)); err != nil { +func (n nodeParam) Assemble(na datamodel.NodeAssembler) { + if err := na.AssignNode(datamodel.Node(n.x)); err != nil { panic(err) } } -func Node(n ipld.Node) Assemble { +func Node(n datamodel.Node) Assemble { return nodeParam{n}.Assemble } diff --git a/fluent/reflect.go b/fluent/reflect.go index 0c039ba9..8f603490 100644 --- a/fluent/reflect.go +++ b/fluent/reflect.go @@ -5,7 +5,7 @@ import ( "reflect" "sort" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Reflect creates a new Node by looking at a golang value with reflection @@ -47,13 +47,13 @@ import ( // Other features in the fluent package will typically out-perform this, // and using NodeAssemblers directly (without any fluent tools) will be much faster. // Only use this function if performance is not of consequence. -func Reflect(np ipld.NodePrototype, i interface{}) (ipld.Node, error) { +func Reflect(np datamodel.NodePrototype, i interface{}) (datamodel.Node, error) { return defaultReflector.Reflect(np, i) } // MustReflect is a shortcut for Reflect but panics on any error. // It is useful if you need a single return value for function composition purposes. -func MustReflect(np ipld.NodePrototype, i interface{}) ipld.Node { +func MustReflect(np datamodel.NodePrototype, i interface{}) datamodel.Node { n, err := Reflect(np, i) if err != nil { panic(err) @@ -66,7 +66,7 @@ func MustReflect(np ipld.NodePrototype, i interface{}) ipld.Node { // This may be useful if you need more direct control over allocations, // or want to fill in only part of a larger node assembly process using the reflect tool. // Data is accumulated by the NodeAssembler parameter, so no Node is returned. -func ReflectIntoAssembler(na ipld.NodeAssembler, i interface{}) error { +func ReflectIntoAssembler(na datamodel.NodeAssembler, i interface{}) error { return defaultReflector.ReflectIntoAssembler(na, i) } @@ -92,7 +92,7 @@ type Reflector struct { // Reflect is as per the package-scope function of the same name and signature, // but using the configuration in the Reflector struct. // See the package-scope function for documentation. -func (rcfg Reflector) Reflect(np ipld.NodePrototype, i interface{}) (ipld.Node, error) { +func (rcfg Reflector) Reflect(np datamodel.NodePrototype, i interface{}) (datamodel.Node, error) { nb := np.NewBuilder() if err := rcfg.ReflectIntoAssembler(nb, i); err != nil { return nil, err @@ -103,7 +103,7 @@ func (rcfg Reflector) Reflect(np ipld.NodePrototype, i interface{}) (ipld.Node, // ReflectIntoAssembler is as per the package-scope function of the same name and signature, // but using the configuration in the Reflector struct. // See the package-scope function for documentation. -func (rcfg Reflector) ReflectIntoAssembler(na ipld.NodeAssembler, i interface{}) error { +func (rcfg Reflector) ReflectIntoAssembler(na datamodel.NodeAssembler, i interface{}) error { // Cover the most common values with a type-switch, as it's faster than reflection. switch x := i.(type) { case map[string]string: diff --git a/fluent/reflect_test.go b/fluent/reflect_test.go index 1f7f75c6..a1266279 100644 --- a/fluent/reflect_test.go +++ b/fluent/reflect_test.go @@ -5,10 +5,10 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestReflect(t *testing.T) { @@ -23,7 +23,7 @@ func TestReflect(t *testing.T) { }, }) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) t.Run("CorrectContents", func(t *testing.T) { Wish(t, n.Length(), ShouldEqual, int64(3)) Wish(t, must.String(must.Node(n.LookupByString("k1"))), ShouldEqual, "fine") @@ -67,7 +67,7 @@ func TestReflect(t *testing.T) { M: Woo{"thanks", "really"}, }) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) t.Run("CorrectContents", func(t *testing.T) { Wish(t, n.Length(), ShouldEqual, int64(3)) Wish(t, must.String(must.Node(n.LookupByString("X"))), ShouldEqual, "fine") @@ -99,7 +99,7 @@ func TestReflect(t *testing.T) { } n, err := fluent.Reflect(basicnode.Prototype.Any, Bar{"foo"}) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, must.String(must.Node(n.LookupByString("Z"))), ShouldEqual, "foo") }) t.Run("Interface", func(t *testing.T) { @@ -108,16 +108,16 @@ func TestReflect(t *testing.T) { } n, err := fluent.Reflect(basicnode.Prototype.Any, Zaz{map[string]interface{}{"wow": "wee"}}) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) n, err = n.LookupByString("Z") Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, must.String(must.Node(n.LookupByString("wow"))), ShouldEqual, "wee") }) t.Run("Bytes", func(t *testing.T) { n, err := fluent.Reflect(basicnode.Prototype.Any, []byte{0x1, 0x2, 0x3}) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Bytes) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Bytes) b, err := n.AsBytes() Wish(t, err, ShouldEqual, nil) Wish(t, b, ShouldEqual, []byte{0x1, 0x2, 0x3}) @@ -129,10 +129,10 @@ func TestReflect(t *testing.T) { } n, err := fluent.Reflect(basicnode.Prototype.Any, Bar{[]byte{0x1, 0x2, 0x3}}) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) n, err = n.LookupByString("Z") Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Bytes) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Bytes) b, err := n.AsBytes() Wish(t, err, ShouldEqual, nil) Wish(t, b, ShouldEqual, []byte{0x1, 0x2, 0x3}) @@ -143,10 +143,10 @@ func TestReflect(t *testing.T) { } n, err := fluent.Reflect(basicnode.Prototype.Any, Zaz{[]byte{0x1, 0x2, 0x3}}) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) n, err = n.LookupByString("Z") Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Bytes) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Bytes) b, err := n.AsBytes() Wish(t, err, ShouldEqual, nil) Wish(t, b, ShouldEqual, []byte{0x1, 0x2, 0x3}) diff --git a/go.mod b/go.mod index 3795a9de..a35d97e2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ipld/go-ipld-prime -go 1.14 +go 1.16 require ( github.com/frankban/quicktest v1.11.3 diff --git a/linking.go b/linking.go index eaac72ce..4e0c7a73 100644 --- a/linking.go +++ b/linking.go @@ -1,158 +1,17 @@ package ipld import ( - "context" - "io" + "github.com/ipld/go-ipld-prime/linking" ) -// This file contains all the functions on LinkSystem. -// These are the helpful, user-facing functions we expect folks to use "most of the time" when loading and storing data. - -// Varations: -// - Load vs Store vs ComputeLink -// - With or without LinkContext? -// - Brevity would be nice but I can't think of what to name the functions, so: everything takes LinkContext. Zero value is fine though. -// - [for load direction only]: Prototype (and return Node|error) or Assembler (and just return error)? -// - naming: Load vs Fill. -// - 'Must' variants. - -// Can we get as far as a `QuickLoad(lnk Link) (Node, error)` function, which doesn't even ask you for a NodePrototype? -// No, not quite. (Alas.) If we tried to do so, and make it use `basicnode.Prototype`, we'd have import cycles; ded. - -func (lsys *LinkSystem) Load(lnkCtx LinkContext, lnk Link, np NodePrototype) (Node, error) { - nb := np.NewBuilder() - if err := lsys.Fill(lnkCtx, lnk, nb); err != nil { - return nil, err - } - nd := nb.Build() - if lsys.NodeReifier == nil { - return nd, nil - } - return lsys.NodeReifier(lnkCtx, nd, lsys) -} - -func (lsys *LinkSystem) MustLoad(lnkCtx LinkContext, lnk Link, np NodePrototype) Node { - if n, err := lsys.Load(lnkCtx, lnk, np); err != nil { - panic(err) - } else { - return n - } -} - -func (lsys *LinkSystem) Fill(lnkCtx LinkContext, lnk Link, na NodeAssembler) error { - if lnkCtx.Ctx == nil { - lnkCtx.Ctx = context.Background() - } - // Choose all the parts. - decoder, err := lsys.DecoderChooser(lnk) - if err != nil { - return ErrLinkingSetup{"could not choose a decoder", err} - } - hasher, err := lsys.HasherChooser(lnk.Prototype()) - if err != nil { - return ErrLinkingSetup{"could not choose a hasher", err} - } - if lsys.StorageReadOpener == nil { - return ErrLinkingSetup{"no storage configured for reading", io.ErrClosedPipe} // REVIEW: better cause? - } - // Open storage, read it, verify it, and feed the codec to assemble the nodes. - reader, err := lsys.StorageReadOpener(lnkCtx, lnk) - if err != nil { - return err - } - // TrustaedStorage indicates the data coming out of this reader has already been hashed and verified earlier. - // As a result, we can skip rehashing it - if lsys.TrustedStorage { - return decoder(na, reader) - } - // Tee the stream so that the hasher is fed as the unmarshal progresses through the stream. - tee := io.TeeReader(reader, hasher) - decodeErr := decoder(na, tee) - if decodeErr != nil { // It is important to security to check the hash before returning any other observation about the content. - // This copy is for data remaining the block that wasn't already pulled through the TeeReader by the decoder. - _, err := io.Copy(hasher, reader) - if err != nil { - return err - } - } - hash := hasher.Sum(nil) - // Bit of a jig to get something we can do the hash equality check on. - lnk2 := lnk.Prototype().BuildLink(hash) - if lnk2 != lnk { - return ErrHashMismatch{Actual: lnk2, Expected: lnk} - } - if decodeErr != nil { - return decodeErr - } - return nil -} - -func (lsys *LinkSystem) MustFill(lnkCtx LinkContext, lnk Link, na NodeAssembler) { - if err := lsys.Fill(lnkCtx, lnk, na); err != nil { - panic(err) - } -} - -func (lsys *LinkSystem) Store(lnkCtx LinkContext, lp LinkPrototype, n Node) (Link, error) { - if lnkCtx.Ctx == nil { - lnkCtx.Ctx = context.Background() - } - // Choose all the parts. - encoder, err := lsys.EncoderChooser(lp) - if err != nil { - return nil, ErrLinkingSetup{"could not choose an encoder", err} - } - hasher, err := lsys.HasherChooser(lp) - if err != nil { - return nil, ErrLinkingSetup{"could not choose a hasher", err} - } - if lsys.StorageWriteOpener == nil { - return nil, ErrLinkingSetup{"no storage configured for writing", io.ErrClosedPipe} // REVIEW: better cause? - } - // Open storage write stream, feed serial data to the storage and the hasher, and funnel the codec output into both. - writer, commitFn, err := lsys.StorageWriteOpener(lnkCtx) - if err != nil { - return nil, err - } - tee := io.MultiWriter(writer, hasher) - err = encoder(n, tee) - if err != nil { - return nil, err - } - lnk := lp.BuildLink(hasher.Sum(nil)) - return lnk, commitFn(lnk) -} - -func (lsys *LinkSystem) MustStore(lnkCtx LinkContext, lp LinkPrototype, n Node) Link { - if lnk, err := lsys.Store(lnkCtx, lp, n); err != nil { - panic(err) - } else { - return lnk - } -} - -// ComputeLink returns a Link for the given data, but doesn't do anything else -// (e.g. it doesn't try to store any of the serial-form data anywhere else). -func (lsys *LinkSystem) ComputeLink(lp LinkPrototype, n Node) (Link, error) { - encoder, err := lsys.EncoderChooser(lp) - if err != nil { - return nil, ErrLinkingSetup{"could not choose an encoder", err} - } - hasher, err := lsys.HasherChooser(lp) - if err != nil { - return nil, ErrLinkingSetup{"could not choose a hasher", err} - } - err = encoder(n, hasher) - if err != nil { - return nil, err - } - return lp.BuildLink(hasher.Sum(nil)), nil -} +type ( + LinkSystem = linking.LinkSystem + LinkContext = linking.LinkContext +) -func (lsys *LinkSystem) MustComputeLink(lp LinkPrototype, n Node) Link { - if lnk, err := lsys.ComputeLink(lp, n); err != nil { - panic(err) - } else { - return lnk - } -} +type ( + BlockReadOpener = linking.BlockReadOpener + BlockWriteOpener = linking.BlockWriteOpener + BlockWriteCommitter = linking.BlockWriteCommitter + NodeReifier = linking.NodeReifier +) diff --git a/linking/cid/cidLink.go b/linking/cid/cidLink.go index 31f1e703..02e8e4da 100644 --- a/linking/cid/cidLink.go +++ b/linking/cid/cidLink.go @@ -4,27 +4,27 @@ import ( "fmt" cid "github.com/ipfs/go-cid" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" multihash "github.com/multiformats/go-multihash" ) var ( - _ ipld.Link = Link{} - _ ipld.LinkPrototype = LinkPrototype{} + _ datamodel.Link = Link{} + _ datamodel.LinkPrototype = LinkPrototype{} ) -// Link implements the ipld.Link interface using a CID. +// Link implements the datamodel.Link interface using a CID. // See https://github.com/ipfs/go-cid for more information about CIDs. // // When using this value, typically you'll use it as `Link`, and not `*Link`. -// This includes when handling the value as an `ipld.Link` interface -- the non-pointer form is typically preferable. -// This is because the ipld.Link inteface is often desirable to be able to use as a golang map key, +// This includes when handling the value as an `datamodel.Link` interface -- the non-pointer form is typically preferable. +// This is because the datamodel.Link inteface is often desirable to be able to use as a golang map key, // and in that context, pointers would not result in the desired behavior. type Link struct { cid.Cid } -func (lnk Link) Prototype() ipld.LinkPrototype { +func (lnk Link) Prototype() datamodel.LinkPrototype { return LinkPrototype{lnk.Cid.Prefix()} } func (lnk Link) String() string { @@ -35,7 +35,7 @@ type LinkPrototype struct { cid.Prefix } -func (lp LinkPrototype) BuildLink(hashsum []byte) ipld.Link { +func (lp LinkPrototype) BuildLink(hashsum []byte) datamodel.Link { // Does this method body look surprisingly complex? I agree. // We actually have to do all this work. The go-cid package doesn't expose a constructor that just lets us directly set the bytes and the prefix numbers next to each other. // No, `cid.Prefix.Sum` is not the method you are looking for: that expects the whole data body. diff --git a/linking/cid/linksystem.go b/linking/cid/linksystem.go index e52c149e..89b7a790 100644 --- a/linking/cid/linksystem.go +++ b/linking/cid/linksystem.go @@ -6,18 +6,20 @@ import ( "github.com/multiformats/go-multihash/core" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" "github.com/ipld/go-ipld-prime/multicodec" ) -// DefaultLinkSystem returns an ipld.LinkSystem which uses cidlink.Link for ipld.Link. +// DefaultLinkSystem returns a linking.LinkSystem which uses cidlink.Link for datamodel.Link. // During selection of encoders, decoders, and hashers, it examines the multicodec indicator numbers and multihash indicator numbers from the CID, // and uses the default global multicodec registry (see the go-ipld-prime/multicodec package) for resolving codec implementations, // and the default global multihash registry (see the go-multihash/core package) for resolving multihash implementations. // // No storage functions are present in the returned LinkSystem. // The caller can assign those themselves as desired. -func DefaultLinkSystem() ipld.LinkSystem { +func DefaultLinkSystem() linking.LinkSystem { return LinkSystemUsingMulticodecRegistry(multicodec.DefaultRegistry) } @@ -26,9 +28,9 @@ func DefaultLinkSystem() ipld.LinkSystem { // This can help create a LinkSystem which uses different multicodec implementations than the global registry. // (Sometimes this can be desired if you want some parts of a program to support a more limited suite of codecs than other parts of the program, // or needed to use a different multicodec registry than the global one for synchronization purposes, or etc.) -func LinkSystemUsingMulticodecRegistry(mcReg multicodec.Registry) ipld.LinkSystem { - return ipld.LinkSystem{ - EncoderChooser: func(lp ipld.LinkPrototype) (ipld.Encoder, error) { +func LinkSystemUsingMulticodecRegistry(mcReg multicodec.Registry) linking.LinkSystem { + return linking.LinkSystem{ + EncoderChooser: func(lp datamodel.LinkPrototype) (codec.Encoder, error) { switch lp2 := lp.(type) { case LinkPrototype: fn, err := mcReg.LookupEncoder(lp2.GetCodec()) @@ -40,7 +42,7 @@ func LinkSystemUsingMulticodecRegistry(mcReg multicodec.Registry) ipld.LinkSyste return nil, fmt.Errorf("this encoderChooser can only handle cidlink.LinkPrototype; got %T", lp) } }, - DecoderChooser: func(lnk ipld.Link) (ipld.Decoder, error) { + DecoderChooser: func(lnk datamodel.Link) (codec.Decoder, error) { lp := lnk.Prototype() switch lp2 := lp.(type) { case LinkPrototype: @@ -53,7 +55,7 @@ func LinkSystemUsingMulticodecRegistry(mcReg multicodec.Registry) ipld.LinkSyste return nil, fmt.Errorf("this decoderChooser can only handle cidlink.LinkPrototype; got %T", lp) } }, - HasherChooser: func(lp ipld.LinkPrototype) (hash.Hash, error) { + HasherChooser: func(lp datamodel.LinkPrototype) (hash.Hash, error) { switch lp2 := lp.(type) { case LinkPrototype: h, err := multihash.GetHasher(lp2.MhType) diff --git a/linking/errors.go b/linking/errors.go new file mode 100644 index 00000000..1c3b549c --- /dev/null +++ b/linking/errors.go @@ -0,0 +1,30 @@ +package linking + +import ( + "fmt" + + "github.com/ipld/go-ipld-prime/datamodel" +) + +// ErrLinkingSetup is returned by methods on LinkSystem when some part of the system is not set up correctly, +// or when one of the components refuses to handle a Link or LinkPrototype given. +// (It is not yielded for errors from the storage nor codec systems once they've started; those errors rise without interference.) +type ErrLinkingSetup struct { + Detail string // Perhaps an enum here as well, which states which internal function was to blame? + Cause error +} + +func (e ErrLinkingSetup) Error() string { return fmt.Sprintf("%s: %v", e.Detail, e.Cause) } +func (e ErrLinkingSetup) Unwrap() error { return e.Cause } + +// ErrHashMismatch is the error returned when loading data and verifying its hash +// and finding that the loaded data doesn't re-hash to the expected value. +// It is typically seen returned by functions like LinkSystem.Load or LinkSystem.Fill. +type ErrHashMismatch struct { + Actual datamodel.Link + Expected datamodel.Link +} + +func (e ErrHashMismatch) Error() string { + return fmt.Sprintf("hash mismatch! %v (actual) != %v (expected)", e.Actual, e.Expected) +} diff --git a/linking/functions.go b/linking/functions.go new file mode 100644 index 00000000..db61121d --- /dev/null +++ b/linking/functions.go @@ -0,0 +1,160 @@ +package linking + +import ( + "context" + "io" + + "github.com/ipld/go-ipld-prime/datamodel" +) + +// This file contains all the functions on LinkSystem. +// These are the helpful, user-facing functions we expect folks to use "most of the time" when loading and storing data. + +// Varations: +// - Load vs Store vs ComputeLink +// - With or without LinkContext? +// - Brevity would be nice but I can't think of what to name the functions, so: everything takes LinkContext. Zero value is fine though. +// - [for load direction only]: Prototype (and return Node|error) or Assembler (and just return error)? +// - naming: Load vs Fill. +// - 'Must' variants. + +// Can we get as far as a `QuickLoad(lnk Link) (Node, error)` function, which doesn't even ask you for a NodePrototype? +// No, not quite. (Alas.) If we tried to do so, and make it use `basicnode.Prototype`, we'd have import cycles; ded. + +func (lsys *LinkSystem) Load(lnkCtx LinkContext, lnk datamodel.Link, np datamodel.NodePrototype) (datamodel.Node, error) { + nb := np.NewBuilder() + if err := lsys.Fill(lnkCtx, lnk, nb); err != nil { + return nil, err + } + nd := nb.Build() + if lsys.NodeReifier == nil { + return nd, nil + } + return lsys.NodeReifier(lnkCtx, nd, lsys) +} + +func (lsys *LinkSystem) MustLoad(lnkCtx LinkContext, lnk datamodel.Link, np datamodel.NodePrototype) datamodel.Node { + if n, err := lsys.Load(lnkCtx, lnk, np); err != nil { + panic(err) + } else { + return n + } +} + +func (lsys *LinkSystem) Fill(lnkCtx LinkContext, lnk datamodel.Link, na datamodel.NodeAssembler) error { + if lnkCtx.Ctx == nil { + lnkCtx.Ctx = context.Background() + } + // Choose all the parts. + decoder, err := lsys.DecoderChooser(lnk) + if err != nil { + return ErrLinkingSetup{"could not choose a decoder", err} + } + hasher, err := lsys.HasherChooser(lnk.Prototype()) + if err != nil { + return ErrLinkingSetup{"could not choose a hasher", err} + } + if lsys.StorageReadOpener == nil { + return ErrLinkingSetup{"no storage configured for reading", io.ErrClosedPipe} // REVIEW: better cause? + } + // Open storage, read it, verify it, and feed the codec to assemble the nodes. + reader, err := lsys.StorageReadOpener(lnkCtx, lnk) + if err != nil { + return err + } + // TrustaedStorage indicates the data coming out of this reader has already been hashed and verified earlier. + // As a result, we can skip rehashing it + if lsys.TrustedStorage { + return decoder(na, reader) + } + // Tee the stream so that the hasher is fed as the unmarshal progresses through the stream. + tee := io.TeeReader(reader, hasher) + decodeErr := decoder(na, tee) + if decodeErr != nil { // It is important to security to check the hash before returning any other observation about the content. + // This copy is for data remaining the block that wasn't already pulled through the TeeReader by the decoder. + _, err := io.Copy(hasher, reader) + if err != nil { + return err + } + } + hash := hasher.Sum(nil) + // Bit of a jig to get something we can do the hash equality check on. + lnk2 := lnk.Prototype().BuildLink(hash) + if lnk2 != lnk { + return ErrHashMismatch{Actual: lnk2, Expected: lnk} + } + if decodeErr != nil { + return decodeErr + } + return nil +} + +func (lsys *LinkSystem) MustFill(lnkCtx LinkContext, lnk datamodel.Link, na datamodel.NodeAssembler) { + if err := lsys.Fill(lnkCtx, lnk, na); err != nil { + panic(err) + } +} + +func (lsys *LinkSystem) Store(lnkCtx LinkContext, lp datamodel.LinkPrototype, n datamodel.Node) (datamodel.Link, error) { + if lnkCtx.Ctx == nil { + lnkCtx.Ctx = context.Background() + } + // Choose all the parts. + encoder, err := lsys.EncoderChooser(lp) + if err != nil { + return nil, ErrLinkingSetup{"could not choose an encoder", err} + } + hasher, err := lsys.HasherChooser(lp) + if err != nil { + return nil, ErrLinkingSetup{"could not choose a hasher", err} + } + if lsys.StorageWriteOpener == nil { + return nil, ErrLinkingSetup{"no storage configured for writing", io.ErrClosedPipe} // REVIEW: better cause? + } + // Open storage write stream, feed serial data to the storage and the hasher, and funnel the codec output into both. + writer, commitFn, err := lsys.StorageWriteOpener(lnkCtx) + if err != nil { + return nil, err + } + tee := io.MultiWriter(writer, hasher) + err = encoder(n, tee) + if err != nil { + return nil, err + } + lnk := lp.BuildLink(hasher.Sum(nil)) + return lnk, commitFn(lnk) +} + +func (lsys *LinkSystem) MustStore(lnkCtx LinkContext, lp datamodel.LinkPrototype, n datamodel.Node) datamodel.Link { + if lnk, err := lsys.Store(lnkCtx, lp, n); err != nil { + panic(err) + } else { + return lnk + } +} + +// ComputeLink returns a Link for the given data, but doesn't do anything else +// (e.g. it doesn't try to store any of the serial-form data anywhere else). +func (lsys *LinkSystem) ComputeLink(lp datamodel.LinkPrototype, n datamodel.Node) (datamodel.Link, error) { + encoder, err := lsys.EncoderChooser(lp) + if err != nil { + return nil, ErrLinkingSetup{"could not choose an encoder", err} + } + hasher, err := lsys.HasherChooser(lp) + if err != nil { + return nil, ErrLinkingSetup{"could not choose a hasher", err} + } + err = encoder(n, hasher) + if err != nil { + return nil, err + } + return lp.BuildLink(hasher.Sum(nil)), nil +} + +func (lsys *LinkSystem) MustComputeLink(lp datamodel.LinkPrototype, n datamodel.Node) datamodel.Link { + if lnk, err := lsys.ComputeLink(lp, n); err != nil { + panic(err) + } else { + return lnk + } +} diff --git a/linkingExamples_test.go b/linking/linkingExamples_test.go similarity index 86% rename from linkingExamples_test.go rename to linking/linkingExamples_test.go index b882ac8c..f77883f8 100644 --- a/linkingExamples_test.go +++ b/linking/linkingExamples_test.go @@ -1,15 +1,15 @@ -package ipld_test +package linking_test import ( "fmt" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" _ "github.com/ipld/go-ipld-prime/codec/dagcbor" "github.com/ipld/go-ipld-prime/fluent" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/storage" ) @@ -36,7 +36,7 @@ func ExampleLinkSystem_Store() { // We want to store the serialized data somewhere. // We'll use an in-memory store for this. (It's a package scoped variable.) // You can use any kind of storage system here; - // you just need a function that conforms to the ipld.BlockWriteOpener interface. + // you just need a function that conforms to the datamodel.BlockWriteOpener interface. lsys.StorageWriteOpener = (&store).OpenWrite // To create any links, first we need a LinkPrototype. @@ -68,9 +68,9 @@ func ExampleLinkSystem_Store() { // Now: time to apply the LinkSystem, and do the actual store operation! lnk, err := lsys.Store( - ipld.LinkContext{}, // The zero value is fine. Configure it it you want cancellability or other features. - lp, // The LinkPrototype says what codec and hashing to use. - n, // And here's our data. + linking.LinkContext{}, // The zero value is fine. Configure it it you want cancellability or other features. + lp, // The LinkPrototype says what codec and hashing to use. + n, // And here's our data. ) if err != nil { panic(err) @@ -103,10 +103,10 @@ func ExampleLinkSystem_Load() { // We'll use an in-memory store for this. (It's a package scoped variable.) // (This particular memory store was filled with the data we'll load earlier, during ExampleLinkSystem_Store.) // You can use any kind of storage system here; - // you just need a function that conforms to the ipld.BlockReadOpener interface. + // you just need a function that conforms to the datamodel.BlockReadOpener interface. lsys.StorageReadOpener = (&store).OpenRead - // We'll need to decide what in-memory implementation of ipld.Node we want to use. + // We'll need to decide what in-memory implementation of datamodel.Node we want to use. // Here, we'll use the "basicnode" implementation. This is a good getting-started choice. // But you could also use other implementations, or even a code-generated type with special features! np := basicnode.Prototype.Any @@ -117,9 +117,9 @@ func ExampleLinkSystem_Load() { // Apply the LinkSystem, and ask it to load our link! n, err := lsys.Load( - ipld.LinkContext{}, // The zero value is fine. Configure it it you want cancellability or other features. - lnk, // The Link we want to load! - np, // The NodePrototype says what kind of Node we want as a result. + linking.LinkContext{}, // The zero value is fine. Configure it it you want cancellability or other features. + lnk, // The Link we want to load! + np, // The NodePrototype says what kind of Node we want as a result. ) if err != nil { panic(err) diff --git a/linksystem.go b/linking/types.go similarity index 58% rename from linksystem.go rename to linking/types.go index 805f8996..8720669d 100644 --- a/linksystem.go +++ b/linking/types.go @@ -1,9 +1,12 @@ -package ipld +package linking import ( - "fmt" + "context" "hash" "io" + + "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/datamodel" ) // LinkSystem is a struct that composes all the individual functions @@ -27,88 +30,15 @@ import ( // Custom wrapping of BlockWriteOpener and BlockReadOpener are also common, // and may be reasonable if one wants to build application features that are block-aware. type LinkSystem struct { - EncoderChooser func(LinkPrototype) (Encoder, error) - DecoderChooser func(Link) (Decoder, error) - HasherChooser func(LinkPrototype) (hash.Hash, error) + EncoderChooser func(datamodel.LinkPrototype) (codec.Encoder, error) + DecoderChooser func(datamodel.Link) (codec.Decoder, error) + HasherChooser func(datamodel.LinkPrototype) (hash.Hash, error) StorageWriteOpener BlockWriteOpener StorageReadOpener BlockReadOpener TrustedStorage bool NodeReifier NodeReifier } -// The following two types define the two directions of transform that a codec can be expected to perform: -// from Node to serial stream, and from serial stream to Node (via a NodeAssembler). -// -// You'll find a couple of implementations matching this shape in subpackages of 'codec' in this module -// (these are the handful of encoders and decoders we ship as "batteries included"). -// Other encoder and decoder implementations can be found in other repositories/modules. -// It should also be easy to implement encodecs and decoders of your own! -// -// Encoder and Decoder functions can be used on their own, but are also often used via the LinkSystem construction, -// which handles all the other related operations necessary for a content-addressed storage system at once. -// -// Encoder and Decoder functions can be registered in the multicodec table in the `codec` package -// if they're providing functionality that matches the expectations for a multicodec identifier. -// This table will be used by some common EncoderChooser and DecoderChooser implementations -// (namely, the ones in LinkSystems produced by the `linking/cid` package). -type ( - // Encoder defines the shape of a function which traverses a Node tree - // and emits its data in a serialized form into an io.Writer. - // - // The dual of Encoder is a Decoder, which takes a NodeAssembler - // and fills it with deserialized data consumed from an io.Reader. - // Typically, Decoder and Encoder functions will be found in pairs, - // and will be expected to be able to round-trip each other's data. - // - // Encoder functions can be used directly. - // Encoder functions are also often used via a LinkSystem when working with content-addressed storage. - // LinkSystem methods will helpfully handle the entire process of traversing a Node tree, - // encoding this data, hashing it, streaming it to the writer, and committing it -- all as one step. - // - // An Encoder works with Nodes. - // If you have a native golang structure, and want to serialize it using an Encoder, - // you'll need to figure out how to transform that golang structure into an ipld.Node tree first. - // - // It may be useful to understand "multicodecs" when working with Encoders. - // In IPLD, a system called "multicodecs" is typically used to describe encoding foramts. - // A "multicodec indicator" is a number which describes an encoding; - // the Link implementations used in IPLD (CIDs) store a multicodec indicator in the Link; - // and in this library, a multicodec registry exists in the `codec` package, - // and can be used to associate a multicodec indicator number with an Encoder function. - // The default EncoderChooser in a LinkSystem will use this multicodec registry to select Encoder functions. - // However, you can construct a LinkSystem that uses any EncoderChooser you want. - // It is also possible to have and use Encoder functions that aren't registered as a multicodec at all... - // we just recommend being cautious of this, because it may make your data less recognizable - // when working with other systems that use multicodec indicators as part of their communication. - Encoder func(Node, io.Writer) error - - // Decoder defines the shape of a function which produces a Node tree - // by reading serialized data from an io.Reader. - // (Decoder doesn't itself return a Node directly, but rather takes a NodeAssembler as an argument, - // because this allows the caller more control over the Node implementation, - // as well as some control over allocations.) - // - // The dual of Decoder is an Encoder, which takes a Node and - // emits its data in a serialized form into an io.Writer. - // Typically, Decoder and Encoder functions will be found in pairs, - // and will be expected to be able to round-trip each other's data. - // - // Decoder functions can be used directly. - // Decoder functions are also often used via a LinkSystem when working with content-addressed storage. - // LinkSystem methods will helpfully handle the entire process of opening block readers, - // verifying the hash of the data stream, and applying a Decoder to build Nodes -- all as one step. - // - // A Decoder works with Nodes. - // If you have a native golang structure, and want to populate it with data using a Decoder, - // you'll need to either get a NodeAssembler which proxies data into that structure directly, - // or assemble a Node as intermediate storage and copy the data to the native structure as a separate step. - // - // It may be useful to understand "multicodecs" when working with Decoders. - // See the documentation on the Encoder function interface for more discussion of multicodecs, - // the multicodec table, and how this is typically connected to linking. - Decoder func(NodeAssembler, io.Reader) error -) - // The following three types are the key functionality we need from a "blockstore". // // Some libraries might provide a "blockstore" object that has these as methods; @@ -156,7 +86,7 @@ type ( // // Some implementations of BlockWriteOpener and BlockReadOpener may be // found in the storage package. Applications are also free to write their own. - BlockReadOpener func(LinkContext, Link) (io.Reader, error) + BlockReadOpener func(LinkContext, datamodel.Link) (io.Reader, error) // BlockWriteOpener defines the shape of a function used to open a writer // into which data can be streamed, and which will eventually be "commited". @@ -206,7 +136,7 @@ type ( // in a content-addressable fashion. // See the documentation of BlockWriteOpener for more description of this // and an example of how this is likely to be reduced to practice. - BlockWriteCommitter func(Link) error + BlockWriteCommitter func(datamodel.Link) error // NodeReifier defines the shape of a function that given a node with no schema // or a basic schema, constructs Advanced Data Layout node @@ -221,16 +151,45 @@ type ( // - nil, error = the simple node should have been converted to an ADL but something // went wrong when we tried to do so // - NodeReifier func(LinkContext, Node, *LinkSystem) (Node, error) + NodeReifier func(LinkContext, datamodel.Node, *LinkSystem) (datamodel.Node, error) ) -// ErrLinkingSetup is returned by methods on LinkSystem when some part of the system is not set up correctly, -// or when one of the components refuses to handle a Link or LinkPrototype given. -// (It is not yielded for errors from the storage nor codec systems once they've started; those errors rise without interference.) -type ErrLinkingSetup struct { - Detail string // Perhaps an enum here as well, which states which internal function was to blame? - Cause error -} +// LinkContext is a structure carrying ancilary information that may be used +// while loading or storing data -- see its usage in BlockReadOpener, BlockWriteOpener, +// and in the methods on LinkSystem which handle loading and storing data. +// +// A zero value for LinkContext is generally acceptable in any functions that use it. +// In this case, any operations that need a context.Context will quietly use Context.Background +// (thus being uncancellable) and simply have no additional information to work with. +type LinkContext struct { + // Ctx is the familiar golang Context pattern. + // Use this for cancellation, or attaching additional info + // (for example, perhaps to pass auth tokens through to the storage functions). + Ctx context.Context + + // Path where the link was encountered. May be zero. + // + // Functions in the traversal package will set this automatically. + LinkPath datamodel.Path -func (e ErrLinkingSetup) Error() string { return fmt.Sprintf("%s: %v", e.Detail, e.Cause) } -func (e ErrLinkingSetup) Unwrap() error { return e.Cause } + // When traversing data or encoding: the Node containing the link -- + // it may have additional type info, etc, that can be accessed. + // When building / decoding: not present. + // + // Functions in the traversal package will set this automatically. + LinkNode datamodel.Node + + // When building data or decoding: the NodeAssembler that will be receiving the link -- + // it may have additional type info, etc, that can be accessed. + // When traversing / encoding: not present. + // + // Functions in the traversal package will set this automatically. + LinkNodeAssembler datamodel.NodeAssembler + + // Parent of the LinkNode. May be zero. + // + // Functions in the traversal package will set this automatically. + ParentNode datamodel.Node + + // REVIEW: ParentNode in LinkContext -- so far, this has only ever been hypothetically useful. Keep or drop? +} diff --git a/multicodec/defaultRegistry.go b/multicodec/defaultRegistry.go index b81066a6..573d2b77 100644 --- a/multicodec/defaultRegistry.go +++ b/multicodec/defaultRegistry.go @@ -1,7 +1,7 @@ package multicodec import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/codec" ) // DefaultRegistry is a multicodec.Registry instance which is global to the program, @@ -22,7 +22,7 @@ import ( // and eschew using the global default. var DefaultRegistry = Registry{} -// RegisterEncoder updates the global DefaultRegistry to map a multicodec indicator number to the given ipld.Encoder function. +// RegisterEncoder updates the global DefaultRegistry to map a multicodec indicator number to the given codec.Encoder function. // The encoder functions registered can be subsequently looked up using LookupEncoder. // It is a shortcut to the RegisterEncoder method on the global DefaultRegistry. // @@ -40,20 +40,20 @@ var DefaultRegistry = Registry{} // This should have the desired effect because the root of the import tree has its init time effect last. // Alternatively, one can just avoid use of this registry entirely: // do this by making a LinkSystem that uses a custom EncoderChooser function. -func RegisterEncoder(indicator uint64, encodeFunc ipld.Encoder) { +func RegisterEncoder(indicator uint64, encodeFunc codec.Encoder) { DefaultRegistry.RegisterEncoder(indicator, encodeFunc) } -// LookupEncoder yields an ipld.Encoder function matching a multicodec indicator code number. +// LookupEncoder yields a codec.Encoder function matching a multicodec indicator code number. // It is a shortcut to the LookupEncoder method on the global DefaultRegistry. // // To be available from this lookup function, an encoder must have been registered // for this indicator number by an earlier call to the RegisterEncoder function. -func LookupEncoder(indicator uint64) (ipld.Encoder, error) { +func LookupEncoder(indicator uint64) (codec.Encoder, error) { return DefaultRegistry.LookupEncoder(indicator) } -// ListEncoders returns a list of multicodec indicators for which an ipld.Encoder is registered. +// ListEncoders returns a list of multicodec indicators for which a codec.Encoder is registered. // The list is in no particular order. // It is a shortcut to the ListEncoders method on the global DefaultRegistry. // @@ -69,7 +69,7 @@ func ListEncoders() []uint64 { return DefaultRegistry.ListEncoders() } -// RegisterDecoder updates the global DefaultRegistry a map a multicodec indicator number to the given ipld.Decoder function. +// RegisterDecoder updates the global DefaultRegistry a map a multicodec indicator number to the given codec.Decoder function. // The decoder functions registered can be subsequently looked up using LookupDecoder. // It is a shortcut to the RegisterDecoder method on the global DefaultRegistry. // @@ -87,20 +87,20 @@ func ListEncoders() []uint64 { // This should have the desired effect because the root of the import tree has its init time effect last. // Alternatively, one can just avoid use of this registry entirely: // do this by making a LinkSystem that uses a custom DecoderChooser function. -func RegisterDecoder(indicator uint64, decodeFunc ipld.Decoder) { +func RegisterDecoder(indicator uint64, decodeFunc codec.Decoder) { DefaultRegistry.RegisterDecoder(indicator, decodeFunc) } -// LookupDecoder yields an ipld.Decoder function matching a multicodec indicator code number. +// LookupDecoder yields a codec.Decoder function matching a multicodec indicator code number. // It is a shortcut to the LookupDecoder method on the global DefaultRegistry. // // To be available from this lookup function, an decoder must have been registered // for this indicator number by an earlier call to the RegisterDecoder function. -func LookupDecoder(indicator uint64) (ipld.Decoder, error) { +func LookupDecoder(indicator uint64) (codec.Decoder, error) { return DefaultRegistry.LookupDecoder(indicator) } -// ListDecoders returns a list of multicodec indicators for which an ipld.Decoder is registered. +// ListDecoders returns a list of multicodec indicators for which a codec.Decoder is registered. // The list is in no particular order. // It is a shortcut to the ListDecoders method on the global DefaultRegistry. // diff --git a/multicodec/registry.go b/multicodec/registry.go index d829f7db..fd35ff0f 100644 --- a/multicodec/registry.go +++ b/multicodec/registry.go @@ -3,12 +3,12 @@ package multicodec import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/codec" ) -// Registry is a structure for storing mappings of multicodec indicator numbers to ipld.Encoder and ipld.Decoder functions. +// Registry is a structure for storing mappings of multicodec indicator numbers to codec.Encoder and codec.Decoder functions. // -// The most typical usage of this structure is in combination with an ipld.LinkSystem. +// The most typical usage of this structure is in combination with a codec.LinkSystem. // For example, a linksystem using CIDs and a custom multicodec registry can be constructed // using cidlink.LinkSystemUsingMulticodecRegistry. // @@ -16,7 +16,7 @@ import ( // (Typically, it is recommended to do initialization earlier in a program, before fanning out goroutines; // this avoids the need for mutexing overhead.) // -// go-ipld-prime also has a default registry, which has the same methods as this structure, but are at package scope. +// go-ipld also has a default registry, which has the same methods as this structure, but are at package scope. // Some systems, like cidlink.DefaultLinkSystem, will use this default registry. // However, this default registry is global to the entire program. // This Registry type is for helping if you wish to make your own registry which does not share that global state. @@ -26,21 +26,21 @@ import ( // You should not use indicator numbers which are not specified in that table // (however, there is nothing in this implementation that will attempt to stop you, either; please behave). type Registry struct { - encoders map[uint64]ipld.Encoder - decoders map[uint64]ipld.Decoder + encoders map[uint64]codec.Encoder + decoders map[uint64]codec.Decoder } func (r *Registry) ensureInit() { if r.encoders != nil { return } - r.encoders = make(map[uint64]ipld.Encoder) - r.decoders = make(map[uint64]ipld.Decoder) + r.encoders = make(map[uint64]codec.Encoder) + r.decoders = make(map[uint64]codec.Decoder) } -// RegisterEncoder updates a simple map of multicodec indicator number to ipld.Encoder function. +// RegisterEncoder updates a simple map of multicodec indicator number to codec.Encoder function. // The encoder functions registered can be subsequently looked up using LookupEncoder. -func (r *Registry) RegisterEncoder(indicator uint64, encodeFunc ipld.Encoder) { +func (r *Registry) RegisterEncoder(indicator uint64, encodeFunc codec.Encoder) { r.ensureInit() if encodeFunc == nil { panic("not sensible to attempt to register a nil function") @@ -48,11 +48,11 @@ func (r *Registry) RegisterEncoder(indicator uint64, encodeFunc ipld.Encoder) { r.encoders[indicator] = encodeFunc } -// LookupEncoder yields an ipld.Encoder function matching a multicodec indicator code number. +// LookupEncoder yields a codec.Encoder function matching a multicodec indicator code number. // // To be available from this lookup function, an encoder must have been registered // for this indicator number by an earlier call to the RegisterEncoder function. -func (r *Registry) LookupEncoder(indicator uint64) (ipld.Encoder, error) { +func (r *Registry) LookupEncoder(indicator uint64) (codec.Encoder, error) { encodeFunc, exists := r.encoders[indicator] if !exists { return nil, fmt.Errorf("no encoder registered for multicodec code %d (0x%x)", indicator, indicator) @@ -60,7 +60,7 @@ func (r *Registry) LookupEncoder(indicator uint64) (ipld.Encoder, error) { return encodeFunc, nil } -// ListEncoders returns a list of multicodec indicators for which an ipld.Encoder is registered. +// ListEncoders returns a list of multicodec indicators for which a codec.Encoder is registered. // The list is in no particular order. func (r *Registry) ListEncoders() []uint64 { encoders := make([]uint64, 0, len(r.encoders)) @@ -70,9 +70,9 @@ func (r *Registry) ListEncoders() []uint64 { return encoders } -// RegisterDecoder updates a simple map of multicodec indicator number to ipld.Decoder function. +// RegisterDecoder updates a simple map of multicodec indicator number to codec.Decoder function. // The decoder functions registered can be subsequently looked up using LookupDecoder. -func (r *Registry) RegisterDecoder(indicator uint64, decodeFunc ipld.Decoder) { +func (r *Registry) RegisterDecoder(indicator uint64, decodeFunc codec.Decoder) { r.ensureInit() if decodeFunc == nil { panic("not sensible to attempt to register a nil function") @@ -80,11 +80,11 @@ func (r *Registry) RegisterDecoder(indicator uint64, decodeFunc ipld.Decoder) { r.decoders[indicator] = decodeFunc } -// LookupDecoder yields an ipld.Decoder function matching a multicodec indicator code number. +// LookupDecoder yields a codec.Decoder function matching a multicodec indicator code number. // // To be available from this lookup function, an decoder must have been registered // for this indicator number by an earlier call to the RegisterDecoder function. -func (r *Registry) LookupDecoder(indicator uint64) (ipld.Decoder, error) { +func (r *Registry) LookupDecoder(indicator uint64) (codec.Decoder, error) { decodeFunc, exists := r.decoders[indicator] if !exists { return nil, fmt.Errorf("no decoder registered for multicodec code %d (0x%x)", indicator, indicator) @@ -92,7 +92,7 @@ func (r *Registry) LookupDecoder(indicator uint64) (ipld.Decoder, error) { return decodeFunc, nil } -// ListDecoders returns a list of multicodec indicators for which an ipld.Decoder is registered. +// ListDecoders returns a list of multicodec indicators for which a codec.Decoder is registered. // The list is in no particular order. func (r *Registry) ListDecoders() []uint64 { decoders := make([]uint64, 0, len(r.decoders)) diff --git a/must/must.go b/must/must.go index 382d7ed6..86f9eba4 100644 --- a/must/must.go +++ b/must/must.go @@ -17,7 +17,7 @@ package must import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -38,7 +38,7 @@ func NotError(e error) { // // must.Node(SomeNodeBuilder{}.CreateString("a")) // -func Node(n ipld.Node, e error) ipld.Node { +func Node(n datamodel.Node, e error) datamodel.Node { if e != nil { panic(e) } @@ -47,14 +47,14 @@ func Node(n ipld.Node, e error) ipld.Node { // must.TypedNode helps write pointfree/chainable-style code // by taking a Node and an error and transforming any error into a panic. -// It will also cast the `ipld.Node` to a `schema.TypedNode`, panicking if impossible. +// It will also cast the `datamodel.Node` to a `schema.TypedNode`, panicking if impossible. // // Because golang supports implied destructuring of multiple-return functions // into arguments for another funtion of matching arity, it can be used like this: // // must.TypedNode(SomeNodeBuilder{}.CreateString("a")) // -func TypedNode(n ipld.Node, e error) schema.TypedNode { +func TypedNode(n datamodel.Node, e error) schema.TypedNode { if e != nil { panic(e) } @@ -71,7 +71,7 @@ func True(v bool) { // must.String unboxes the given Node via AsString, // panicking in the case that the Node isn't of string kind, // and otherwise returning the bare native string. -func String(n ipld.Node) string { +func String(n datamodel.Node) string { if v, err := n.AsString(); err != nil { panic(err) } else { @@ -82,7 +82,7 @@ func String(n ipld.Node) string { // must.Int unboxes the given Node via AsInt, // panicking in the case that the Node isn't of int kind, // and otherwise returning the bare native int. -func Int(n ipld.Node) int64 { +func Int(n datamodel.Node) int64 { if v, err := n.AsInt(); err != nil { panic(err) } else { diff --git a/node/basic/deprecated.go b/node/basic/deprecated.go new file mode 100644 index 00000000..e32032cd --- /dev/null +++ b/node/basic/deprecated.go @@ -0,0 +1,36 @@ +// This is a transitional package: please move your references to `node/basicnode`. +// The new package is identical: we've renamed the import path only. +// +// All content in this package is a thin wrapper around `node/basicnode`. +// Please update at your earliest convenience. +// +// This package will eventually be removed. +package basicnode + +import ( + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" + "github.com/ipld/go-ipld-prime/node/basicnode" +) + +var Prototype = basicnode.Prototype + +func Chooser(_ datamodel.Link, _ linking.LinkContext) (datamodel.NodePrototype, error) { + return basicnode.Chooser(nil, linking.LinkContext{}) +} +func NewBool(value bool) datamodel.Node { return basicnode.NewBool(value) } +func NewBytes(value []byte) datamodel.Node { return basicnode.NewBytes(value) } +func NewFloat(value float64) datamodel.Node { return basicnode.NewFloat(value) } +func NewInt(value int64) datamodel.Node { return basicnode.NewInt(value) } +func NewLink(value datamodel.Link) datamodel.Node { return basicnode.NewLink(value) } +func NewString(value string) datamodel.Node { return basicnode.NewString(value) } + +type Prototype__Any = basicnode.Prototype__Any +type Prototype__Bool = basicnode.Prototype__Bool +type Prototype__Bytes = basicnode.Prototype__Bytes +type Prototype__Float = basicnode.Prototype__Float +type Prototype__Int = basicnode.Prototype__Int +type Prototype__Link = basicnode.Prototype__Link +type Prototype__List = basicnode.Prototype__List +type Prototype__Map = basicnode.Prototype__Map +type Prototype__String = basicnode.Prototype__String diff --git a/node/basic/HACKME.md b/node/basicnode/HACKME.md similarity index 99% rename from node/basic/HACKME.md rename to node/basicnode/HACKME.md index bf2f74a9..dad98f5f 100644 --- a/node/basic/HACKME.md +++ b/node/basicnode/HACKME.md @@ -134,7 +134,7 @@ The 'Prototype' singleton is one way to access the NodePrototype in this package their exported types are another equivalent way. ```go -basicnode.Prototype.Map = basicnode.Prototype__Map{} +basicnode.Prototype.Map = basicnode.Prototype.Map ``` It is recommended to use the singleton style; diff --git a/node/basic/any.go b/node/basicnode/any.go similarity index 64% rename from node/basic/any.go rename to node/basicnode/any.go index f472b136..023f8fc9 100644 --- a/node/basic/any.go +++ b/node/basicnode/any.go @@ -1,14 +1,15 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" ) var ( - //_ ipld.Node = &anyNode{} - _ ipld.NodePrototype = Prototype__Any{} - _ ipld.NodeBuilder = &anyBuilder{} - //_ ipld.NodeAssembler = &anyAssembler{} + //_ datamodel.Node = &anyNode{} + _ datamodel.NodePrototype = Prototype__Any{} + _ datamodel.NodeBuilder = &anyBuilder{} + //_ datamodel.NodeAssembler = &anyAssembler{} ) // Note that we don't use a "var _" declaration to assert that Chooser @@ -21,28 +22,10 @@ var ( // or with another chooser layer on top, such as: // // prototypeChooser := dagpb.AddSupportToChooser(basicnode.Chooser) -func Chooser(_ ipld.Link, _ ipld.LinkContext) (ipld.NodePrototype, error) { - return Prototype__Any{}, nil +func Chooser(_ datamodel.Link, _ linking.LinkContext) (datamodel.NodePrototype, error) { + return Prototype.Any, nil } -// anyNode is a union meant for alloc amortization; see anyAssembler. -// Note that anyBuilder doesn't use anyNode, because it's not aiming to amortize anything. -// -// REVIEW: if there's any point in keeping this around. It's here for completeness, -// but not currently used anywhere in package, and also not currently exported. -// type anyNode struct { -// kind ipld.Kind -// -// plainMap -// plainList -// plainBool -// plainInt -// plainFloat -// plainString -// plainBytes -// plainLink -// } - // -- Node interface methods --> // Unimplemented at present -- see "REVIEW" comment on anyNode. @@ -51,7 +34,7 @@ func Chooser(_ ipld.Link, _ ipld.LinkContext) (ipld.NodePrototype, error) { type Prototype__Any struct{} -func (Prototype__Any) NewBuilder() ipld.NodeBuilder { +func (Prototype__Any) NewBuilder() datamodel.NodeBuilder { return &anyBuilder{} } @@ -71,7 +54,7 @@ type anyBuilder struct { // kind is set on first interaction, and used to select which builder to delegate 'Build' to! // As soon as it's been set to a value other than zero (being "Invalid"), all other Assign/Begin calls will fail since something is already in progress. // May also be set to the magic value '99', which means "i dunno, I'm just carrying another node of unknown prototype". - kind ipld.Kind + kind datamodel.Kind // Only one of the following ends up being used... // but we don't know in advance which one, so all are embeded here. @@ -84,117 +67,117 @@ type anyBuilder struct { mapBuilder plainMap__Builder listBuilder plainList__Builder - scalarNode ipld.Node + scalarNode datamodel.Node } func (nb *anyBuilder) Reset() { *nb = anyBuilder{} } -func (nb *anyBuilder) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - if nb.kind != ipld.Kind_Invalid { +func (nb *anyBuilder) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Map + nb.kind = datamodel.Kind_Map nb.mapBuilder.w = &plainMap{} return nb.mapBuilder.BeginMap(sizeHint) } -func (nb *anyBuilder) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - if nb.kind != ipld.Kind_Invalid { +func (nb *anyBuilder) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_List + nb.kind = datamodel.Kind_List nb.listBuilder.w = &plainList{} return nb.listBuilder.BeginList(sizeHint) } func (nb *anyBuilder) AssignNull() error { - if nb.kind != ipld.Kind_Invalid { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Null + nb.kind = datamodel.Kind_Null return nil } func (nb *anyBuilder) AssignBool(v bool) error { - if nb.kind != ipld.Kind_Invalid { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Bool + nb.kind = datamodel.Kind_Bool nb.scalarNode = NewBool(v) return nil } func (nb *anyBuilder) AssignInt(v int64) error { - if nb.kind != ipld.Kind_Invalid { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Int + nb.kind = datamodel.Kind_Int nb.scalarNode = NewInt(v) return nil } func (nb *anyBuilder) AssignFloat(v float64) error { - if nb.kind != ipld.Kind_Invalid { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Float + nb.kind = datamodel.Kind_Float nb.scalarNode = NewFloat(v) return nil } func (nb *anyBuilder) AssignString(v string) error { - if nb.kind != ipld.Kind_Invalid { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_String + nb.kind = datamodel.Kind_String nb.scalarNode = NewString(v) return nil } func (nb *anyBuilder) AssignBytes(v []byte) error { - if nb.kind != ipld.Kind_Invalid { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Bytes + nb.kind = datamodel.Kind_Bytes nb.scalarNode = NewBytes(v) return nil } -func (nb *anyBuilder) AssignLink(v ipld.Link) error { - if nb.kind != ipld.Kind_Invalid { +func (nb *anyBuilder) AssignLink(v datamodel.Link) error { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } - nb.kind = ipld.Kind_Link + nb.kind = datamodel.Kind_Link nb.scalarNode = NewLink(v) return nil } -func (nb *anyBuilder) AssignNode(v ipld.Node) error { - if nb.kind != ipld.Kind_Invalid { +func (nb *anyBuilder) AssignNode(v datamodel.Node) error { + if nb.kind != datamodel.Kind_Invalid { panic("misuse") } nb.kind = 99 nb.scalarNode = v return nil } -func (anyBuilder) Prototype() ipld.NodePrototype { - return Prototype__Any{} +func (anyBuilder) Prototype() datamodel.NodePrototype { + return Prototype.Any } -func (nb *anyBuilder) Build() ipld.Node { +func (nb *anyBuilder) Build() datamodel.Node { switch nb.kind { - case ipld.Kind_Invalid: + case datamodel.Kind_Invalid: panic("misuse") - case ipld.Kind_Map: + case datamodel.Kind_Map: return nb.mapBuilder.Build() - case ipld.Kind_List: + case datamodel.Kind_List: return nb.listBuilder.Build() - case ipld.Kind_Null: - return ipld.Null - case ipld.Kind_Bool: + case datamodel.Kind_Null: + return datamodel.Null + case datamodel.Kind_Bool: return nb.scalarNode - case ipld.Kind_Int: + case datamodel.Kind_Int: return nb.scalarNode - case ipld.Kind_Float: + case datamodel.Kind_Float: return nb.scalarNode - case ipld.Kind_String: + case datamodel.Kind_String: return nb.scalarNode - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: return nb.scalarNode - case ipld.Kind_Link: + case datamodel.Kind_Link: return nb.scalarNode case 99: return nb.scalarNode diff --git a/node/basic/any_test.go b/node/basicnode/any_test.go similarity index 50% rename from node/basic/any_test.go rename to node/basicnode/any_test.go index 5ec3b4a4..0f45d8ef 100644 --- a/node/basic/any_test.go +++ b/node/basicnode/any_test.go @@ -3,18 +3,18 @@ package basicnode_test import ( "testing" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/node/tests" ) func TestAnyBeingString(t *testing.T) { - tests.SpecTestString(t, basicnode.Prototype__Any{}) + tests.SpecTestString(t, basicnode.Prototype.Any) } func TestAnyBeingMapStrInt(t *testing.T) { - tests.SpecTestMapStrInt(t, basicnode.Prototype__Any{}) + tests.SpecTestMapStrInt(t, basicnode.Prototype.Any) } func TestAnyBeingMapStrMapStrInt(t *testing.T) { - tests.SpecTestMapStrMapStrInt(t, basicnode.Prototype__Any{}) + tests.SpecTestMapStrMapStrInt(t, basicnode.Prototype.Any) } diff --git a/node/basic/bench_test.go b/node/basicnode/bench_test.go similarity index 66% rename from node/basic/bench_test.go rename to node/basicnode/bench_test.go index bd1aa6e7..8822fb10 100644 --- a/node/basic/bench_test.go +++ b/node/basicnode/bench_test.go @@ -3,14 +3,14 @@ package basicnode_test import ( "testing" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/node/tests" ) func BenchmarkSpec_Walk_Map3StrInt(b *testing.B) { - tests.BenchmarkSpec_Walk_Map3StrInt(b, basicnode.Prototype__Any{}) + tests.BenchmarkSpec_Walk_Map3StrInt(b, basicnode.Prototype.Any) } func BenchmarkSpec_Walk_MapNStrMap3StrInt(b *testing.B) { - tests.BenchmarkSpec_Walk_MapNStrMap3StrInt(b, basicnode.Prototype__Any{}) + tests.BenchmarkSpec_Walk_MapNStrMap3StrInt(b, basicnode.Prototype.Any) } diff --git a/node/basic/bool.go b/node/basicnode/bool.go similarity index 64% rename from node/basic/bool.go rename to node/basicnode/bool.go index 3e9df965..ecf85fad 100644 --- a/node/basic/bool.go +++ b/node/basicnode/bool.go @@ -1,46 +1,46 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = plainBool(false) - _ ipld.NodePrototype = Prototype__Bool{} - _ ipld.NodeBuilder = &plainBool__Builder{} - _ ipld.NodeAssembler = &plainBool__Assembler{} + _ datamodel.Node = plainBool(false) + _ datamodel.NodePrototype = Prototype__Bool{} + _ datamodel.NodeBuilder = &plainBool__Builder{} + _ datamodel.NodeAssembler = &plainBool__Assembler{} ) -func NewBool(value bool) ipld.Node { +func NewBool(value bool) datamodel.Node { v := plainBool(value) return &v } -// plainBool is a simple boxed boolean that complies with ipld.Node. +// plainBool is a simple boxed boolean that complies with datamodel.Node. type plainBool bool // -- Node interface methods --> -func (plainBool) Kind() ipld.Kind { - return ipld.Kind_Bool +func (plainBool) Kind() datamodel.Kind { + return datamodel.Kind_Bool } -func (plainBool) LookupByString(string) (ipld.Node, error) { +func (plainBool) LookupByString(string) (datamodel.Node, error) { return mixins.Bool{TypeName: "bool"}.LookupByString("") } -func (plainBool) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (plainBool) LookupByNode(key datamodel.Node) (datamodel.Node, error) { return mixins.Bool{TypeName: "bool"}.LookupByNode(nil) } -func (plainBool) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainBool) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Bool{TypeName: "bool"}.LookupByIndex(0) } -func (plainBool) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (plainBool) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Bool{TypeName: "bool"}.LookupBySegment(seg) } -func (plainBool) MapIterator() ipld.MapIterator { +func (plainBool) MapIterator() datamodel.MapIterator { return nil } -func (plainBool) ListIterator() ipld.ListIterator { +func (plainBool) ListIterator() datamodel.ListIterator { return nil } func (plainBool) Length() int64 { @@ -67,10 +67,10 @@ func (plainBool) AsString() (string, error) { func (plainBool) AsBytes() ([]byte, error) { return mixins.Bool{TypeName: "bool"}.AsBytes() } -func (plainBool) AsLink() (ipld.Link, error) { +func (plainBool) AsLink() (datamodel.Link, error) { return mixins.Bool{TypeName: "bool"}.AsLink() } -func (plainBool) Prototype() ipld.NodePrototype { +func (plainBool) Prototype() datamodel.NodePrototype { return Prototype__Bool{} } @@ -78,7 +78,7 @@ func (plainBool) Prototype() ipld.NodePrototype { type Prototype__Bool struct{} -func (Prototype__Bool) NewBuilder() ipld.NodeBuilder { +func (Prototype__Bool) NewBuilder() datamodel.NodeBuilder { var w plainBool return &plainBool__Builder{plainBool__Assembler{w: &w}} } @@ -89,7 +89,7 @@ type plainBool__Builder struct { plainBool__Assembler } -func (nb *plainBool__Builder) Build() ipld.Node { +func (nb *plainBool__Builder) Build() datamodel.Node { return nb.w } func (nb *plainBool__Builder) Reset() { @@ -103,10 +103,10 @@ type plainBool__Assembler struct { w *plainBool } -func (plainBool__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainBool__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.BoolAssembler{TypeName: "bool"}.BeginMap(0) } -func (plainBool__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainBool__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.BoolAssembler{TypeName: "bool"}.BeginList(0) } func (plainBool__Assembler) AssignNull() error { @@ -128,10 +128,10 @@ func (plainBool__Assembler) AssignString(string) error { func (plainBool__Assembler) AssignBytes([]byte) error { return mixins.BoolAssembler{TypeName: "bool"}.AssignBytes(nil) } -func (plainBool__Assembler) AssignLink(ipld.Link) error { +func (plainBool__Assembler) AssignLink(datamodel.Link) error { return mixins.BoolAssembler{TypeName: "bool"}.AssignLink(nil) } -func (na *plainBool__Assembler) AssignNode(v ipld.Node) error { +func (na *plainBool__Assembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsBool(); err != nil { return err } else { @@ -139,6 +139,6 @@ func (na *plainBool__Assembler) AssignNode(v ipld.Node) error { return nil } } -func (plainBool__Assembler) Prototype() ipld.NodePrototype { +func (plainBool__Assembler) Prototype() datamodel.NodePrototype { return Prototype__Bool{} } diff --git a/node/basic/bytes.go b/node/basicnode/bytes.go similarity index 64% rename from node/basic/bytes.go rename to node/basicnode/bytes.go index d1586b05..ae3d1832 100644 --- a/node/basic/bytes.go +++ b/node/basicnode/bytes.go @@ -1,46 +1,46 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = plainBytes(nil) - _ ipld.NodePrototype = Prototype__Bytes{} - _ ipld.NodeBuilder = &plainBytes__Builder{} - _ ipld.NodeAssembler = &plainBytes__Assembler{} + _ datamodel.Node = plainBytes(nil) + _ datamodel.NodePrototype = Prototype__Bytes{} + _ datamodel.NodeBuilder = &plainBytes__Builder{} + _ datamodel.NodeAssembler = &plainBytes__Assembler{} ) -func NewBytes(value []byte) ipld.Node { +func NewBytes(value []byte) datamodel.Node { v := plainBytes(value) return &v } -// plainBytes is a simple boxed byte slice that complies with ipld.Node. +// plainBytes is a simple boxed byte slice that complies with datamodel.Node. type plainBytes []byte // -- Node interface methods --> -func (plainBytes) Kind() ipld.Kind { - return ipld.Kind_Bytes +func (plainBytes) Kind() datamodel.Kind { + return datamodel.Kind_Bytes } -func (plainBytes) LookupByString(string) (ipld.Node, error) { +func (plainBytes) LookupByString(string) (datamodel.Node, error) { return mixins.Bytes{TypeName: "bytes"}.LookupByString("") } -func (plainBytes) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (plainBytes) LookupByNode(key datamodel.Node) (datamodel.Node, error) { return mixins.Bytes{TypeName: "bytes"}.LookupByNode(nil) } -func (plainBytes) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainBytes) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Bytes{TypeName: "bytes"}.LookupByIndex(0) } -func (plainBytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (plainBytes) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Bytes{TypeName: "bytes"}.LookupBySegment(seg) } -func (plainBytes) MapIterator() ipld.MapIterator { +func (plainBytes) MapIterator() datamodel.MapIterator { return nil } -func (plainBytes) ListIterator() ipld.ListIterator { +func (plainBytes) ListIterator() datamodel.ListIterator { return nil } func (plainBytes) Length() int64 { @@ -67,10 +67,10 @@ func (plainBytes) AsString() (string, error) { func (n plainBytes) AsBytes() ([]byte, error) { return []byte(n), nil } -func (plainBytes) AsLink() (ipld.Link, error) { +func (plainBytes) AsLink() (datamodel.Link, error) { return mixins.Bytes{TypeName: "bytes"}.AsLink() } -func (plainBytes) Prototype() ipld.NodePrototype { +func (plainBytes) Prototype() datamodel.NodePrototype { return Prototype__Bytes{} } @@ -78,7 +78,7 @@ func (plainBytes) Prototype() ipld.NodePrototype { type Prototype__Bytes struct{} -func (Prototype__Bytes) NewBuilder() ipld.NodeBuilder { +func (Prototype__Bytes) NewBuilder() datamodel.NodeBuilder { var w plainBytes return &plainBytes__Builder{plainBytes__Assembler{w: &w}} } @@ -89,7 +89,7 @@ type plainBytes__Builder struct { plainBytes__Assembler } -func (nb *plainBytes__Builder) Build() ipld.Node { +func (nb *plainBytes__Builder) Build() datamodel.Node { return nb.w } func (nb *plainBytes__Builder) Reset() { @@ -103,10 +103,10 @@ type plainBytes__Assembler struct { w *plainBytes } -func (plainBytes__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainBytes__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.BytesAssembler{TypeName: "bytes"}.BeginMap(0) } -func (plainBytes__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainBytes__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.BytesAssembler{TypeName: "bytes"}.BeginList(0) } func (plainBytes__Assembler) AssignNull() error { @@ -128,10 +128,10 @@ func (na *plainBytes__Assembler) AssignBytes(v []byte) error { *na.w = plainBytes(v) return nil } -func (plainBytes__Assembler) AssignLink(ipld.Link) error { +func (plainBytes__Assembler) AssignLink(datamodel.Link) error { return mixins.BytesAssembler{TypeName: "bytes"}.AssignLink(nil) } -func (na *plainBytes__Assembler) AssignNode(v ipld.Node) error { +func (na *plainBytes__Assembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsBytes(); err != nil { return err } else { @@ -139,6 +139,6 @@ func (na *plainBytes__Assembler) AssignNode(v ipld.Node) error { return nil } } -func (plainBytes__Assembler) Prototype() ipld.NodePrototype { +func (plainBytes__Assembler) Prototype() datamodel.NodePrototype { return Prototype__Bytes{} } diff --git a/node/basic/float.go b/node/basicnode/float.go similarity index 64% rename from node/basic/float.go rename to node/basicnode/float.go index 04db0179..f00db30d 100644 --- a/node/basic/float.go +++ b/node/basicnode/float.go @@ -1,46 +1,46 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = plainFloat(0) - _ ipld.NodePrototype = Prototype__Float{} - _ ipld.NodeBuilder = &plainFloat__Builder{} - _ ipld.NodeAssembler = &plainFloat__Assembler{} + _ datamodel.Node = plainFloat(0) + _ datamodel.NodePrototype = Prototype__Float{} + _ datamodel.NodeBuilder = &plainFloat__Builder{} + _ datamodel.NodeAssembler = &plainFloat__Assembler{} ) -func NewFloat(value float64) ipld.Node { +func NewFloat(value float64) datamodel.Node { v := plainFloat(value) return &v } -// plainFloat is a simple boxed float that complies with ipld.Node. +// plainFloat is a simple boxed float that complies with datamodel.Node. type plainFloat float64 // -- Node interface methods --> -func (plainFloat) Kind() ipld.Kind { - return ipld.Kind_Float +func (plainFloat) Kind() datamodel.Kind { + return datamodel.Kind_Float } -func (plainFloat) LookupByString(string) (ipld.Node, error) { +func (plainFloat) LookupByString(string) (datamodel.Node, error) { return mixins.Float{TypeName: "float"}.LookupByString("") } -func (plainFloat) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (plainFloat) LookupByNode(key datamodel.Node) (datamodel.Node, error) { return mixins.Float{TypeName: "float"}.LookupByNode(nil) } -func (plainFloat) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainFloat) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Float{TypeName: "float"}.LookupByIndex(0) } -func (plainFloat) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (plainFloat) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Float{TypeName: "float"}.LookupBySegment(seg) } -func (plainFloat) MapIterator() ipld.MapIterator { +func (plainFloat) MapIterator() datamodel.MapIterator { return nil } -func (plainFloat) ListIterator() ipld.ListIterator { +func (plainFloat) ListIterator() datamodel.ListIterator { return nil } func (plainFloat) Length() int64 { @@ -67,10 +67,10 @@ func (plainFloat) AsString() (string, error) { func (plainFloat) AsBytes() ([]byte, error) { return mixins.Float{TypeName: "float"}.AsBytes() } -func (plainFloat) AsLink() (ipld.Link, error) { +func (plainFloat) AsLink() (datamodel.Link, error) { return mixins.Float{TypeName: "float"}.AsLink() } -func (plainFloat) Prototype() ipld.NodePrototype { +func (plainFloat) Prototype() datamodel.NodePrototype { return Prototype__Float{} } @@ -78,7 +78,7 @@ func (plainFloat) Prototype() ipld.NodePrototype { type Prototype__Float struct{} -func (Prototype__Float) NewBuilder() ipld.NodeBuilder { +func (Prototype__Float) NewBuilder() datamodel.NodeBuilder { var w plainFloat return &plainFloat__Builder{plainFloat__Assembler{w: &w}} } @@ -89,7 +89,7 @@ type plainFloat__Builder struct { plainFloat__Assembler } -func (nb *plainFloat__Builder) Build() ipld.Node { +func (nb *plainFloat__Builder) Build() datamodel.Node { return nb.w } func (nb *plainFloat__Builder) Reset() { @@ -103,10 +103,10 @@ type plainFloat__Assembler struct { w *plainFloat } -func (plainFloat__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainFloat__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.FloatAssembler{TypeName: "float"}.BeginMap(0) } -func (plainFloat__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainFloat__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.FloatAssembler{TypeName: "float"}.BeginList(0) } func (plainFloat__Assembler) AssignNull() error { @@ -128,10 +128,10 @@ func (plainFloat__Assembler) AssignString(string) error { func (plainFloat__Assembler) AssignBytes([]byte) error { return mixins.FloatAssembler{TypeName: "float"}.AssignBytes(nil) } -func (plainFloat__Assembler) AssignLink(ipld.Link) error { +func (plainFloat__Assembler) AssignLink(datamodel.Link) error { return mixins.FloatAssembler{TypeName: "float"}.AssignLink(nil) } -func (na *plainFloat__Assembler) AssignNode(v ipld.Node) error { +func (na *plainFloat__Assembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsFloat(); err != nil { return err } else { @@ -139,6 +139,6 @@ func (na *plainFloat__Assembler) AssignNode(v ipld.Node) error { return nil } } -func (plainFloat__Assembler) Prototype() ipld.NodePrototype { +func (plainFloat__Assembler) Prototype() datamodel.NodePrototype { return Prototype__Float{} } diff --git a/node/basic/int.go b/node/basicnode/int.go similarity index 64% rename from node/basic/int.go rename to node/basicnode/int.go index 75676e9c..5d330226 100644 --- a/node/basic/int.go +++ b/node/basicnode/int.go @@ -1,46 +1,46 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = plainInt(0) - _ ipld.NodePrototype = Prototype__Int{} - _ ipld.NodeBuilder = &plainInt__Builder{} - _ ipld.NodeAssembler = &plainInt__Assembler{} + _ datamodel.Node = plainInt(0) + _ datamodel.NodePrototype = Prototype__Int{} + _ datamodel.NodeBuilder = &plainInt__Builder{} + _ datamodel.NodeAssembler = &plainInt__Assembler{} ) -func NewInt(value int64) ipld.Node { +func NewInt(value int64) datamodel.Node { v := plainInt(value) return &v } -// plainInt is a simple boxed int that complies with ipld.Node. +// plainInt is a simple boxed int that complies with datamodel.Node. type plainInt int64 // -- Node interface methods --> -func (plainInt) Kind() ipld.Kind { - return ipld.Kind_Int +func (plainInt) Kind() datamodel.Kind { + return datamodel.Kind_Int } -func (plainInt) LookupByString(string) (ipld.Node, error) { +func (plainInt) LookupByString(string) (datamodel.Node, error) { return mixins.Int{TypeName: "int"}.LookupByString("") } -func (plainInt) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (plainInt) LookupByNode(key datamodel.Node) (datamodel.Node, error) { return mixins.Int{TypeName: "int"}.LookupByNode(nil) } -func (plainInt) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainInt) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Int{TypeName: "int"}.LookupByIndex(0) } -func (plainInt) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (plainInt) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Int{TypeName: "int"}.LookupBySegment(seg) } -func (plainInt) MapIterator() ipld.MapIterator { +func (plainInt) MapIterator() datamodel.MapIterator { return nil } -func (plainInt) ListIterator() ipld.ListIterator { +func (plainInt) ListIterator() datamodel.ListIterator { return nil } func (plainInt) Length() int64 { @@ -67,10 +67,10 @@ func (plainInt) AsString() (string, error) { func (plainInt) AsBytes() ([]byte, error) { return mixins.Int{TypeName: "int"}.AsBytes() } -func (plainInt) AsLink() (ipld.Link, error) { +func (plainInt) AsLink() (datamodel.Link, error) { return mixins.Int{TypeName: "int"}.AsLink() } -func (plainInt) Prototype() ipld.NodePrototype { +func (plainInt) Prototype() datamodel.NodePrototype { return Prototype__Int{} } @@ -78,7 +78,7 @@ func (plainInt) Prototype() ipld.NodePrototype { type Prototype__Int struct{} -func (Prototype__Int) NewBuilder() ipld.NodeBuilder { +func (Prototype__Int) NewBuilder() datamodel.NodeBuilder { var w plainInt return &plainInt__Builder{plainInt__Assembler{w: &w}} } @@ -89,7 +89,7 @@ type plainInt__Builder struct { plainInt__Assembler } -func (nb *plainInt__Builder) Build() ipld.Node { +func (nb *plainInt__Builder) Build() datamodel.Node { return nb.w } func (nb *plainInt__Builder) Reset() { @@ -103,10 +103,10 @@ type plainInt__Assembler struct { w *plainInt } -func (plainInt__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainInt__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.IntAssembler{TypeName: "int"}.BeginMap(0) } -func (plainInt__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainInt__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.IntAssembler{TypeName: "int"}.BeginList(0) } func (plainInt__Assembler) AssignNull() error { @@ -128,10 +128,10 @@ func (plainInt__Assembler) AssignString(string) error { func (plainInt__Assembler) AssignBytes([]byte) error { return mixins.IntAssembler{TypeName: "int"}.AssignBytes(nil) } -func (plainInt__Assembler) AssignLink(ipld.Link) error { +func (plainInt__Assembler) AssignLink(datamodel.Link) error { return mixins.IntAssembler{TypeName: "int"}.AssignLink(nil) } -func (na *plainInt__Assembler) AssignNode(v ipld.Node) error { +func (na *plainInt__Assembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsInt(); err != nil { return err } else { @@ -139,6 +139,6 @@ func (na *plainInt__Assembler) AssignNode(v ipld.Node) error { return nil } } -func (plainInt__Assembler) Prototype() ipld.NodePrototype { +func (plainInt__Assembler) Prototype() datamodel.NodePrototype { return Prototype__Int{} } diff --git a/node/basic/link.go b/node/basicnode/link.go similarity index 63% rename from node/basic/link.go rename to node/basicnode/link.go index 3542bc04..41d2cf0d 100644 --- a/node/basic/link.go +++ b/node/basicnode/link.go @@ -1,47 +1,47 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = &plainLink{} - _ ipld.NodePrototype = Prototype__Link{} - _ ipld.NodeBuilder = &plainLink__Builder{} - _ ipld.NodeAssembler = &plainLink__Assembler{} + _ datamodel.Node = &plainLink{} + _ datamodel.NodePrototype = Prototype__Link{} + _ datamodel.NodeBuilder = &plainLink__Builder{} + _ datamodel.NodeAssembler = &plainLink__Assembler{} ) -func NewLink(value ipld.Link) ipld.Node { +func NewLink(value datamodel.Link) datamodel.Node { return &plainLink{value} } -// plainLink is a simple box around a Link that complies with ipld.Node. +// plainLink is a simple box around a Link that complies with datamodel.Node. type plainLink struct { - x ipld.Link + x datamodel.Link } // -- Node interface methods --> -func (plainLink) Kind() ipld.Kind { - return ipld.Kind_Link +func (plainLink) Kind() datamodel.Kind { + return datamodel.Kind_Link } -func (plainLink) LookupByString(string) (ipld.Node, error) { +func (plainLink) LookupByString(string) (datamodel.Node, error) { return mixins.Link{TypeName: "link"}.LookupByString("") } -func (plainLink) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (plainLink) LookupByNode(key datamodel.Node) (datamodel.Node, error) { return mixins.Link{TypeName: "link"}.LookupByNode(nil) } -func (plainLink) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainLink) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Link{TypeName: "link"}.LookupByIndex(0) } -func (plainLink) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (plainLink) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Link{TypeName: "link"}.LookupBySegment(seg) } -func (plainLink) MapIterator() ipld.MapIterator { +func (plainLink) MapIterator() datamodel.MapIterator { return nil } -func (plainLink) ListIterator() ipld.ListIterator { +func (plainLink) ListIterator() datamodel.ListIterator { return nil } func (plainLink) Length() int64 { @@ -68,10 +68,10 @@ func (plainLink) AsString() (string, error) { func (plainLink) AsBytes() ([]byte, error) { return mixins.Link{TypeName: "link"}.AsBytes() } -func (n *plainLink) AsLink() (ipld.Link, error) { +func (n *plainLink) AsLink() (datamodel.Link, error) { return n.x, nil } -func (plainLink) Prototype() ipld.NodePrototype { +func (plainLink) Prototype() datamodel.NodePrototype { return Prototype__Link{} } @@ -79,7 +79,7 @@ func (plainLink) Prototype() ipld.NodePrototype { type Prototype__Link struct{} -func (Prototype__Link) NewBuilder() ipld.NodeBuilder { +func (Prototype__Link) NewBuilder() datamodel.NodeBuilder { var w plainLink return &plainLink__Builder{plainLink__Assembler{w: &w}} } @@ -90,7 +90,7 @@ type plainLink__Builder struct { plainLink__Assembler } -func (nb *plainLink__Builder) Build() ipld.Node { +func (nb *plainLink__Builder) Build() datamodel.Node { return nb.w } func (nb *plainLink__Builder) Reset() { @@ -104,10 +104,10 @@ type plainLink__Assembler struct { w *plainLink } -func (plainLink__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainLink__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.LinkAssembler{TypeName: "link"}.BeginMap(0) } -func (plainLink__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainLink__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.LinkAssembler{TypeName: "link"}.BeginList(0) } func (plainLink__Assembler) AssignNull() error { @@ -128,11 +128,11 @@ func (plainLink__Assembler) AssignString(string) error { func (plainLink__Assembler) AssignBytes([]byte) error { return mixins.LinkAssembler{TypeName: "link"}.AssignBytes(nil) } -func (na *plainLink__Assembler) AssignLink(v ipld.Link) error { +func (na *plainLink__Assembler) AssignLink(v datamodel.Link) error { na.w.x = v return nil } -func (na *plainLink__Assembler) AssignNode(v ipld.Node) error { +func (na *plainLink__Assembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsLink(); err != nil { return err } else { @@ -140,6 +140,6 @@ func (na *plainLink__Assembler) AssignNode(v ipld.Node) error { return nil } } -func (plainLink__Assembler) Prototype() ipld.NodePrototype { +func (plainLink__Assembler) Prototype() datamodel.NodePrototype { return Prototype__Link{} } diff --git a/node/basic/list.go b/node/basicnode/list.go similarity index 72% rename from node/basic/list.go rename to node/basicnode/list.go index f8679272..6f7582bb 100644 --- a/node/basic/list.go +++ b/node/basicnode/list.go @@ -1,52 +1,52 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = &plainList{} - _ ipld.NodePrototype = Prototype__List{} - _ ipld.NodeBuilder = &plainList__Builder{} - _ ipld.NodeAssembler = &plainList__Assembler{} + _ datamodel.Node = &plainList{} + _ datamodel.NodePrototype = Prototype__List{} + _ datamodel.NodeBuilder = &plainList__Builder{} + _ datamodel.NodeAssembler = &plainList__Assembler{} ) -// plainList is a concrete type that provides a list-kind ipld.Node. +// plainList is a concrete type that provides a list-kind datamodel.Node. // It can contain any kind of value. // plainList is also embedded in the 'any' struct and usable from there. type plainList struct { - x []ipld.Node + x []datamodel.Node } // -- Node interface methods --> -func (plainList) Kind() ipld.Kind { - return ipld.Kind_List +func (plainList) Kind() datamodel.Kind { + return datamodel.Kind_List } -func (plainList) LookupByString(string) (ipld.Node, error) { +func (plainList) LookupByString(string) (datamodel.Node, error) { return mixins.List{TypeName: "list"}.LookupByString("") } -func (plainList) LookupByNode(ipld.Node) (ipld.Node, error) { +func (plainList) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.List{TypeName: "list"}.LookupByNode(nil) } -func (n *plainList) LookupByIndex(idx int64) (ipld.Node, error) { +func (n *plainList) LookupByIndex(idx int64) (datamodel.Node, error) { if n.Length() <= idx { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)} } return n.x[idx], nil } -func (n *plainList) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n *plainList) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { idx, err := seg.Index() if err != nil { - return nil, ipld.ErrInvalidSegmentForList{TroubleSegment: seg, Reason: err} + return nil, datamodel.ErrInvalidSegmentForList{TroubleSegment: seg, Reason: err} } return n.LookupByIndex(idx) } -func (plainList) MapIterator() ipld.MapIterator { +func (plainList) MapIterator() datamodel.MapIterator { return nil } -func (n *plainList) ListIterator() ipld.ListIterator { +func (n *plainList) ListIterator() datamodel.ListIterator { return &plainList_ListIterator{n, 0} } func (n *plainList) Length() int64 { @@ -73,11 +73,11 @@ func (plainList) AsString() (string, error) { func (plainList) AsBytes() ([]byte, error) { return mixins.List{TypeName: "list"}.AsBytes() } -func (plainList) AsLink() (ipld.Link, error) { +func (plainList) AsLink() (datamodel.Link, error) { return mixins.List{TypeName: "list"}.AsLink() } -func (plainList) Prototype() ipld.NodePrototype { - return Prototype__List{} +func (plainList) Prototype() datamodel.NodePrototype { + return Prototype.List } type plainList_ListIterator struct { @@ -85,9 +85,9 @@ type plainList_ListIterator struct { idx int } -func (itr *plainList_ListIterator) Next() (idx int64, v ipld.Node, _ error) { +func (itr *plainList_ListIterator) Next() (idx int64, v datamodel.Node, _ error) { if itr.Done() { - return -1, nil, ipld.ErrIteratorOverread{} + return -1, nil, datamodel.ErrIteratorOverread{} } v = itr.n.x[itr.idx] idx = int64(itr.idx) @@ -102,7 +102,7 @@ func (itr *plainList_ListIterator) Done() bool { type Prototype__List struct{} -func (Prototype__List) NewBuilder() ipld.NodeBuilder { +func (Prototype__List) NewBuilder() datamodel.NodeBuilder { return &plainList__Builder{plainList__Assembler{w: &plainList{}}} } @@ -112,7 +112,7 @@ type plainList__Builder struct { plainList__Assembler } -func (nb *plainList__Builder) Build() ipld.Node { +func (nb *plainList__Builder) Build() datamodel.Node { if nb.state != laState_finished { panic("invalid state: assembler must be 'finished' before Build can be called!") } @@ -147,15 +147,15 @@ const ( laState_finished // 'w' will also be nil, but this is a politer statement ) -func (plainList__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainList__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.ListAssembler{TypeName: "list"}.BeginMap(0) } -func (na *plainList__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *plainList__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { if sizeHint < 0 { sizeHint = 0 } // Allocate storage space. - na.w.x = make([]ipld.Node, 0, sizeHint) + na.w.x = make([]datamodel.Node, 0, sizeHint) // That's it; return self as the ListAssembler. We already have all the right methods on this structure. return na, nil } @@ -177,10 +177,10 @@ func (plainList__Assembler) AssignString(string) error { func (plainList__Assembler) AssignBytes([]byte) error { return mixins.ListAssembler{TypeName: "list"}.AssignBytes(nil) } -func (plainList__Assembler) AssignLink(ipld.Link) error { +func (plainList__Assembler) AssignLink(datamodel.Link) error { return mixins.ListAssembler{TypeName: "list"}.AssignLink(nil) } -func (na *plainList__Assembler) AssignNode(v ipld.Node) error { +func (na *plainList__Assembler) AssignNode(v datamodel.Node) error { // Sanity check, then update, assembler state. // Update of state to 'finished' comes later; where exactly depends on if shortcuts apply. if na.state != laState_initial { @@ -198,8 +198,8 @@ func (na *plainList__Assembler) AssignNode(v ipld.Node) error { } // If the above shortcut didn't work, resort to a generic copy. // We call AssignNode for all the child values, giving them a chance to hit shortcuts even if we didn't. - if v.Kind() != ipld.Kind_List { - return ipld.ErrWrongKind{TypeName: "list", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_List { + return datamodel.ErrWrongKind{TypeName: "list", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustList, ActualKind: v.Kind()} } itr := v.ListIterator() for !itr.Done() { @@ -213,15 +213,15 @@ func (na *plainList__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (plainList__Assembler) Prototype() ipld.NodePrototype { - return Prototype__List{} +func (plainList__Assembler) Prototype() datamodel.NodePrototype { + return Prototype.List } // -- ListAssembler --> // AssembleValue is part of conforming to ListAssembler, which we do on // plainList__Assembler so that BeginList can just return a retyped pointer rather than new object. -func (la *plainList__Assembler) AssembleValue() ipld.NodeAssembler { +func (la *plainList__Assembler) AssembleValue() datamodel.NodeAssembler { // Sanity check, then update, assembler state. if la.state != laState_initial { panic("misuse") @@ -243,20 +243,20 @@ func (la *plainList__Assembler) Finish() error { // validators could run and report errors promptly, if this type had any. return nil } -func (plainList__Assembler) ValuePrototype(_ int64) ipld.NodePrototype { - return Prototype__Any{} +func (plainList__Assembler) ValuePrototype(_ int64) datamodel.NodePrototype { + return Prototype.Any } // -- ListAssembler.ValueAssembler --> -func (lva *plainList__ValueAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (lva *plainList__ValueAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { ma := plainList__ValueAssemblerMap{} ma.ca.w = &plainMap{} ma.p = lva.la _, err := ma.ca.BeginMap(sizeHint) return &ma, err } -func (lva *plainList__ValueAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (lva *plainList__ValueAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { la := plainList__ValueAssemblerList{} la.ca.w = &plainList{} la.p = lva.la @@ -264,7 +264,7 @@ func (lva *plainList__ValueAssembler) BeginList(sizeHint int64) (ipld.ListAssemb return &la, err } func (lva *plainList__ValueAssembler) AssignNull() error { - return lva.AssignNode(ipld.Null) + return lva.AssignNode(datamodel.Null) } func (lva *plainList__ValueAssembler) AssignBool(v bool) error { vb := plainBool(v) @@ -286,18 +286,18 @@ func (lva *plainList__ValueAssembler) AssignBytes(v []byte) error { vb := plainBytes(v) return lva.AssignNode(&vb) } -func (lva *plainList__ValueAssembler) AssignLink(v ipld.Link) error { +func (lva *plainList__ValueAssembler) AssignLink(v datamodel.Link) error { vb := plainLink{v} return lva.AssignNode(&vb) } -func (lva *plainList__ValueAssembler) AssignNode(v ipld.Node) error { +func (lva *plainList__ValueAssembler) AssignNode(v datamodel.Node) error { lva.la.w.x = append(lva.la.w.x, v) lva.la.state = laState_initial lva.la = nil // invalidate self to prevent further incorrect use. return nil } -func (plainList__ValueAssembler) Prototype() ipld.NodePrototype { - return Prototype__Any{} +func (plainList__ValueAssembler) Prototype() datamodel.NodePrototype { + return Prototype.Any } type plainList__ValueAssemblerMap struct { @@ -309,20 +309,20 @@ type plainList__ValueAssemblerMap struct { // just embedding plainMap__Assembler also behaves correctly, // but causes a lot of unnecessary autogenerated functions in the final binary. -func (ma *plainList__ValueAssemblerMap) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *plainList__ValueAssemblerMap) AssembleEntry(k string) (datamodel.NodeAssembler, error) { return ma.ca.AssembleEntry(k) } -func (ma *plainList__ValueAssemblerMap) AssembleKey() ipld.NodeAssembler { +func (ma *plainList__ValueAssemblerMap) AssembleKey() datamodel.NodeAssembler { return ma.ca.AssembleKey() } -func (ma *plainList__ValueAssemblerMap) AssembleValue() ipld.NodeAssembler { +func (ma *plainList__ValueAssemblerMap) AssembleValue() datamodel.NodeAssembler { return ma.ca.AssembleValue() } -func (plainList__ValueAssemblerMap) KeyPrototype() ipld.NodePrototype { +func (plainList__ValueAssemblerMap) KeyPrototype() datamodel.NodePrototype { return Prototype__String{} } -func (plainList__ValueAssemblerMap) ValuePrototype(_ string) ipld.NodePrototype { - return Prototype__Any{} +func (plainList__ValueAssemblerMap) ValuePrototype(_ string) datamodel.NodePrototype { + return Prototype.Any } func (ma *plainList__ValueAssemblerMap) Finish() error { @@ -343,11 +343,11 @@ type plainList__ValueAssemblerList struct { // just embedding plainList__Assembler also behaves correctly, // but causes a lot of unnecessary autogenerated functions in the final binary. -func (la *plainList__ValueAssemblerList) AssembleValue() ipld.NodeAssembler { +func (la *plainList__ValueAssemblerList) AssembleValue() datamodel.NodeAssembler { return la.ca.AssembleValue() } -func (plainList__ValueAssemblerList) ValuePrototype(_ int64) ipld.NodePrototype { - return Prototype__Any{} +func (plainList__ValueAssemblerList) ValuePrototype(_ int64) datamodel.NodePrototype { + return Prototype.Any } func (la *plainList__ValueAssemblerList) Finish() error { diff --git a/node/basic/list_test.go b/node/basicnode/list_test.go similarity index 52% rename from node/basic/list_test.go rename to node/basicnode/list_test.go index 224e243e..68cb1778 100644 --- a/node/basic/list_test.go +++ b/node/basicnode/list_test.go @@ -3,10 +3,10 @@ package basicnode_test import ( "testing" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/node/tests" ) func TestList(t *testing.T) { - tests.SpecTestListString(t, basicnode.Prototype__List{}) + tests.SpecTestListString(t, basicnode.Prototype.List) } diff --git a/node/basic/map.go b/node/basicnode/map.go similarity index 72% rename from node/basic/map.go rename to node/basicnode/map.go index 83d6f998..9a86fc52 100644 --- a/node/basic/map.go +++ b/node/basicnode/map.go @@ -3,60 +3,60 @@ package basicnode import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = &plainMap{} - _ ipld.NodePrototype = Prototype__Map{} - _ ipld.NodeBuilder = &plainMap__Builder{} - _ ipld.NodeAssembler = &plainMap__Assembler{} + _ datamodel.Node = &plainMap{} + _ datamodel.NodePrototype = Prototype__Map{} + _ datamodel.NodeBuilder = &plainMap__Builder{} + _ datamodel.NodeAssembler = &plainMap__Assembler{} ) -// plainMap is a concrete type that provides a map-kind ipld.Node. +// plainMap is a concrete type that provides a map-kind datamodel.Node. // It can contain any kind of value. // plainMap is also embedded in the 'any' struct and usable from there. type plainMap struct { - m map[string]ipld.Node // string key -- even if a runtime schema wrapper is using us for storage, we must have a comparable type here, and string is all we know. - t []plainMap__Entry // table for fast iteration, order keeping, and yielding pointers to enable alloc/conv amortization. + m map[string]datamodel.Node // string key -- even if a runtime schema wrapper is using us for storage, we must have a comparable type here, and string is all we know. + t []plainMap__Entry // table for fast iteration, order keeping, and yielding pointers to enable alloc/conv amortization. } type plainMap__Entry struct { - k plainString // address of this used when we return keys as nodes, such as in iterators. Need in one place to amortize shifts to heap when ptr'ing for iface. - v ipld.Node // identical to map values. keeping them here simplifies iteration. (in codegen'd maps, this position is also part of amortization, but in this implementation, that's less useful.) + k plainString // address of this used when we return keys as nodes, such as in iterators. Need in one place to amortize shifts to heap when ptr'ing for iface. + v datamodel.Node // identical to map values. keeping them here simplifies iteration. (in codegen'd maps, this position is also part of amortization, but in this implementation, that's less useful.) // note on alternate implementations: 'v' could also use the 'any' type, and thus amortize value allocations. the memory size trade would be large however, so we don't, here. } // -- Node interface methods --> -func (plainMap) Kind() ipld.Kind { - return ipld.Kind_Map +func (plainMap) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *plainMap) LookupByString(key string) (ipld.Node, error) { +func (n *plainMap) LookupByString(key string) (datamodel.Node, error) { v, exists := n.m[key] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return v, nil } -func (n *plainMap) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *plainMap) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (plainMap) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainMap) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "map"}.LookupByIndex(0) } -func (n *plainMap) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n *plainMap) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *plainMap) MapIterator() ipld.MapIterator { +func (n *plainMap) MapIterator() datamodel.MapIterator { return &plainMap_MapIterator{n, 0} } -func (plainMap) ListIterator() ipld.ListIterator { +func (plainMap) ListIterator() datamodel.ListIterator { return nil } func (n *plainMap) Length() int64 { @@ -83,11 +83,11 @@ func (plainMap) AsString() (string, error) { func (plainMap) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "map"}.AsBytes() } -func (plainMap) AsLink() (ipld.Link, error) { +func (plainMap) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "map"}.AsLink() } -func (plainMap) Prototype() ipld.NodePrototype { - return Prototype__Map{} +func (plainMap) Prototype() datamodel.NodePrototype { + return Prototype.Map } type plainMap_MapIterator struct { @@ -95,9 +95,9 @@ type plainMap_MapIterator struct { idx int } -func (itr *plainMap_MapIterator) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *plainMap_MapIterator) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.Done() { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } k = &itr.n.t[itr.idx].k v = itr.n.t[itr.idx].v @@ -112,7 +112,7 @@ func (itr *plainMap_MapIterator) Done() bool { type Prototype__Map struct{} -func (Prototype__Map) NewBuilder() ipld.NodeBuilder { +func (Prototype__Map) NewBuilder() datamodel.NodeBuilder { return &plainMap__Builder{plainMap__Assembler{w: &plainMap{}}} } @@ -122,7 +122,7 @@ type plainMap__Builder struct { plainMap__Assembler } -func (nb *plainMap__Builder) Build() ipld.Node { +func (nb *plainMap__Builder) Build() datamodel.Node { if nb.state != maState_finished { panic("invalid state: assembler must be 'finished' before Build can be called!") } @@ -162,17 +162,17 @@ const ( maState_finished // 'w' will also be nil, but this is a politer statement ) -func (na *plainMap__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *plainMap__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { if sizeHint < 0 { sizeHint = 0 } // Allocate storage space. na.w.t = make([]plainMap__Entry, 0, sizeHint) - na.w.m = make(map[string]ipld.Node, sizeHint) + na.w.m = make(map[string]datamodel.Node, sizeHint) // That's it; return self as the MapAssembler. We already have all the right methods on this structure. return na, nil } -func (plainMap__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainMap__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "map"}.BeginList(0) } func (plainMap__Assembler) AssignNull() error { @@ -193,10 +193,10 @@ func (plainMap__Assembler) AssignString(string) error { func (plainMap__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "map"}.AssignBytes(nil) } -func (plainMap__Assembler) AssignLink(ipld.Link) error { +func (plainMap__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "map"}.AssignLink(nil) } -func (na *plainMap__Assembler) AssignNode(v ipld.Node) error { +func (na *plainMap__Assembler) AssignNode(v datamodel.Node) error { // Sanity check assembler state. // Update of state to 'finished' comes later; where exactly depends on if shortcuts apply. if na.state != maState_initial { @@ -214,8 +214,8 @@ func (na *plainMap__Assembler) AssignNode(v ipld.Node) error { } // If the above shortcut didn't work, resort to a generic copy. // We call AssignNode for all the child values, giving them a chance to hit shortcuts even if we didn't. - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "map", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "map", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -232,15 +232,15 @@ func (na *plainMap__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (plainMap__Assembler) Prototype() ipld.NodePrototype { - return Prototype__Map{} +func (plainMap__Assembler) Prototype() datamodel.NodePrototype { + return Prototype.Map } // -- MapAssembler --> // AssembleEntry is part of conforming to MapAssembler, which we do on // plainMap__Assembler so that BeginMap can just return a retyped pointer rather than new object. -func (ma *plainMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *plainMap__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { // Sanity check assembler state. // Update of state comes after possible key rejection. if ma.state != maState_initial { @@ -249,7 +249,7 @@ func (ma *plainMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro // Check for dup keys; error if so. _, exists := ma.w.m[k] if exists { - return nil, ipld.ErrRepeatedMapKey{Key: plainString(k)} + return nil, datamodel.ErrRepeatedMapKey{Key: plainString(k)} } ma.state = maState_midValue ma.w.t = append(ma.w.t, plainMap__Entry{k: plainString(k)}) @@ -260,7 +260,7 @@ func (ma *plainMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro // AssembleKey is part of conforming to MapAssembler, which we do on // plainMap__Assembler so that BeginMap can just return a retyped pointer rather than new object. -func (ma *plainMap__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *plainMap__Assembler) AssembleKey() datamodel.NodeAssembler { // Sanity check, then update, assembler state. if ma.state != maState_initial { panic("misuse") @@ -273,7 +273,7 @@ func (ma *plainMap__Assembler) AssembleKey() ipld.NodeAssembler { // AssembleValue is part of conforming to MapAssembler, which we do on // plainMap__Assembler so that BeginMap can just return a retyped pointer rather than new object. -func (ma *plainMap__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *plainMap__Assembler) AssembleValue() datamodel.NodeAssembler { // Sanity check, then update, assembler state. if ma.state != maState_expectValue { panic("misuse") @@ -295,19 +295,19 @@ func (ma *plainMap__Assembler) Finish() error { // validators could run and report errors promptly, if this type had any. return nil } -func (plainMap__Assembler) KeyPrototype() ipld.NodePrototype { +func (plainMap__Assembler) KeyPrototype() datamodel.NodePrototype { return Prototype__String{} } -func (plainMap__Assembler) ValuePrototype(_ string) ipld.NodePrototype { - return Prototype__Any{} +func (plainMap__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { + return Prototype.Any } // -- MapAssembler.KeyAssembler --> -func (plainMap__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainMap__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "string"}.BeginMap(0) } -func (plainMap__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainMap__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "string"}.BeginList(0) } func (plainMap__KeyAssembler) AssignNull() error { @@ -329,7 +329,7 @@ func (mka *plainMap__KeyAssembler) AssignString(v string) error { if exists { mka.ma.state = maState_initial mka.ma = nil // invalidate self to prevent further incorrect use. - return ipld.ErrRepeatedMapKey{Key: plainString(v)} + return datamodel.ErrRepeatedMapKey{Key: plainString(v)} } // Assign the key into the end of the entry table; // we'll be doing map insertions after we get the value in hand. @@ -345,30 +345,30 @@ func (mka *plainMap__KeyAssembler) AssignString(v string) error { func (plainMap__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "string"}.AssignBytes(nil) } -func (plainMap__KeyAssembler) AssignLink(ipld.Link) error { +func (plainMap__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "string"}.AssignLink(nil) } -func (mka *plainMap__KeyAssembler) AssignNode(v ipld.Node) error { +func (mka *plainMap__KeyAssembler) AssignNode(v datamodel.Node) error { vs, err := v.AsString() if err != nil { return fmt.Errorf("cannot assign non-string node into map key assembler") // FIXME:errors: this doesn't quite fit in ErrWrongKind cleanly; new error type? } return mka.AssignString(vs) } -func (plainMap__KeyAssembler) Prototype() ipld.NodePrototype { +func (plainMap__KeyAssembler) Prototype() datamodel.NodePrototype { return Prototype__String{} } // -- MapAssembler.ValueAssembler --> -func (mva *plainMap__ValueAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (mva *plainMap__ValueAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { ma := plainMap__ValueAssemblerMap{} ma.ca.w = &plainMap{} ma.p = mva.ma _, err := ma.ca.BeginMap(sizeHint) return &ma, err } -func (mva *plainMap__ValueAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (mva *plainMap__ValueAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { la := plainMap__ValueAssemblerList{} la.ca.w = &plainList{} la.p = mva.ma @@ -376,7 +376,7 @@ func (mva *plainMap__ValueAssembler) BeginList(sizeHint int64) (ipld.ListAssembl return &la, err } func (mva *plainMap__ValueAssembler) AssignNull() error { - return mva.AssignNode(ipld.Null) + return mva.AssignNode(datamodel.Null) } func (mva *plainMap__ValueAssembler) AssignBool(v bool) error { vb := plainBool(v) @@ -398,11 +398,11 @@ func (mva *plainMap__ValueAssembler) AssignBytes(v []byte) error { vb := plainBytes(v) return mva.AssignNode(&vb) } -func (mva *plainMap__ValueAssembler) AssignLink(v ipld.Link) error { +func (mva *plainMap__ValueAssembler) AssignLink(v datamodel.Link) error { vb := plainLink{v} return mva.AssignNode(&vb) } -func (mva *plainMap__ValueAssembler) AssignNode(v ipld.Node) error { +func (mva *plainMap__ValueAssembler) AssignNode(v datamodel.Node) error { l := len(mva.ma.w.t) - 1 mva.ma.w.t[l].v = v mva.ma.w.m[string(mva.ma.w.t[l].k)] = v @@ -410,8 +410,8 @@ func (mva *plainMap__ValueAssembler) AssignNode(v ipld.Node) error { mva.ma = nil // invalidate self to prevent further incorrect use. return nil } -func (plainMap__ValueAssembler) Prototype() ipld.NodePrototype { - return Prototype__Any{} +func (plainMap__ValueAssembler) Prototype() datamodel.NodePrototype { + return Prototype.Any } type plainMap__ValueAssemblerMap struct { @@ -423,20 +423,20 @@ type plainMap__ValueAssemblerMap struct { // just embedding plainMap__Assembler also behaves correctly, // but causes a lot of unnecessary autogenerated functions in the final binary. -func (ma *plainMap__ValueAssemblerMap) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *plainMap__ValueAssemblerMap) AssembleEntry(k string) (datamodel.NodeAssembler, error) { return ma.ca.AssembleEntry(k) } -func (ma *plainMap__ValueAssemblerMap) AssembleKey() ipld.NodeAssembler { +func (ma *plainMap__ValueAssemblerMap) AssembleKey() datamodel.NodeAssembler { return ma.ca.AssembleKey() } -func (ma *plainMap__ValueAssemblerMap) AssembleValue() ipld.NodeAssembler { +func (ma *plainMap__ValueAssemblerMap) AssembleValue() datamodel.NodeAssembler { return ma.ca.AssembleValue() } -func (plainMap__ValueAssemblerMap) KeyPrototype() ipld.NodePrototype { +func (plainMap__ValueAssemblerMap) KeyPrototype() datamodel.NodePrototype { return Prototype__String{} } -func (plainMap__ValueAssemblerMap) ValuePrototype(_ string) ipld.NodePrototype { - return Prototype__Any{} +func (plainMap__ValueAssemblerMap) ValuePrototype(_ string) datamodel.NodePrototype { + return Prototype.Any } func (ma *plainMap__ValueAssemblerMap) Finish() error { @@ -457,11 +457,11 @@ type plainMap__ValueAssemblerList struct { // just embedding plainList__Assembler also behaves correctly, // but causes a lot of unnecessary autogenerated functions in the final binary. -func (la *plainMap__ValueAssemblerList) AssembleValue() ipld.NodeAssembler { +func (la *plainMap__ValueAssemblerList) AssembleValue() datamodel.NodeAssembler { return la.ca.AssembleValue() } -func (plainMap__ValueAssemblerList) ValuePrototype(_ int64) ipld.NodePrototype { - return Prototype__Any{} +func (plainMap__ValueAssemblerList) ValuePrototype(_ int64) datamodel.NodePrototype { + return Prototype.Any } func (la *plainMap__ValueAssemblerList) Finish() error { diff --git a/node/basic/map_test.go b/node/basicnode/map_test.go similarity index 69% rename from node/basic/map_test.go rename to node/basicnode/map_test.go index dc68e771..2417fc62 100644 --- a/node/basic/map_test.go +++ b/node/basicnode/map_test.go @@ -3,49 +3,46 @@ package basicnode_test import ( "testing" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/node/tests" ) func TestMap(t *testing.T) { - tests.SpecTestMapStrInt(t, basicnode.Prototype__Map{}) - tests.SpecTestMapStrMapStrInt(t, basicnode.Prototype__Map{}) - tests.SpecTestMapStrListStr(t, basicnode.Prototype__Map{}) + tests.SpecTestMapStrInt(t, basicnode.Prototype.Map) + tests.SpecTestMapStrMapStrInt(t, basicnode.Prototype.Map) + tests.SpecTestMapStrListStr(t, basicnode.Prototype.Map) } func BenchmarkMapStrInt_3n_AssembleStandard(b *testing.B) { - tests.SpecBenchmarkMapStrInt_3n_AssembleStandard(b, basicnode.Prototype__Map{}) + tests.SpecBenchmarkMapStrInt_3n_AssembleStandard(b, basicnode.Prototype.Map) } func BenchmarkMapStrInt_3n_AssembleEntry(b *testing.B) { - tests.SpecBenchmarkMapStrInt_3n_AssembleEntry(b, basicnode.Prototype__Map{}) + tests.SpecBenchmarkMapStrInt_3n_AssembleEntry(b, basicnode.Prototype.Map) } func BenchmarkMapStrInt_3n_Iteration(b *testing.B) { - tests.SpecBenchmarkMapStrInt_3n_Iteration(b, basicnode.Prototype__Map{}) + tests.SpecBenchmarkMapStrInt_3n_Iteration(b, basicnode.Prototype.Map) } func BenchmarkMapStrInt_25n_AssembleStandard(b *testing.B) { - tests.SpecBenchmarkMapStrInt_25n_AssembleStandard(b, basicnode.Prototype__Map{}) + tests.SpecBenchmarkMapStrInt_25n_AssembleStandard(b, basicnode.Prototype.Map) } func BenchmarkMapStrInt_25n_AssembleEntry(b *testing.B) { - tests.SpecBenchmarkMapStrInt_25n_AssembleEntry(b, basicnode.Prototype__Map{}) + tests.SpecBenchmarkMapStrInt_25n_AssembleEntry(b, basicnode.Prototype.Map) } func BenchmarkMapStrInt_25n_Iteration(b *testing.B) { - tests.SpecBenchmarkMapStrInt_25n_Iteration(b, basicnode.Prototype__Map{}) + tests.SpecBenchmarkMapStrInt_25n_Iteration(b, basicnode.Prototype.Map) } func BenchmarkSpec_Marshal_Map3StrInt(b *testing.B) { - tests.BenchmarkSpec_Marshal_Map3StrInt(b, basicnode.Prototype__Map{}) -} -func BenchmarkSpec_Marshal_Map3StrInt_CodecNull(b *testing.B) { - tests.BenchmarkSpec_Marshal_Map3StrInt_CodecNull(b, basicnode.Prototype__Map{}) + tests.BenchmarkSpec_Marshal_Map3StrInt(b, basicnode.Prototype.Map) } func BenchmarkSpec_Marshal_MapNStrMap3StrInt(b *testing.B) { - tests.BenchmarkSpec_Marshal_MapNStrMap3StrInt(b, basicnode.Prototype__Map{}) + tests.BenchmarkSpec_Marshal_MapNStrMap3StrInt(b, basicnode.Prototype.Map) } func BenchmarkSpec_Unmarshal_Map3StrInt(b *testing.B) { - tests.BenchmarkSpec_Unmarshal_Map3StrInt(b, basicnode.Prototype__Map{}) + tests.BenchmarkSpec_Unmarshal_Map3StrInt(b, basicnode.Prototype.Map) } func BenchmarkSpec_Unmarshal_MapNStrMap3StrInt(b *testing.B) { - tests.BenchmarkSpec_Unmarshal_MapNStrMap3StrInt(b, basicnode.Prototype__Map{}) + tests.BenchmarkSpec_Unmarshal_MapNStrMap3StrInt(b, basicnode.Prototype.Map) } diff --git a/node/basic/prototypes.go b/node/basicnode/prototypes.go similarity index 100% rename from node/basic/prototypes.go rename to node/basicnode/prototypes.go diff --git a/node/basic/string.go b/node/basicnode/string.go similarity index 66% rename from node/basic/string.go rename to node/basicnode/string.go index 37ac6405..3d9856c8 100644 --- a/node/basic/string.go +++ b/node/basicnode/string.go @@ -1,23 +1,23 @@ package basicnode import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" ) var ( - _ ipld.Node = plainString("") - _ ipld.NodePrototype = Prototype__String{} - _ ipld.NodeBuilder = &plainString__Builder{} - _ ipld.NodeAssembler = &plainString__Assembler{} + _ datamodel.Node = plainString("") + _ datamodel.NodePrototype = Prototype__String{} + _ datamodel.NodeBuilder = &plainString__Builder{} + _ datamodel.NodeAssembler = &plainString__Assembler{} ) -func NewString(value string) ipld.Node { +func NewString(value string) datamodel.Node { v := plainString(value) return &v } -// plainString is a simple boxed string that complies with ipld.Node. +// plainString is a simple boxed string that complies with datamodel.Node. // It's useful for many things, such as boxing map keys. // // The implementation is a simple typedef of a string; @@ -27,25 +27,25 @@ type plainString string // -- Node interface methods --> -func (plainString) Kind() ipld.Kind { - return ipld.Kind_String +func (plainString) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (plainString) LookupByString(string) (ipld.Node, error) { +func (plainString) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "string"}.LookupByString("") } -func (plainString) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (plainString) LookupByNode(key datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "string"}.LookupByNode(nil) } -func (plainString) LookupByIndex(idx int64) (ipld.Node, error) { +func (plainString) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "string"}.LookupByIndex(0) } -func (plainString) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (plainString) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "string"}.LookupBySegment(seg) } -func (plainString) MapIterator() ipld.MapIterator { +func (plainString) MapIterator() datamodel.MapIterator { return nil } -func (plainString) ListIterator() ipld.ListIterator { +func (plainString) ListIterator() datamodel.ListIterator { return nil } func (plainString) Length() int64 { @@ -72,10 +72,10 @@ func (x plainString) AsString() (string, error) { func (plainString) AsBytes() ([]byte, error) { return mixins.String{TypeName: "string"}.AsBytes() } -func (plainString) AsLink() (ipld.Link, error) { +func (plainString) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "string"}.AsLink() } -func (plainString) Prototype() ipld.NodePrototype { +func (plainString) Prototype() datamodel.NodePrototype { return Prototype__String{} } @@ -83,7 +83,7 @@ func (plainString) Prototype() ipld.NodePrototype { type Prototype__String struct{} -func (Prototype__String) NewBuilder() ipld.NodeBuilder { +func (Prototype__String) NewBuilder() datamodel.NodeBuilder { var w plainString return &plainString__Builder{plainString__Assembler{w: &w}} } @@ -94,7 +94,7 @@ type plainString__Builder struct { plainString__Assembler } -func (nb *plainString__Builder) Build() ipld.Node { +func (nb *plainString__Builder) Build() datamodel.Node { return nb.w } func (nb *plainString__Builder) Reset() { @@ -108,10 +108,10 @@ type plainString__Assembler struct { w *plainString } -func (plainString__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (plainString__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "string"}.BeginMap(0) } -func (plainString__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (plainString__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "string"}.BeginList(0) } func (plainString__Assembler) AssignNull() error { @@ -133,10 +133,10 @@ func (na *plainString__Assembler) AssignString(v string) error { func (plainString__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "string"}.AssignBytes(nil) } -func (plainString__Assembler) AssignLink(ipld.Link) error { +func (plainString__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "string"}.AssignLink(nil) } -func (na *plainString__Assembler) AssignNode(v ipld.Node) error { +func (na *plainString__Assembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { @@ -144,6 +144,6 @@ func (na *plainString__Assembler) AssignNode(v ipld.Node) error { return nil } } -func (plainString__Assembler) Prototype() ipld.NodePrototype { +func (plainString__Assembler) Prototype() datamodel.NodePrototype { return Prototype__String{} } diff --git a/node/basic/string_test.go b/node/basicnode/string_test.go similarity index 77% rename from node/basic/string_test.go rename to node/basicnode/string_test.go index 82e2420c..5f5f8f84 100644 --- a/node/basic/string_test.go +++ b/node/basicnode/string_test.go @@ -3,7 +3,7 @@ package basicnode_test import ( "testing" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/node/tests" ) diff --git a/node/bindnode/api.go b/node/bindnode/api.go index 6e1171d2..3237ff9e 100644 --- a/node/bindnode/api.go +++ b/node/bindnode/api.go @@ -1,4 +1,4 @@ -// Package bindnode provides an ipld.Node implementation via Go reflection. +// Package bindnode provides an datamodel.Node implementation via Go reflection. // // This package is EXPERIMENTAL; its behavior and API might change as it's still // in development. @@ -7,12 +7,12 @@ package bindnode import ( "reflect" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) // Prototype implements a schema.TypedPrototype given a Go pointer type and an -// IPLD schema type. Note that the result is also an ipld.NodePrototype. +// IPLD schema type. Note that the result is also an datamodel.NodePrototype. // // If both the Go type and schema type are supplied, it is assumed that they are // compatible with one another. @@ -53,7 +53,7 @@ func Prototype(ptrType interface{}, schemaType schema.Type) schema.TypedPrototyp } // Wrap implements a schema.TypedNode given a non-nil pointer to a Go value and an -// IPLD schema type. Note that the result is also an ipld.Node. +// IPLD schema type. Note that the result is also an datamodel.Node. // // Wrap is meant to be used when one already has a Go value with data. // As such, ptrVal must not be nil. @@ -78,11 +78,11 @@ func Wrap(ptrVal interface{}, schemaType schema.Type) schema.TypedNode { return &_node{val: goVal, schemaType: schemaType} } -// Unwrap takes an ipld.Node implemented by Prototype or Wrap, +// Unwrap takes an datamodel.Node implemented by Prototype or Wrap, // and returns a pointer to the inner Go value. // // Unwrap returns nil if the node isn't implemented by this package. -func Unwrap(node ipld.Node) (ptr interface{}) { +func Unwrap(node datamodel.Node) (ptr interface{}) { var val reflect.Value switch node := node.(type) { case *_node: diff --git a/node/bindnode/example_test.go b/node/bindnode/example_test.go index fc52bcb8..a34e6220 100644 --- a/node/bindnode/example_test.go +++ b/node/bindnode/example_test.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent/qp" "github.com/ipld/go-ipld-prime/node/bindnode" "github.com/ipld/go-ipld-prime/schema" @@ -83,9 +83,9 @@ func ExamplePrototype_onlySchema() { schemaType := ts.TypeByName("Person") proto := bindnode.Prototype(nil, schemaType) - node, err := qp.BuildMap(proto, -1, func(ma ipld.MapAssembler) { + node, err := qp.BuildMap(proto, -1, func(ma datamodel.MapAssembler) { qp.MapEntry(ma, "Name", qp.String("Michael")) - qp.MapEntry(ma, "Friends", qp.List(-1, func(la ipld.ListAssembler) { + qp.MapEntry(ma, "Friends", qp.List(-1, func(la datamodel.ListAssembler) { qp.ListEntry(la, qp.String("Sarah")) qp.ListEntry(la, qp.String("Alex")) })) @@ -127,7 +127,7 @@ func ExamplePrototype_union() { proto := bindnode.Prototype((*StringOrInt)(nil), schemaType) - node, err := qp.BuildMap(proto.Representation(), -1, func(ma ipld.MapAssembler) { + node, err := qp.BuildMap(proto.Representation(), -1, func(ma datamodel.MapAssembler) { qp.MapEntry(ma, "hasInt", qp.Int(123)) }) if err != nil { diff --git a/node/bindnode/infer.go b/node/bindnode/infer.go index b1e0ddf4..ca544540 100644 --- a/node/bindnode/infer.go +++ b/node/bindnode/infer.go @@ -5,7 +5,7 @@ import ( "reflect" "strings" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -15,7 +15,7 @@ var ( goTypeFloat = reflect.TypeOf(0.0) goTypeString = reflect.TypeOf("") goTypeBytes = reflect.TypeOf([]byte{}) - goTypeLink = reflect.TypeOf((*ipld.Link)(nil)).Elem() + goTypeLink = reflect.TypeOf((*datamodel.Link)(nil)).Elem() schemaTypeBool = schema.SpawnBool("Bool") schemaTypeInt = schema.SpawnInt("Int") diff --git a/node/bindnode/node.go b/node/bindnode/node.go index 21e7b5ba..0c93c460 100644 --- a/node/bindnode/node.go +++ b/node/bindnode/node.go @@ -4,40 +4,40 @@ import ( "fmt" "reflect" - ipld "github.com/ipld/go-ipld-prime" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/schema" ) // Assert that we implement all the interfaces as expected. // Grouped by the interfaces to implement, roughly. var ( - _ ipld.NodePrototype = (*_prototype)(nil) - _ schema.TypedPrototype = (*_prototype)(nil) - _ ipld.NodePrototype = (*_prototypeRepr)(nil) + _ datamodel.NodePrototype = (*_prototype)(nil) + _ schema.TypedPrototype = (*_prototype)(nil) + _ datamodel.NodePrototype = (*_prototypeRepr)(nil) - _ ipld.Node = (*_node)(nil) + _ datamodel.Node = (*_node)(nil) _ schema.TypedNode = (*_node)(nil) - _ ipld.Node = (*_nodeRepr)(nil) - - _ ipld.NodeBuilder = (*_builder)(nil) - _ ipld.NodeAssembler = (*_assembler)(nil) - _ ipld.NodeBuilder = (*_builderRepr)(nil) - _ ipld.NodeAssembler = (*_assemblerRepr)(nil) - - _ ipld.MapAssembler = (*_structAssembler)(nil) - _ ipld.MapIterator = (*_structIterator)(nil) - _ ipld.MapAssembler = (*_structAssemblerRepr)(nil) - _ ipld.MapIterator = (*_structIteratorRepr)(nil) - - _ ipld.ListAssembler = (*_listAssembler)(nil) - _ ipld.ListIterator = (*_listIterator)(nil) - _ ipld.ListAssembler = (*_listAssemblerRepr)(nil) - - _ ipld.MapAssembler = (*_unionAssembler)(nil) - _ ipld.MapIterator = (*_unionIterator)(nil) - _ ipld.MapAssembler = (*_unionAssemblerRepr)(nil) - _ ipld.MapIterator = (*_unionIteratorRepr)(nil) + _ datamodel.Node = (*_nodeRepr)(nil) + + _ datamodel.NodeBuilder = (*_builder)(nil) + _ datamodel.NodeAssembler = (*_assembler)(nil) + _ datamodel.NodeBuilder = (*_builderRepr)(nil) + _ datamodel.NodeAssembler = (*_assemblerRepr)(nil) + + _ datamodel.MapAssembler = (*_structAssembler)(nil) + _ datamodel.MapIterator = (*_structIterator)(nil) + _ datamodel.MapAssembler = (*_structAssemblerRepr)(nil) + _ datamodel.MapIterator = (*_structIteratorRepr)(nil) + + _ datamodel.ListAssembler = (*_listAssembler)(nil) + _ datamodel.ListIterator = (*_listIterator)(nil) + _ datamodel.ListAssembler = (*_listAssemblerRepr)(nil) + + _ datamodel.MapAssembler = (*_unionAssembler)(nil) + _ datamodel.MapIterator = (*_unionIterator)(nil) + _ datamodel.MapAssembler = (*_unionAssemblerRepr)(nil) + _ datamodel.MapIterator = (*_unionIteratorRepr)(nil) ) type _prototype struct { @@ -45,7 +45,7 @@ type _prototype struct { goType reflect.Type // non-pointer } -func (w *_prototype) NewBuilder() ipld.NodeBuilder { +func (w *_prototype) NewBuilder() datamodel.NodeBuilder { return &_builder{_assembler{ schemaType: w.schemaType, val: reflect.New(w.goType).Elem(), @@ -56,7 +56,7 @@ func (w *_prototype) Type() schema.Type { return w.schemaType } -func (w *_prototype) Representation() ipld.NodePrototype { +func (w *_prototype) Representation() datamodel.NodePrototype { return (*_prototypeRepr)(w) } @@ -75,20 +75,20 @@ func (w *_node) Type() schema.Type { return w.schemaType } -func (w *_node) Representation() ipld.Node { +func (w *_node) Representation() datamodel.Node { return (*_nodeRepr)(w) } -func (w *_node) Kind() ipld.Kind { +func (w *_node) Kind() datamodel.Kind { return w.schemaType.TypeKind().ActsLike() } -func (w *_node) LookupByString(key string) (ipld.Node, error) { +func (w *_node) LookupByString(key string) (datamodel.Node, error) { switch typ := w.schemaType.(type) { case *schema.TypeStruct: field := typ.Field(key) if field == nil { - return nil, ipld.ErrInvalidKey{ + return nil, schema.ErrInvalidKey{ TypeName: typ.Name().String(), Key: basicnode.NewString(key), } @@ -99,13 +99,13 @@ func (w *_node) LookupByString(key string) (ipld.Node, error) { } if field.IsOptional() { if fval.IsNil() { - return ipld.Absent, nil + return datamodel.Absent, nil } fval = fval.Elem() } if field.IsNullable() { if fval.IsNil() { - return ipld.Null, nil + return datamodel.Null, nil } fval = fval.Elem() } @@ -132,7 +132,7 @@ func (w *_node) LookupByString(key string) (ipld.Node, error) { } fval := valuesVal.MapIndex(kval) if !fval.IsValid() { // not found - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } // TODO: Error/panic if fval.IsNil() && !typ.ValueIsNullable()? // Otherwise we could have two non-equal Go values (nil map, @@ -140,7 +140,7 @@ func (w *_node) LookupByString(key string) (ipld.Node, error) { // node when the field is not nullable. if typ.ValueIsNullable() { if fval.IsNil() { - return ipld.Null, nil + return datamodel.Null, nil } fval = fval.Elem() } @@ -160,12 +160,12 @@ func (w *_node) LookupByString(key string) (ipld.Node, error) { } } if mtyp == nil { // not found - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } // TODO: we could look up the right Go field straight away via idx. haveIdx, mval := unionMember(w.val) if haveIdx != idx { // mismatching type - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } node := &_node{ schemaType: mtyp, @@ -173,7 +173,7 @@ func (w *_node) LookupByString(key string) (ipld.Node, error) { } return node, nil } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "LookupByString", // TODO @@ -202,69 +202,69 @@ func unionSetMember(val reflect.Value, memberIdx int, memberPtr reflect.Value) { val.Field(memberIdx).Set(memberPtr) } -func (w *_node) LookupByIndex(idx int64) (ipld.Node, error) { +func (w *_node) LookupByIndex(idx int64) (datamodel.Node, error) { switch typ := w.schemaType.(type) { case *schema.TypeList: if idx < 0 || int(idx) >= w.val.Len() { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)} } val := w.val.Index(int(idx)) if typ.ValueIsNullable() { if val.IsNil() { - return ipld.Null, nil + return datamodel.Null, nil } val = val.Elem() } return &_node{schemaType: typ.ValueType(), val: val}, nil } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "LookupByIndex", // TODO } } -func (w *_node) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (w *_node) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { switch w.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: return w.LookupByString(seg.String()) - case ipld.Kind_List: + case datamodel.Kind_List: idx, err := seg.Index() if err != nil { return nil, err } return w.LookupByIndex(idx) } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "LookupBySegment", // TODO } } -func (w *_node) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (w *_node) LookupByNode(key datamodel.Node) (datamodel.Node, error) { switch w.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: s, err := key.AsString() if err != nil { return nil, err } return w.LookupByString(s) - case ipld.Kind_List: + case datamodel.Kind_List: i, err := key.AsInt() if err != nil { return nil, err } return w.LookupByIndex(i) } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "LookupByNode", // TODO } } -func (w *_node) MapIterator() ipld.MapIterator { +func (w *_node) MapIterator() datamodel.MapIterator { switch typ := w.schemaType.(type) { case *schema.TypeStruct: return &_structIterator{ @@ -288,7 +288,7 @@ func (w *_node) MapIterator() ipld.MapIterator { return nil } -func (w *_node) ListIterator() ipld.ListIterator { +func (w *_node) ListIterator() datamodel.ListIterator { val := w.val if val.Type().Kind() == reflect.Ptr { if !val.IsNil() { @@ -304,7 +304,7 @@ func (w *_node) ListIterator() ipld.ListIterator { func (w *_node) Length() int64 { switch w.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: switch typ := w.schemaType.(type) { case *schema.TypeStruct: return int64(len(typ.Fields())) @@ -312,7 +312,7 @@ func (w *_node) Length() int64 { return 1 } return int64(w.val.FieldByName("Keys").Len()) - case ipld.Kind_List: + case datamodel.Kind_List: return int64(w.val.Len()) } return -1 @@ -329,8 +329,8 @@ func (w *_node) IsNull() bool { } func (w *_node) AsBool() (bool, error) { - if w.Kind() != ipld.Kind_Bool { - return false, ipld.ErrWrongKind{ + if w.Kind() != datamodel.Kind_Bool { + return false, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsBool", // TODO @@ -340,8 +340,8 @@ func (w *_node) AsBool() (bool, error) { } func (w *_node) AsInt() (int64, error) { - if w.Kind() != ipld.Kind_Int { - return 0, ipld.ErrWrongKind{ + if w.Kind() != datamodel.Kind_Int { + return 0, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsInt", // TODO @@ -351,8 +351,8 @@ func (w *_node) AsInt() (int64, error) { } func (w *_node) AsFloat() (float64, error) { - if w.Kind() != ipld.Kind_Float { - return 0, ipld.ErrWrongKind{ + if w.Kind() != datamodel.Kind_Float { + return 0, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsFloat", // TODO @@ -362,8 +362,8 @@ func (w *_node) AsFloat() (float64, error) { } func (w *_node) AsString() (string, error) { - if w.Kind() != ipld.Kind_String { - return "", ipld.ErrWrongKind{ + if w.Kind() != datamodel.Kind_String { + return "", datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsString", // TODO @@ -373,8 +373,8 @@ func (w *_node) AsString() (string, error) { } func (w *_node) AsBytes() ([]byte, error) { - if w.Kind() != ipld.Kind_Bytes { - return nil, ipld.ErrWrongKind{ + if w.Kind() != datamodel.Kind_Bytes { + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsBytes", // TODO @@ -383,19 +383,19 @@ func (w *_node) AsBytes() ([]byte, error) { return w.val.Bytes(), nil } -func (w *_node) AsLink() (ipld.Link, error) { - if w.Kind() != ipld.Kind_Link { - return nil, ipld.ErrWrongKind{ +func (w *_node) AsLink() (datamodel.Link, error) { + if w.Kind() != datamodel.Kind_Link { + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsLink", // TODO } } - link, _ := w.val.Interface().(ipld.Link) + link, _ := w.val.Interface().(datamodel.Link) return link, nil } -func (w *_node) Prototype() ipld.NodePrototype { +func (w *_node) Prototype() datamodel.NodePrototype { panic("TODO: Prototype") } @@ -403,7 +403,7 @@ type _builder struct { _assembler } -func (w *_builder) Build() ipld.Node { +func (w *_builder) Build() datamodel.Node { // TODO: should we panic if no Assign call was made, just like codegen? return &_node{schemaType: w.schemaType, val: w.val} } @@ -430,15 +430,15 @@ func (w *_assembler) nonPtrVal() reflect.Value { return val } -func (w *_assembler) kind() ipld.Kind { +func (w *_assembler) kind() datamodel.Kind { return w.schemaType.TypeKind().ActsLike() } -func (w *_assembler) Representation() ipld.NodeAssembler { +func (w *_assembler) Representation() datamodel.NodeAssembler { return (*_assemblerRepr)(w) } -func (w *_assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (w *_assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch typ := w.schemaType.(type) { case *schema.TypeStruct: val := w.nonPtrVal() @@ -470,14 +470,14 @@ func (w *_assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { finish: w.finish, }, nil } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "BeginMap", // TODO } } -func (w *_assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (w *_assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch typ := w.schemaType.(type) { case *schema.TypeList: val := w.nonPtrVal() @@ -487,7 +487,7 @@ func (w *_assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { finish: w.finish, }, nil } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "BeginList", // TODO @@ -496,7 +496,7 @@ func (w *_assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { func (w *_assembler) AssignNull() error { if !w.nullable { - return ipld.ErrWrongKind{ + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignNull", // TODO @@ -512,11 +512,11 @@ func (w *_assembler) AssignNull() error { } func (w *_assembler) AssignBool(b bool) error { - if w.kind() != ipld.Kind_Bool { - return ipld.ErrWrongKind{ + if w.kind() != datamodel.Kind_Bool { + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignBool", - AppropriateKind: ipld.KindSet{ipld.Kind_Bool}, + AppropriateKind: datamodel.KindSet{datamodel.Kind_Bool}, ActualKind: w.kind(), } } @@ -530,11 +530,11 @@ func (w *_assembler) AssignBool(b bool) error { } func (w *_assembler) AssignInt(i int64) error { - if w.kind() != ipld.Kind_Int { - return ipld.ErrWrongKind{ + if w.kind() != datamodel.Kind_Int { + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignInt", - AppropriateKind: ipld.KindSet{ipld.Kind_Int}, + AppropriateKind: datamodel.KindSet{datamodel.Kind_Int}, ActualKind: w.kind(), } } @@ -548,11 +548,11 @@ func (w *_assembler) AssignInt(i int64) error { } func (w *_assembler) AssignFloat(f float64) error { - if w.kind() != ipld.Kind_Float { - return ipld.ErrWrongKind{ + if w.kind() != datamodel.Kind_Float { + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignFloat", - AppropriateKind: ipld.KindSet{ipld.Kind_Float}, + AppropriateKind: datamodel.KindSet{datamodel.Kind_Float}, ActualKind: w.kind(), } } @@ -566,11 +566,11 @@ func (w *_assembler) AssignFloat(f float64) error { } func (w *_assembler) AssignString(s string) error { - if w.kind() != ipld.Kind_String { - return ipld.ErrWrongKind{ + if w.kind() != datamodel.Kind_String { + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignString", - AppropriateKind: ipld.KindSet{ipld.Kind_String}, + AppropriateKind: datamodel.KindSet{datamodel.Kind_String}, ActualKind: w.kind(), } } @@ -584,11 +584,11 @@ func (w *_assembler) AssignString(s string) error { } func (w *_assembler) AssignBytes(p []byte) error { - if w.kind() != ipld.Kind_Bytes { - return ipld.ErrWrongKind{ + if w.kind() != datamodel.Kind_Bytes { + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignBytes", - AppropriateKind: ipld.KindSet{ipld.Kind_Bytes}, + AppropriateKind: datamodel.KindSet{datamodel.Kind_Bytes}, ActualKind: w.kind(), } } @@ -596,10 +596,10 @@ func (w *_assembler) AssignBytes(p []byte) error { return nil } -func (w *_assembler) AssignLink(link ipld.Link) error { +func (w *_assembler) AssignLink(link datamodel.Link) error { newVal := reflect.ValueOf(link) if !newVal.Type().AssignableTo(w.val.Type()) { - return ipld.ErrWrongKind{ + return datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AssignLink", // TODO @@ -614,7 +614,7 @@ func (w *_assembler) AssignLink(link ipld.Link) error { return nil } -func (w *_assembler) AssignNode(node ipld.Node) error { +func (w *_assembler) AssignNode(node datamodel.Node) error { // TODO: does this ever trigger? // newVal := reflect.ValueOf(node) // if newVal.Type().AssignableTo(w.val.Type()) { @@ -622,10 +622,10 @@ func (w *_assembler) AssignNode(node ipld.Node) error { // return nil // } switch node.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: itr := node.MapIterator() // TODO: consider reusing this code from elsewhere, - // via something like ipld.BlindCopyMap. + // via something like datamodel.BlindCopyMap. am, err := w.BeginMap(-1) // TODO: length? if err != nil { return err @@ -643,7 +643,7 @@ func (w *_assembler) AssignNode(node ipld.Node) error { } } return am.Finish() - case ipld.Kind_List: + case datamodel.Kind_List: itr := node.ListIterator() am, err := w.BeginList(-1) // TODO: length? if err != nil { @@ -660,50 +660,50 @@ func (w *_assembler) AssignNode(node ipld.Node) error { } return am.Finish() - case ipld.Kind_Bool: + case datamodel.Kind_Bool: b, err := node.AsBool() if err != nil { return err } return w.AssignBool(b) - case ipld.Kind_Int: + case datamodel.Kind_Int: i, err := node.AsInt() if err != nil { return err } return w.AssignInt(i) - case ipld.Kind_Float: + case datamodel.Kind_Float: f, err := node.AsFloat() if err != nil { return err } return w.AssignFloat(f) - case ipld.Kind_String: + case datamodel.Kind_String: s, err := node.AsString() if err != nil { return err } return w.AssignString(s) - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: p, err := node.AsBytes() if err != nil { return err } return w.AssignBytes(p) - case ipld.Kind_Link: + case datamodel.Kind_Link: l, err := node.AsLink() if err != nil { return err } return w.AssignLink(l) - case ipld.Kind_Null: + case datamodel.Kind_Null: return w.AssignNull() } // fmt.Println(w.val.Type(), reflect.TypeOf(node)) panic(fmt.Sprintf("TODO: %v %v", w.val.Type(), node.Kind())) } -func (w *_assembler) Prototype() ipld.NodePrototype { +func (w *_assembler) Prototype() datamodel.NodePrototype { panic("TODO: Assembler.Prototype") } @@ -728,7 +728,7 @@ type _structAssembler struct { nextIndex int // only used by repr.go } -func (w *_structAssembler) AssembleKey() ipld.NodeAssembler { +func (w *_structAssembler) AssembleKey() datamodel.NodeAssembler { w.curKey = _assembler{ schemaType: schemaTypeString, val: reflect.New(goTypeString).Elem(), @@ -736,13 +736,13 @@ func (w *_structAssembler) AssembleKey() ipld.NodeAssembler { return &w.curKey } -func (w *_structAssembler) AssembleValue() ipld.NodeAssembler { +func (w *_structAssembler) AssembleValue() datamodel.NodeAssembler { // TODO: optimize this to do one lookup by name name := w.curKey.val.String() field := w.schemaType.Field(name) if field == nil { panic(name) - // return nil, ipld.ErrInvalidKey{ + // return nil, datamodel.ErrInvalidKey{ // TypeName: w.schemaType.Name().String(), // Key: basicnode.NewString(name), // } @@ -769,7 +769,7 @@ func (w *_structAssembler) AssembleValue() ipld.NodeAssembler { } } -func (w *_structAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (w *_structAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { if err := w.AssembleKey().AssignString(k); err != nil { return nil, err } @@ -786,7 +786,7 @@ func (w *_structAssembler) Finish() error { } } if len(missing) > 0 { - return ipld.ErrMissingRequiredField{Missing: missing} + return schema.ErrMissingRequiredField{Missing: missing} } if w.finish != nil { if err := w.finish(); err != nil { @@ -796,13 +796,13 @@ func (w *_structAssembler) Finish() error { return nil } -func (w *_structAssembler) KeyPrototype() ipld.NodePrototype { +func (w *_structAssembler) KeyPrototype() datamodel.NodePrototype { // TODO: if the user provided their own schema with their own typesystem, // the schemaTypeString here may be using the wrong typesystem. return &_prototype{schemaType: schemaTypeString, goType: goTypeString} } -func (w *_structAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (w *_structAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("TODO: struct ValuePrototype") } @@ -819,7 +819,7 @@ type _mapAssembler struct { nextIndex int // only used by repr.go } -func (w *_mapAssembler) AssembleKey() ipld.NodeAssembler { +func (w *_mapAssembler) AssembleKey() datamodel.NodeAssembler { w.curKey = _assembler{ schemaType: w.schemaType.KeyType(), val: reflect.New(w.valuesVal.Type().Key()).Elem(), @@ -827,7 +827,7 @@ func (w *_mapAssembler) AssembleKey() ipld.NodeAssembler { return &w.curKey } -func (w *_mapAssembler) AssembleValue() ipld.NodeAssembler { +func (w *_mapAssembler) AssembleValue() datamodel.NodeAssembler { kval := w.curKey.val val := reflect.New(w.valuesVal.Type().Elem()).Elem() finish := func() error { @@ -847,7 +847,7 @@ func (w *_mapAssembler) AssembleValue() ipld.NodeAssembler { } } -func (w *_mapAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (w *_mapAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { if err := w.AssembleKey().AssignString(k); err != nil { return nil, err } @@ -864,11 +864,11 @@ func (w *_mapAssembler) Finish() error { return nil } -func (w *_mapAssembler) KeyPrototype() ipld.NodePrototype { +func (w *_mapAssembler) KeyPrototype() datamodel.NodePrototype { return &_prototype{schemaType: w.schemaType.KeyType(), goType: w.valuesVal.Type().Key()} } -func (w *_mapAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (w *_mapAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("TODO: struct ValuePrototype") } @@ -878,7 +878,7 @@ type _listAssembler struct { finish func() error } -func (w *_listAssembler) AssembleValue() ipld.NodeAssembler { +func (w *_listAssembler) AssembleValue() datamodel.NodeAssembler { goType := w.val.Type().Elem() // TODO: use a finish func to append w.val.Set(reflect.Append(w.val, reflect.New(goType).Elem())) @@ -898,7 +898,7 @@ func (w *_listAssembler) Finish() error { return nil } -func (w *_listAssembler) ValuePrototype(idx int64) ipld.NodePrototype { +func (w *_listAssembler) ValuePrototype(idx int64) datamodel.NodePrototype { panic("TODO: list ValuePrototype") } @@ -914,7 +914,7 @@ type _unionAssembler struct { nextIndex int // only used by repr.go } -func (w *_unionAssembler) AssembleKey() ipld.NodeAssembler { +func (w *_unionAssembler) AssembleKey() datamodel.NodeAssembler { w.curKey = _assembler{ schemaType: schemaTypeString, val: reflect.New(goTypeString).Elem(), @@ -922,7 +922,7 @@ func (w *_unionAssembler) AssembleKey() ipld.NodeAssembler { return &w.curKey } -func (w *_unionAssembler) AssembleValue() ipld.NodeAssembler { +func (w *_unionAssembler) AssembleValue() datamodel.NodeAssembler { name := w.curKey.val.String() var idx int var mtyp schema.Type @@ -935,7 +935,7 @@ func (w *_unionAssembler) AssembleValue() ipld.NodeAssembler { } if mtyp == nil { panic("TODO: missing member") - // return nil, ipld.ErrInvalidKey{ + // return nil, datamodel.ErrInvalidKey{ // TypeName: w.schemaType.Name().String(), // Key: basicnode.NewString(name), // } @@ -955,7 +955,7 @@ func (w *_unionAssembler) AssembleValue() ipld.NodeAssembler { } } -func (w *_unionAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (w *_unionAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { if err := w.AssembleKey().AssignString(k); err != nil { return nil, err } @@ -972,11 +972,11 @@ func (w *_unionAssembler) Finish() error { return nil } -func (w *_unionAssembler) KeyPrototype() ipld.NodePrototype { +func (w *_unionAssembler) KeyPrototype() datamodel.NodePrototype { return &_prototype{schemaType: schemaTypeString, goType: goTypeString} } -func (w *_unionAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (w *_unionAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("TODO: struct ValuePrototype") } @@ -991,9 +991,9 @@ type _structIterator struct { reprEnd int } -func (w *_structIterator) Next() (key, value ipld.Node, _ error) { +func (w *_structIterator) Next() (key, value datamodel.Node, _ error) { if w.Done() { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } field := w.fields[w.nextIndex] val := w.val.Field(w.nextIndex) @@ -1001,13 +1001,13 @@ func (w *_structIterator) Next() (key, value ipld.Node, _ error) { key = basicnode.NewString(field.Name()) if field.IsOptional() { if val.IsNil() { - return key, ipld.Absent, nil + return key, datamodel.Absent, nil } val = val.Elem() } if field.IsNullable() { if val.IsNil() { - return key, ipld.Null, nil + return key, datamodel.Null, nil } val = val.Elem() } @@ -1029,9 +1029,9 @@ type _mapIterator struct { nextIndex int } -func (w *_mapIterator) Next() (key, value ipld.Node, _ error) { +func (w *_mapIterator) Next() (key, value datamodel.Node, _ error) { if w.Done() { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } goKey := w.keysVal.Index(w.nextIndex) val := w.valuesVal.MapIndex(goKey) @@ -1043,7 +1043,7 @@ func (w *_mapIterator) Next() (key, value ipld.Node, _ error) { } if w.schemaType.ValueIsNullable() { if val.IsNil() { - return key, ipld.Null, nil + return key, datamodel.Null, nil } val = val.Elem() } @@ -1064,16 +1064,16 @@ type _listIterator struct { nextIndex int } -func (w *_listIterator) Next() (index int64, value ipld.Node, _ error) { +func (w *_listIterator) Next() (index int64, value datamodel.Node, _ error) { if w.Done() { - return 0, nil, ipld.ErrIteratorOverread{} + return 0, nil, datamodel.ErrIteratorOverread{} } idx := int64(w.nextIndex) val := w.val.Index(w.nextIndex) w.nextIndex++ if w.schemaType.ValueIsNullable() { if val.IsNil() { - return idx, ipld.Null, nil + return idx, datamodel.Null, nil } val = val.Elem() } @@ -1093,9 +1093,9 @@ type _unionIterator struct { done bool } -func (w *_unionIterator) Next() (key, value ipld.Node, _ error) { +func (w *_unionIterator) Next() (key, value datamodel.Node, _ error) { if w.Done() { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } w.done = true @@ -1117,9 +1117,9 @@ func (w *_unionIterator) Done() bool { // TODO: consider making our own Node interface, like: // // type WrappedNode interface { -// ipld.Node +// datamodel.Node // Unwrap() (ptr interface) // } // -// Pros: API is easier to understand, harder to mix up with other ipld.Nodes. -// Cons: One usually only has an ipld.Node, and type assertions can be weird. +// Pros: API is easier to understand, harder to mix up with other datamodel.Nodes. +// Cons: One usually only has an datamodel.Node, and type assertions can be weird. diff --git a/node/bindnode/repr.go b/node/bindnode/repr.go index 77b52ef3..d048ae74 100644 --- a/node/bindnode/repr.go +++ b/node/bindnode/repr.go @@ -5,16 +5,16 @@ import ( "reflect" "strings" - ipld "github.com/ipld/go-ipld-prime" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/schema" ) -func reprNode(node ipld.Node) ipld.Node { +func reprNode(node datamodel.Node) datamodel.Node { if node, ok := node.(schema.TypedNode); ok { return node.Representation() } - // ipld.Absent and ipld.Null are not typed. + // datamodel.Absent and datamodel.Null are not typed. // TODO: is this a problem? surely a typed struct's fields are always // typed, even when absent or null. return node @@ -32,7 +32,7 @@ func reprStrategy(typ schema.Type) interface{} { type _prototypeRepr _prototype -func (w *_prototypeRepr) NewBuilder() ipld.NodeBuilder { +func (w *_prototypeRepr) NewBuilder() datamodel.NodeBuilder { return &_builderRepr{_assemblerRepr{ schemaType: w.schemaType, val: reflect.New(w.goType).Elem(), @@ -41,22 +41,22 @@ func (w *_prototypeRepr) NewBuilder() ipld.NodeBuilder { type _nodeRepr _node -func (w *_nodeRepr) Kind() ipld.Kind { +func (w *_nodeRepr) Kind() datamodel.Kind { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Stringjoin: - return ipld.Kind_String + return datamodel.Kind_String case schema.StructRepresentation_Map: - return ipld.Kind_Map + return datamodel.Kind_Map case schema.StructRepresentation_Tuple: - return ipld.Kind_List + return datamodel.Kind_List case schema.UnionRepresentation_Keyed: - return ipld.Kind_Map + return datamodel.Kind_Map case schema.UnionRepresentation_Kinded: haveIdx, _ := unionMember(w.val) mtyp := w.schemaType.(*schema.TypeUnion).Members()[haveIdx] return mtyp.TypeKind().ActsLike() case schema.UnionRepresentation_Stringprefix: - return ipld.Kind_String + return datamodel.Kind_String case nil: return (*_node)(w).Kind() default: @@ -105,7 +105,7 @@ func inboundMappedType(typ *schema.TypeUnion, stg schema.UnionRepresentation_Key return key // fallback to the same key } -func (w *_nodeRepr) asKinded(stg schema.UnionRepresentation_Kinded, kind ipld.Kind) *_nodeRepr { +func (w *_nodeRepr) asKinded(stg schema.UnionRepresentation_Kinded, kind datamodel.Kind) *_nodeRepr { name := stg.GetMember(kind) members := w.schemaType.(*schema.TypeUnion).Members() for i, member := range members { @@ -120,9 +120,9 @@ func (w *_nodeRepr) asKinded(stg schema.UnionRepresentation_Kinded, kind ipld.Ki return nil } -func (w *_nodeRepr) LookupByString(key string) (ipld.Node, error) { +func (w *_nodeRepr) LookupByString(key string) (datamodel.Node, error) { if stg, ok := reprStrategy(w.schemaType).(schema.UnionRepresentation_Kinded); ok { - w = w.asKinded(stg, ipld.Kind_Map) + w = w.asKinded(stg, datamodel.Kind_Map) } switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Map: @@ -150,7 +150,7 @@ func (w *_nodeRepr) LookupByString(key string) (ipld.Node, error) { } } -func (w *_nodeRepr) LookupByIndex(idx int64) (ipld.Node, error) { +func (w *_nodeRepr) LookupByIndex(idx int64) (datamodel.Node, error) { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Tuple: fields := w.schemaType.(*schema.TypeStruct).Fields() @@ -171,49 +171,49 @@ func (w *_nodeRepr) LookupByIndex(idx int64) (ipld.Node, error) { } } -func (w *_nodeRepr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (w *_nodeRepr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { switch w.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: return w.LookupByString(seg.String()) - case ipld.Kind_List: + case datamodel.Kind_List: idx, err := seg.Index() if err != nil { return nil, err } return w.LookupByIndex(idx) } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "LookupBySegment", // TODO } } -func (w *_nodeRepr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (w *_nodeRepr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { switch w.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: s, err := key.AsString() if err != nil { return nil, err } return w.LookupByString(s) - case ipld.Kind_List: + case datamodel.Kind_List: i, err := key.AsInt() if err != nil { return nil, err } return w.LookupByIndex(i) } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "LookupByNode", // TODO } } -func (w *_nodeRepr) MapIterator() ipld.MapIterator { +func (w *_nodeRepr) MapIterator() datamodel.MapIterator { if stg, ok := reprStrategy(w.schemaType).(schema.UnionRepresentation_Kinded); ok { - w = w.asKinded(stg, ipld.Kind_Map) + w = w.asKinded(stg, datamodel.Kind_Map) } switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Map: @@ -230,7 +230,7 @@ func (w *_nodeRepr) MapIterator() ipld.MapIterator { } } -func (w *_nodeRepr) ListIterator() ipld.ListIterator { +func (w *_nodeRepr) ListIterator() datamodel.ListIterator { if reprStrategy(w.schemaType) == nil { return (*_node)(w).ListIterator() } @@ -287,10 +287,10 @@ func (w *_nodeRepr) AsBool() (bool, error) { if reprStrategy(w.schemaType) == nil { return (*_node)(w).AsBool() } - return false, ipld.ErrWrongKind{ + return false, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsBool", - AppropriateKind: ipld.KindSet_JustBool, + AppropriateKind: datamodel.KindSet_JustBool, // TODO } } @@ -299,10 +299,10 @@ func (w *_nodeRepr) AsInt() (int64, error) { if reprStrategy(w.schemaType) == nil { return (*_node)(w).AsInt() } - return 0, ipld.ErrWrongKind{ + return 0, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsInt", - AppropriateKind: ipld.KindSet_JustInt, + AppropriateKind: datamodel.KindSet_JustInt, // TODO } } @@ -311,10 +311,10 @@ func (w *_nodeRepr) AsFloat() (float64, error) { if reprStrategy(w.schemaType) == nil { return (*_node)(w).AsFloat() } - return 0, ipld.ErrWrongKind{ + return 0, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsFloat", - AppropriateKind: ipld.KindSet_JustFloat, + AppropriateKind: datamodel.KindSet_JustFloat, // TODO } } @@ -354,7 +354,7 @@ func (w *_nodeRepr) AsString() (string, error) { name := stg.GetDiscriminant(mtyp) return name + stg.GetDelim() + s, nil case schema.UnionRepresentation_Kinded: - w = w.asKinded(stg, ipld.Kind_String) + w = w.asKinded(stg, datamodel.Kind_String) // continues below case nil: // continues below @@ -368,27 +368,27 @@ func (w *_nodeRepr) AsBytes() ([]byte, error) { if reprStrategy(w.schemaType) == nil { return (*_node)(w).AsBytes() } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsBytes", - AppropriateKind: ipld.KindSet_JustBytes, + AppropriateKind: datamodel.KindSet_JustBytes, // TODO } } -func (w *_nodeRepr) AsLink() (ipld.Link, error) { +func (w *_nodeRepr) AsLink() (datamodel.Link, error) { if reprStrategy(w.schemaType) == nil { return (*_node)(w).AsLink() } - return nil, ipld.ErrWrongKind{ + return nil, datamodel.ErrWrongKind{ TypeName: w.schemaType.Name().String(), MethodName: "AsLink", - AppropriateKind: ipld.KindSet_JustLink, + AppropriateKind: datamodel.KindSet_JustLink, // TODO } } -func (w *_nodeRepr) Prototype() ipld.NodePrototype { +func (w *_nodeRepr) Prototype() datamodel.NodePrototype { panic("TODO: Prototype") } @@ -402,7 +402,7 @@ type _builderRepr struct { // The solution might be to add a way to go from the repr node to its parent // typed node. -func (w *_builderRepr) Build() ipld.Node { +func (w *_builderRepr) Build() datamodel.Node { // TODO: see the notes above. // return &_nodeRepr{schemaType: w.schemaType, val: w.val} return &_node{schemaType: w.schemaType, val: w.val} @@ -420,11 +420,11 @@ type _assemblerRepr struct { nullable bool } -func assemblerRepr(am ipld.NodeAssembler) *_assemblerRepr { +func assemblerRepr(am datamodel.NodeAssembler) *_assemblerRepr { return (*_assemblerRepr)(am.(*_assembler)) } -func (w *_assemblerRepr) asKinded(stg schema.UnionRepresentation_Kinded, kind ipld.Kind) *_assemblerRepr { +func (w *_assemblerRepr) asKinded(stg schema.UnionRepresentation_Kinded, kind datamodel.Kind) *_assemblerRepr { name := stg.GetMember(kind) members := w.schemaType.(*schema.TypeUnion).Members() for idx, member := range members { @@ -452,9 +452,9 @@ func (w *_assemblerRepr) asKinded(stg schema.UnionRepresentation_Kinded, kind ip return nil } -func (w *_assemblerRepr) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (w *_assemblerRepr) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { if stg, ok := reprStrategy(w.schemaType).(schema.UnionRepresentation_Kinded); ok { - w = w.asKinded(stg, ipld.Kind_Map) + w = w.asKinded(stg, datamodel.Kind_Map) } asm, err := (*_assembler)(w).BeginMap(sizeHint) if err != nil { @@ -472,7 +472,7 @@ func (w *_assemblerRepr) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { } } -func (w *_assemblerRepr) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (w *_assemblerRepr) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Tuple: asm, err := (*_assembler)(w).BeginMap(sizeHint) @@ -551,7 +551,7 @@ func (w *_assemblerRepr) AssignString(s string) error { } return mapAsm.Finish() case schema.UnionRepresentation_Kinded: - w2 := w.asKinded(stg, ipld.Kind_String) + w2 := w.asKinded(stg, datamodel.Kind_String) if w2 == nil { panic("TODO: GetMember result is missing?") } @@ -616,7 +616,7 @@ func (w *_assemblerRepr) AssignBytes(p []byte) error { } } -func (w *_assemblerRepr) AssignLink(link ipld.Link) error { +func (w *_assemblerRepr) AssignLink(link datamodel.Link) error { switch stg := reprStrategy(w.schemaType).(type) { case nil: return (*_assembler)(w).AssignLink(link) @@ -625,7 +625,7 @@ func (w *_assemblerRepr) AssignLink(link ipld.Link) error { } } -func (w *_assemblerRepr) AssignNode(node ipld.Node) error { +func (w *_assemblerRepr) AssignNode(node datamodel.Node) error { switch stg := reprStrategy(w.schemaType).(type) { case nil: return (*_assembler)(w).AssignNode(node) @@ -634,13 +634,13 @@ func (w *_assemblerRepr) AssignNode(node ipld.Node) error { } } -func (w *_assemblerRepr) Prototype() ipld.NodePrototype { +func (w *_assemblerRepr) Prototype() datamodel.NodePrototype { panic("TODO: Assembler.Prototype") } type _structAssemblerRepr _structAssembler -func (w *_structAssemblerRepr) AssembleKey() ipld.NodeAssembler { +func (w *_structAssemblerRepr) AssembleKey() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Map: return (*_structAssembler)(w).AssembleKey() @@ -648,25 +648,25 @@ func (w *_structAssemblerRepr) AssembleKey() ipld.NodeAssembler { schema.StructRepresentation_StringPairs: // TODO an error-carrying "NodeAssembler" is needed so that this can refrain from panicking. // TODO perhaps the ErrorWrongKind type should also be extended to explicitly describe whether the method was applied on bare DM, type-level, or repr-level. - panic(&ipld.ErrWrongKind{ + panic(&datamodel.ErrWrongKind{ TypeName: string(w.schemaType.Name()) + ".Repr", MethodName: "AssembleKey", - AppropriateKind: ipld.KindSet_JustMap, - ActualKind: ipld.Kind_String, + AppropriateKind: datamodel.KindSet_JustMap, + ActualKind: datamodel.Kind_String, }) case schema.StructRepresentation_Tuple: - panic(&ipld.ErrWrongKind{ + panic(&datamodel.ErrWrongKind{ TypeName: string(w.schemaType.Name()) + ".Repr", MethodName: "AssembleKey", - AppropriateKind: ipld.KindSet_JustMap, - ActualKind: ipld.Kind_List, + AppropriateKind: datamodel.KindSet_JustMap, + ActualKind: datamodel.Kind_List, }) default: panic(fmt.Sprintf("TODO: %T", stg)) } } -func (w *_structAssemblerRepr) AssembleValue() ipld.NodeAssembler { +func (w *_structAssemblerRepr) AssembleValue() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Map: key := w.curKey.val.String() @@ -681,7 +681,7 @@ func (w *_structAssemblerRepr) AssembleValue() ipld.NodeAssembler { } } -func (w *_structAssemblerRepr) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (w *_structAssemblerRepr) AssembleEntry(k string) (datamodel.NodeAssembler, error) { if err := w.AssembleKey().AssignString(k); err != nil { return nil, err } @@ -693,7 +693,7 @@ func (w *_structAssemblerRepr) Finish() error { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Map: err := (*_structAssembler)(w).Finish() - if err, ok := err.(ipld.ErrMissingRequiredField); ok { + if err, ok := err.(schema.ErrMissingRequiredField); ok { for i, name := range err.Missing { serial := outboundMappedKey(stg, name) if serial != name { @@ -707,17 +707,17 @@ func (w *_structAssemblerRepr) Finish() error { } } -func (w *_structAssemblerRepr) KeyPrototype() ipld.NodePrototype { +func (w *_structAssemblerRepr) KeyPrototype() datamodel.NodePrototype { panic("TODO") } -func (w *_structAssemblerRepr) ValuePrototype(k string) ipld.NodePrototype { +func (w *_structAssemblerRepr) ValuePrototype(k string) datamodel.NodePrototype { panic("TODO: struct ValuePrototype") } type _mapAssemblerRepr _mapAssembler -func (w *_mapAssemblerRepr) AssembleKey() ipld.NodeAssembler { +func (w *_mapAssemblerRepr) AssembleKey() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case nil: asm := (*_mapAssembler)(w).AssembleKey() @@ -727,7 +727,7 @@ func (w *_mapAssemblerRepr) AssembleKey() ipld.NodeAssembler { } } -func (w *_mapAssemblerRepr) AssembleValue() ipld.NodeAssembler { +func (w *_mapAssemblerRepr) AssembleValue() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case nil: asm := (*_mapAssembler)(w).AssembleValue() @@ -737,7 +737,7 @@ func (w *_mapAssemblerRepr) AssembleValue() ipld.NodeAssembler { } } -func (w *_mapAssemblerRepr) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (w *_mapAssemblerRepr) AssembleEntry(k string) (datamodel.NodeAssembler, error) { if err := w.AssembleKey().AssignString(k); err != nil { return nil, err } @@ -754,17 +754,17 @@ func (w *_mapAssemblerRepr) Finish() error { } } -func (w *_mapAssemblerRepr) KeyPrototype() ipld.NodePrototype { +func (w *_mapAssemblerRepr) KeyPrototype() datamodel.NodePrototype { panic("TODO") } -func (w *_mapAssemblerRepr) ValuePrototype(k string) ipld.NodePrototype { +func (w *_mapAssemblerRepr) ValuePrototype(k string) datamodel.NodePrototype { panic("TODO: struct ValuePrototype") } type _listStructAssemblerRepr _structAssembler -func (w *_listStructAssemblerRepr) AssembleValue() ipld.NodeAssembler { +func (w *_listStructAssemblerRepr) AssembleValue() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Tuple: fields := w.schemaType.Fields() @@ -791,14 +791,14 @@ func (w *_listStructAssemblerRepr) Finish() error { } } -func (w *_listStructAssemblerRepr) ValuePrototype(idx int64) ipld.NodePrototype { +func (w *_listStructAssemblerRepr) ValuePrototype(idx int64) datamodel.NodePrototype { panic("TODO: list ValuePrototype") } // Note that lists do not have any representation strategy right now. type _listAssemblerRepr _listAssembler -func (w *_listAssemblerRepr) AssembleValue() ipld.NodeAssembler { +func (w *_listAssemblerRepr) AssembleValue() datamodel.NodeAssembler { asm := (*_listAssembler)(w).AssembleValue() return (*_assemblerRepr)(asm.(*_assembler)) } @@ -807,13 +807,13 @@ func (w *_listAssemblerRepr) Finish() error { return (*_listAssembler)(w).Finish() } -func (w *_listAssemblerRepr) ValuePrototype(idx int64) ipld.NodePrototype { +func (w *_listAssemblerRepr) ValuePrototype(idx int64) datamodel.NodePrototype { panic("TODO: list ValuePrototype") } type _unionAssemblerRepr _unionAssembler -func (w *_unionAssemblerRepr) AssembleKey() ipld.NodeAssembler { +func (w *_unionAssemblerRepr) AssembleKey() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case schema.UnionRepresentation_Keyed: return (*_unionAssembler)(w).AssembleKey() @@ -822,7 +822,7 @@ func (w *_unionAssemblerRepr) AssembleKey() ipld.NodeAssembler { } } -func (w *_unionAssemblerRepr) AssembleValue() ipld.NodeAssembler { +func (w *_unionAssemblerRepr) AssembleValue() datamodel.NodeAssembler { switch stg := reprStrategy(w.schemaType).(type) { case schema.UnionRepresentation_Keyed: key := w.curKey.val.String() @@ -837,7 +837,7 @@ func (w *_unionAssemblerRepr) AssembleValue() ipld.NodeAssembler { } } -func (w *_unionAssemblerRepr) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (w *_unionAssemblerRepr) AssembleEntry(k string) (datamodel.NodeAssembler, error) { if err := w.AssembleKey().AssignString(k); err != nil { return nil, err } @@ -854,17 +854,17 @@ func (w *_unionAssemblerRepr) Finish() error { } } -func (w *_unionAssemblerRepr) KeyPrototype() ipld.NodePrototype { +func (w *_unionAssemblerRepr) KeyPrototype() datamodel.NodePrototype { panic("TODO") } -func (w *_unionAssemblerRepr) ValuePrototype(k string) ipld.NodePrototype { +func (w *_unionAssemblerRepr) ValuePrototype(k string) datamodel.NodePrototype { panic("TODO: struct ValuePrototype") } type _structIteratorRepr _structIterator -func (w *_structIteratorRepr) Next() (key, value ipld.Node, _ error) { +func (w *_structIteratorRepr) Next() (key, value datamodel.Node, _ error) { switch stg := reprStrategy(w.schemaType).(type) { case schema.StructRepresentation_Map: _skipAbsent: @@ -899,7 +899,7 @@ func (w *_structIteratorRepr) Done() bool { type _unionIteratorRepr _unionIterator -func (w *_unionIteratorRepr) Next() (key, value ipld.Node, _ error) { +func (w *_unionIteratorRepr) Next() (key, value datamodel.Node, _ error) { switch stg := reprStrategy(w.schemaType).(type) { case schema.UnionRepresentation_Keyed: key, value, err := (*_unionIterator)(w).Next() diff --git a/node/bindnode/schema_test.go b/node/bindnode/schema_test.go index e8e9696a..c67ae254 100644 --- a/node/bindnode/schema_test.go +++ b/node/bindnode/schema_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/bindnode" "github.com/ipld/go-ipld-prime/node/tests" "github.com/ipld/go-ipld-prime/schema" @@ -38,7 +38,7 @@ func (e *bindEngine) Init(t *testing.T, ts schema.TypeSystem) { e.ts = ts } -func (e *bindEngine) PrototypeByName(name string) ipld.NodePrototype { +func (e *bindEngine) PrototypeByName(name string) datamodel.NodePrototype { wantRepr := strings.HasSuffix(name, ".Repr") if wantRepr { name = strings.TrimSuffix(name, ".Repr") diff --git a/node/doc.go b/node/doc.go index a1e6a3b4..c62436d8 100644 --- a/node/doc.go +++ b/node/doc.go @@ -1,6 +1,6 @@ /* The 'node' package gathers various general purpose Node implementations; - the first one you should jump to is 'node/basic'. + the first one you should jump to is 'node/basicnode'. There's no code in this package itself; it's just for grouping. diff --git a/node/gendemo/gendemo_test.go b/node/gendemo/gendemo_test.go index 514713da..932a08af 100644 --- a/node/gendemo/gendemo_test.go +++ b/node/gendemo/gendemo_test.go @@ -18,9 +18,6 @@ func BenchmarkMapStrInt_3n_Iteration(b *testing.B) { func BenchmarkSpec_Marshal_Map3StrInt(b *testing.B) { tests.BenchmarkSpec_Marshal_Map3StrInt(b, _Msg3__Prototype{}) } -func BenchmarkSpec_Marshal_Map3StrInt_CodecNull(b *testing.B) { - tests.BenchmarkSpec_Marshal_Map3StrInt_CodecNull(b, _Msg3__Prototype{}) -} func BenchmarkSpec_Unmarshal_Map3StrInt(b *testing.B) { tests.BenchmarkSpec_Unmarshal_Map3StrInt(b, _Msg3__Prototype{}) } diff --git a/node/gendemo/ipldsch_minima.go b/node/gendemo/ipldsch_minima.go index 4b0dcda6..b5389af1 100644 --- a/node/gendemo/ipldsch_minima.go +++ b/node/gendemo/ipldsch_minima.go @@ -5,7 +5,7 @@ package gendemo import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -36,16 +36,16 @@ type _ErrorThunkAssembler struct { e error } -func (ea _ErrorThunkAssembler) BeginMap(_ int64) (ipld.MapAssembler, error) { return nil, ea.e } -func (ea _ErrorThunkAssembler) BeginList(_ int64) (ipld.ListAssembler, error) { return nil, ea.e } -func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e } -func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignLink(ipld.Link) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignNode(ipld.Node) error { return ea.e } -func (ea _ErrorThunkAssembler) Prototype() ipld.NodePrototype { +func (ea _ErrorThunkAssembler) BeginMap(_ int64) (datamodel.MapAssembler, error) { return nil, ea.e } +func (ea _ErrorThunkAssembler) BeginList(_ int64) (datamodel.ListAssembler, error) { return nil, ea.e } +func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e } +func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignLink(datamodel.Link) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignNode(datamodel.Node) error { return ea.e } +func (ea _ErrorThunkAssembler) Prototype() datamodel.NodePrototype { panic(fmt.Errorf("cannot get prototype from error-carrying assembler: already derailed with error: %w", ea.e)) } diff --git a/node/gendemo/ipldsch_satisfaction.go b/node/gendemo/ipldsch_satisfaction.go index 530abd6a..2867f183 100644 --- a/node/gendemo/ipldsch_satisfaction.go +++ b/node/gendemo/ipldsch_satisfaction.go @@ -3,7 +3,7 @@ package gendemo // Code generated by go-ipld-prime gengo. DO NOT EDIT. import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" "github.com/ipld/go-ipld-prime/schema" ) @@ -31,12 +31,12 @@ func (m MaybeInt) IsAbsent() bool { func (m MaybeInt) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeInt) AsNode() ipld.Node { +func (m MaybeInt) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -50,28 +50,28 @@ func (m MaybeInt) Must() Int { return &m.v } -var _ ipld.Node = (Int)(&_Int{}) +var _ datamodel.Node = (Int)(&_Int{}) var _ schema.TypedNode = (Int)(&_Int{}) -func (Int) Kind() ipld.Kind { - return ipld.Kind_Int +func (Int) Kind() datamodel.Kind { + return datamodel.Kind_Int } -func (Int) LookupByString(string) (ipld.Node, error) { +func (Int) LookupByString(string) (datamodel.Node, error) { return mixins.Int{TypeName: "gendemo.Int"}.LookupByString("") } -func (Int) LookupByNode(ipld.Node) (ipld.Node, error) { +func (Int) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.Int{TypeName: "gendemo.Int"}.LookupByNode(nil) } -func (Int) LookupByIndex(idx int64) (ipld.Node, error) { +func (Int) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Int{TypeName: "gendemo.Int"}.LookupByIndex(0) } -func (Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (Int) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Int{TypeName: "gendemo.Int"}.LookupBySegment(seg) } -func (Int) MapIterator() ipld.MapIterator { +func (Int) MapIterator() datamodel.MapIterator { return nil } -func (Int) ListIterator() ipld.ListIterator { +func (Int) ListIterator() datamodel.ListIterator { return nil } func (Int) Length() int64 { @@ -98,16 +98,16 @@ func (Int) AsString() (string, error) { func (Int) AsBytes() ([]byte, error) { return mixins.Int{TypeName: "gendemo.Int"}.AsBytes() } -func (Int) AsLink() (ipld.Link, error) { +func (Int) AsLink() (datamodel.Link, error) { return mixins.Int{TypeName: "gendemo.Int"}.AsLink() } -func (Int) Prototype() ipld.NodePrototype { +func (Int) Prototype() datamodel.NodePrototype { return _Int__Prototype{} } type _Int__Prototype struct{} -func (_Int__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Int__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Int__Builder nb.Reset() return &nb @@ -117,7 +117,7 @@ type _Int__Builder struct { _Int__Assembler } -func (nb *_Int__Builder) Build() ipld.Node { +func (nb *_Int__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -135,10 +135,10 @@ type _Int__Assembler struct { } func (na *_Int__Assembler) reset() {} -func (_Int__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Int__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.IntAssembler{TypeName: "gendemo.Int"}.BeginMap(0) } -func (_Int__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Int__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.IntAssembler{TypeName: "gendemo.Int"}.BeginList(0) } func (na *_Int__Assembler) AssignNull() error { @@ -174,10 +174,10 @@ func (_Int__Assembler) AssignString(string) error { func (_Int__Assembler) AssignBytes([]byte) error { return mixins.IntAssembler{TypeName: "gendemo.Int"}.AssignBytes(nil) } -func (_Int__Assembler) AssignLink(ipld.Link) error { +func (_Int__Assembler) AssignLink(datamodel.Link) error { return mixins.IntAssembler{TypeName: "gendemo.Int"}.AssignLink(nil) } -func (na *_Int__Assembler) AssignNode(v ipld.Node) error { +func (na *_Int__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -196,19 +196,19 @@ func (na *_Int__Assembler) AssignNode(v ipld.Node) error { return na.AssignInt(v2) } } -func (_Int__Assembler) Prototype() ipld.NodePrototype { +func (_Int__Assembler) Prototype() datamodel.NodePrototype { return _Int__Prototype{} } func (Int) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Int) Representation() ipld.Node { +func (n Int) Representation() datamodel.Node { return (*_Int__Repr)(n) } type _Int__Repr = _Int -var _ ipld.Node = &_Int__Repr{} +var _ datamodel.Node = &_Int__Repr{} type _Int__ReprPrototype = _Int__Prototype type _Int__ReprAssembler = _Int__Assembler @@ -271,12 +271,12 @@ func (m MaybeMap__String__Msg3) IsAbsent() bool { func (m MaybeMap__String__Msg3) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMap__String__Msg3) AsNode() ipld.Node { +func (m MaybeMap__String__Msg3) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -290,42 +290,42 @@ func (m MaybeMap__String__Msg3) Must() Map__String__Msg3 { return &m.v } -var _ ipld.Node = (Map__String__Msg3)(&_Map__String__Msg3{}) +var _ datamodel.Node = (Map__String__Msg3)(&_Map__String__Msg3{}) var _ schema.TypedNode = (Map__String__Msg3)(&_Map__String__Msg3{}) -func (Map__String__Msg3) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map__String__Msg3) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Map__String__Msg3) LookupByString(k string) (ipld.Node, error) { +func (n Map__String__Msg3) LookupByString(k string) (datamodel.Node, error) { var k2 _String if err := (_String__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n Map__String__Msg3) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n Map__String__Msg3) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(String) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"gendemo.Map__String__Msg3", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"gendemo.Map__String__Msg3", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (Map__String__Msg3) LookupByIndex(idx int64) (ipld.Node, error) { +func (Map__String__Msg3) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "gendemo.Map__String__Msg3"}.LookupByIndex(0) } -func (n Map__String__Msg3) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Map__String__Msg3) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Map__String__Msg3) MapIterator() ipld.MapIterator { +func (n Map__String__Msg3) MapIterator() datamodel.MapIterator { return &_Map__String__Msg3__MapItr{n, 0} } @@ -334,9 +334,9 @@ type _Map__String__Msg3__MapItr struct { idx int } -func (itr *_Map__String__Msg3__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Map__String__Msg3__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -348,7 +348,7 @@ func (itr *_Map__String__Msg3__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (Map__String__Msg3) ListIterator() ipld.ListIterator { +func (Map__String__Msg3) ListIterator() datamodel.ListIterator { return nil } func (n Map__String__Msg3) Length() int64 { @@ -375,16 +375,16 @@ func (Map__String__Msg3) AsString() (string, error) { func (Map__String__Msg3) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "gendemo.Map__String__Msg3"}.AsBytes() } -func (Map__String__Msg3) AsLink() (ipld.Link, error) { +func (Map__String__Msg3) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "gendemo.Map__String__Msg3"}.AsLink() } -func (Map__String__Msg3) Prototype() ipld.NodePrototype { +func (Map__String__Msg3) Prototype() datamodel.NodePrototype { return _Map__String__Msg3__Prototype{} } type _Map__String__Msg3__Prototype struct{} -func (_Map__String__Msg3__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Map__String__Msg3__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__String__Msg3__Builder nb.Reset() return &nb @@ -394,7 +394,7 @@ type _Map__String__Msg3__Builder struct { _Map__String__Msg3__Assembler } -func (nb *_Map__String__Msg3__Builder) Build() ipld.Node { +func (nb *_Map__String__Msg3__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -421,7 +421,7 @@ func (na *_Map__String__Msg3__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__String__Msg3__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__String__Msg3__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -436,7 +436,7 @@ func (na *_Map__String__Msg3__Assembler) BeginMap(sizeHint int64) (ipld.MapAssem na.w.t = make([]_Map__String__Msg3__entry, 0, sizeHint) return na, nil } -func (_Map__String__Msg3__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__String__Msg3__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "gendemo.Map__String__Msg3"}.BeginList(0) } func (na *_Map__String__Msg3__Assembler) AssignNull() error { @@ -468,10 +468,10 @@ func (_Map__String__Msg3__Assembler) AssignString(string) error { func (_Map__String__Msg3__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "gendemo.Map__String__Msg3"}.AssignBytes(nil) } -func (_Map__String__Msg3__Assembler) AssignLink(ipld.Link) error { +func (_Map__String__Msg3__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "gendemo.Map__String__Msg3"}.AssignLink(nil) } -func (na *_Map__String__Msg3__Assembler) AssignNode(v ipld.Node) error { +func (na *_Map__String__Msg3__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -486,8 +486,8 @@ func (na *_Map__String__Msg3__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "gendemo.Map__String__Msg3", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "gendemo.Map__String__Msg3", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -504,7 +504,7 @@ func (na *_Map__String__Msg3__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__String__Msg3__Assembler) Prototype() ipld.NodePrototype { +func (_Map__String__Msg3__Assembler) Prototype() datamodel.NodePrototype { return _Map__String__Msg3__Prototype{} } func (ma *_Map__String__Msg3__Assembler) keyFinishTidy() bool { @@ -535,7 +535,7 @@ func (ma *_Map__String__Msg3__Assembler) valueFinishTidy() bool { return false } } -func (ma *_Map__String__Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__String__Msg3__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -556,7 +556,7 @@ func (ma *_Map__String__Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssem return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__String__Msg3__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -567,7 +567,7 @@ func (ma *_Map__String__Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssem ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__String__Msg3__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__String__Msg3__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -588,7 +588,7 @@ func (ma *_Map__String__Msg3__Assembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__String__Msg3__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__String__Msg3__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -625,55 +625,55 @@ func (ma *_Map__String__Msg3__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__String__Msg3__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__String__Msg3__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Map__String__Msg3__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__String__Msg3__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Msg3__Prototype{} } func (Map__String__Msg3) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Map__String__Msg3) Representation() ipld.Node { +func (n Map__String__Msg3) Representation() datamodel.Node { return (*_Map__String__Msg3__Repr)(n) } type _Map__String__Msg3__Repr _Map__String__Msg3 -var _ ipld.Node = &_Map__String__Msg3__Repr{} +var _ datamodel.Node = &_Map__String__Msg3__Repr{} -func (_Map__String__Msg3__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Map__String__Msg3__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_Map__String__Msg3__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_Map__String__Msg3__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (Map__String__Msg3)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Msg3).Representation(), nil } -func (nr *_Map__String__Msg3__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_Map__String__Msg3__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (Map__String__Msg3)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Msg3).Representation(), nil } -func (_Map__String__Msg3__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Map__String__Msg3__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "gendemo.Map__String__Msg3.Repr"}.LookupByIndex(0) } -func (n _Map__String__Msg3__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Map__String__Msg3__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_Map__String__Msg3__Repr) MapIterator() ipld.MapIterator { +func (nr *_Map__String__Msg3__Repr) MapIterator() datamodel.MapIterator { return &_Map__String__Msg3__ReprMapItr{(Map__String__Msg3)(nr), 0} } type _Map__String__Msg3__ReprMapItr _Map__String__Msg3__MapItr -func (itr *_Map__String__Msg3__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_Map__String__Msg3__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_Map__String__Msg3__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(Msg3).Representation(), nil @@ -682,7 +682,7 @@ func (itr *_Map__String__Msg3__ReprMapItr) Done() bool { return (*_Map__String__Msg3__MapItr)(itr).Done() } -func (_Map__String__Msg3__Repr) ListIterator() ipld.ListIterator { +func (_Map__String__Msg3__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Map__String__Msg3__Repr) Length() int64 { @@ -709,16 +709,16 @@ func (_Map__String__Msg3__Repr) AsString() (string, error) { func (_Map__String__Msg3__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "gendemo.Map__String__Msg3.Repr"}.AsBytes() } -func (_Map__String__Msg3__Repr) AsLink() (ipld.Link, error) { +func (_Map__String__Msg3__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "gendemo.Map__String__Msg3.Repr"}.AsLink() } -func (_Map__String__Msg3__Repr) Prototype() ipld.NodePrototype { +func (_Map__String__Msg3__Repr) Prototype() datamodel.NodePrototype { return _Map__String__Msg3__ReprPrototype{} } type _Map__String__Msg3__ReprPrototype struct{} -func (_Map__String__Msg3__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Map__String__Msg3__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__String__Msg3__ReprBuilder nb.Reset() return &nb @@ -728,7 +728,7 @@ type _Map__String__Msg3__ReprBuilder struct { _Map__String__Msg3__ReprAssembler } -func (nb *_Map__String__Msg3__ReprBuilder) Build() ipld.Node { +func (nb *_Map__String__Msg3__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -755,7 +755,7 @@ func (na *_Map__String__Msg3__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__String__Msg3__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__String__Msg3__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -770,7 +770,7 @@ func (na *_Map__String__Msg3__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapA na.w.t = make([]_Map__String__Msg3__entry, 0, sizeHint) return na, nil } -func (_Map__String__Msg3__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__String__Msg3__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "gendemo.Map__String__Msg3.Repr"}.BeginList(0) } func (na *_Map__String__Msg3__ReprAssembler) AssignNull() error { @@ -802,10 +802,10 @@ func (_Map__String__Msg3__ReprAssembler) AssignString(string) error { func (_Map__String__Msg3__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "gendemo.Map__String__Msg3.Repr"}.AssignBytes(nil) } -func (_Map__String__Msg3__ReprAssembler) AssignLink(ipld.Link) error { +func (_Map__String__Msg3__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "gendemo.Map__String__Msg3.Repr"}.AssignLink(nil) } -func (na *_Map__String__Msg3__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Map__String__Msg3__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -820,8 +820,8 @@ func (na *_Map__String__Msg3__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "gendemo.Map__String__Msg3.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "gendemo.Map__String__Msg3.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -838,7 +838,7 @@ func (na *_Map__String__Msg3__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__String__Msg3__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Map__String__Msg3__ReprAssembler) Prototype() datamodel.NodePrototype { return _Map__String__Msg3__ReprPrototype{} } func (ma *_Map__String__Msg3__ReprAssembler) keyFinishTidy() bool { @@ -869,7 +869,7 @@ func (ma *_Map__String__Msg3__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_Map__String__Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__String__Msg3__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -890,7 +890,7 @@ func (ma *_Map__String__Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeA return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__String__Msg3__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -901,7 +901,7 @@ func (ma *_Map__String__Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeA ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__String__Msg3__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__String__Msg3__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -922,7 +922,7 @@ func (ma *_Map__String__Msg3__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__String__Msg3__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__String__Msg3__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -959,10 +959,10 @@ func (ma *_Map__String__Msg3__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__String__Msg3__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__String__Msg3__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__ReprPrototype{} } -func (ma *_Map__String__Msg3__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__String__Msg3__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Msg3__ReprPrototype{} } @@ -991,12 +991,12 @@ func (m MaybeMsg3) IsAbsent() bool { func (m MaybeMsg3) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMsg3) AsNode() ipld.Node { +func (m MaybeMsg3) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -1015,13 +1015,13 @@ var ( fieldName__Msg3_Woot = _String{"woot"} fieldName__Msg3_Waga = _String{"waga"} ) -var _ ipld.Node = (Msg3)(&_Msg3{}) +var _ datamodel.Node = (Msg3)(&_Msg3{}) var _ schema.TypedNode = (Msg3)(&_Msg3{}) -func (Msg3) Kind() ipld.Kind { - return ipld.Kind_Map +func (Msg3) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Msg3) LookupByString(key string) (ipld.Node, error) { +func (n Msg3) LookupByString(key string) (datamodel.Node, error) { switch key { case "whee": return &n.whee, nil @@ -1030,23 +1030,23 @@ func (n Msg3) LookupByString(key string) (ipld.Node, error) { case "waga": return &n.waga, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n Msg3) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n Msg3) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (Msg3) LookupByIndex(idx int64) (ipld.Node, error) { +func (Msg3) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "gendemo.Msg3"}.LookupByIndex(0) } -func (n Msg3) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Msg3) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Msg3) MapIterator() ipld.MapIterator { +func (n Msg3) MapIterator() datamodel.MapIterator { return &_Msg3__MapItr{n, 0} } @@ -1055,9 +1055,9 @@ type _Msg3__MapItr struct { idx int } -func (itr *_Msg3__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Msg3__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -1079,7 +1079,7 @@ func (itr *_Msg3__MapItr) Done() bool { return itr.idx >= 3 } -func (Msg3) ListIterator() ipld.ListIterator { +func (Msg3) ListIterator() datamodel.ListIterator { return nil } func (Msg3) Length() int64 { @@ -1106,16 +1106,16 @@ func (Msg3) AsString() (string, error) { func (Msg3) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "gendemo.Msg3"}.AsBytes() } -func (Msg3) AsLink() (ipld.Link, error) { +func (Msg3) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "gendemo.Msg3"}.AsLink() } -func (Msg3) Prototype() ipld.NodePrototype { +func (Msg3) Prototype() datamodel.NodePrototype { return _Msg3__Prototype{} } type _Msg3__Prototype struct{} -func (_Msg3__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Msg3__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Msg3__Builder nb.Reset() return &nb @@ -1125,7 +1125,7 @@ type _Msg3__Builder struct { _Msg3__Assembler } -func (nb *_Msg3__Builder) Build() ipld.Node { +func (nb *_Msg3__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -1165,7 +1165,7 @@ var ( fieldBits__Msg3_sufficient = 0 + 1<<0 + 1<<1 + 1<<2 ) -func (na *_Msg3__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_Msg3__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -1178,7 +1178,7 @@ func (na *_Msg3__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_Msg3__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Msg3__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "gendemo.Msg3"}.BeginList(0) } func (na *_Msg3__Assembler) AssignNull() error { @@ -1210,10 +1210,10 @@ func (_Msg3__Assembler) AssignString(string) error { func (_Msg3__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "gendemo.Msg3"}.AssignBytes(nil) } -func (_Msg3__Assembler) AssignLink(ipld.Link) error { +func (_Msg3__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "gendemo.Msg3"}.AssignLink(nil) } -func (na *_Msg3__Assembler) AssignNode(v ipld.Node) error { +func (na *_Msg3__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -1233,8 +1233,8 @@ func (na *_Msg3__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "gendemo.Msg3", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "gendemo.Msg3", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -1251,7 +1251,7 @@ func (na *_Msg3__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Msg3__Assembler) Prototype() ipld.NodePrototype { +func (_Msg3__Assembler) Prototype() datamodel.NodePrototype { return _Msg3__Prototype{} } func (ma *_Msg3__Assembler) valueFinishTidy() bool { @@ -1290,7 +1290,7 @@ func (ma *_Msg3__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Msg3__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -1308,7 +1308,7 @@ func (ma *_Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) switch k { case "whee": if ma.s&fieldBit__Msg3_Whee != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee} } ma.s += fieldBit__Msg3_Whee ma.state = maState_midValue @@ -1318,7 +1318,7 @@ func (ma *_Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) return &ma.ca_whee, nil case "woot": if ma.s&fieldBit__Msg3_Woot != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot} } ma.s += fieldBit__Msg3_Woot ma.state = maState_midValue @@ -1328,7 +1328,7 @@ func (ma *_Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) return &ma.ca_woot, nil case "waga": if ma.s&fieldBit__Msg3_Waga != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga} } ma.s += fieldBit__Msg3_Waga ma.state = maState_midValue @@ -1337,9 +1337,9 @@ func (ma *_Msg3__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) ma.ca_waga.m = &ma.cm return &ma.ca_waga, nil } - return nil, ipld.ErrInvalidKey{TypeName: "gendemo.Msg3", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "gendemo.Msg3", Key: &_String{k}} } -func (ma *_Msg3__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Msg3__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -1357,7 +1357,7 @@ func (ma *_Msg3__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_Msg3__KeyAssembler)(ma) } -func (ma *_Msg3__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Msg3__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -1404,7 +1404,7 @@ func (ma *_Msg3__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__Msg3_sufficient != fieldBits__Msg3_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__Msg3_Whee == 0 { err.Missing = append(err.Missing, "whee") } @@ -1420,19 +1420,19 @@ func (ma *_Msg3__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Msg3__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Msg3__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Msg3__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_Msg3__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _Msg3__KeyAssembler _Msg3__Assembler -func (_Msg3__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Msg3__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "gendemo.Msg3.KeyAssembler"}.BeginMap(0) } -func (_Msg3__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Msg3__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "gendemo.Msg3.KeyAssembler"}.BeginList(0) } func (na *_Msg3__KeyAssembler) AssignNull() error { @@ -1454,50 +1454,52 @@ func (ka *_Msg3__KeyAssembler) AssignString(k string) error { switch k { case "whee": if ka.s&fieldBit__Msg3_Whee != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee} } ka.s += fieldBit__Msg3_Whee ka.state = maState_expectValue ka.f = 0 + return nil case "woot": if ka.s&fieldBit__Msg3_Woot != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot} } ka.s += fieldBit__Msg3_Woot ka.state = maState_expectValue ka.f = 1 + return nil case "waga": if ka.s&fieldBit__Msg3_Waga != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga} } ka.s += fieldBit__Msg3_Waga ka.state = maState_expectValue ka.f = 2 + return nil default: - return ipld.ErrInvalidKey{TypeName: "gendemo.Msg3", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "gendemo.Msg3", Key: &_String{k}} } - return nil } func (_Msg3__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "gendemo.Msg3.KeyAssembler"}.AssignBytes(nil) } -func (_Msg3__KeyAssembler) AssignLink(ipld.Link) error { +func (_Msg3__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "gendemo.Msg3.KeyAssembler"}.AssignLink(nil) } -func (ka *_Msg3__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_Msg3__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_Msg3__KeyAssembler) Prototype() ipld.NodePrototype { +func (_Msg3__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (Msg3) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Msg3) Representation() ipld.Node { +func (n Msg3) Representation() datamodel.Node { return (*_Msg3__Repr)(n) } @@ -1508,12 +1510,12 @@ var ( fieldName__Msg3_Woot_serial = _String{"woot"} fieldName__Msg3_Waga_serial = _String{"waga"} ) -var _ ipld.Node = &_Msg3__Repr{} +var _ datamodel.Node = &_Msg3__Repr{} -func (_Msg3__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Msg3__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_Msg3__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_Msg3__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "whee": return n.whee.Representation(), nil @@ -1522,23 +1524,23 @@ func (n *_Msg3__Repr) LookupByString(key string) (ipld.Node, error) { case "waga": return n.waga.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_Msg3__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_Msg3__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_Msg3__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Msg3__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "gendemo.Msg3.Repr"}.LookupByIndex(0) } -func (n _Msg3__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Msg3__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_Msg3__Repr) MapIterator() ipld.MapIterator { +func (n *_Msg3__Repr) MapIterator() datamodel.MapIterator { return &_Msg3__ReprMapItr{n, 0} } @@ -1547,9 +1549,9 @@ type _Msg3__ReprMapItr struct { idx int } -func (itr *_Msg3__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Msg3__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -1570,7 +1572,7 @@ func (itr *_Msg3__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_Msg3__ReprMapItr) Done() bool { return itr.idx >= 3 } -func (_Msg3__Repr) ListIterator() ipld.ListIterator { +func (_Msg3__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Msg3__Repr) Length() int64 { @@ -1598,16 +1600,16 @@ func (_Msg3__Repr) AsString() (string, error) { func (_Msg3__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "gendemo.Msg3.Repr"}.AsBytes() } -func (_Msg3__Repr) AsLink() (ipld.Link, error) { +func (_Msg3__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "gendemo.Msg3.Repr"}.AsLink() } -func (_Msg3__Repr) Prototype() ipld.NodePrototype { +func (_Msg3__Repr) Prototype() datamodel.NodePrototype { return _Msg3__ReprPrototype{} } type _Msg3__ReprPrototype struct{} -func (_Msg3__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Msg3__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Msg3__ReprBuilder nb.Reset() return &nb @@ -1617,7 +1619,7 @@ type _Msg3__ReprBuilder struct { _Msg3__ReprAssembler } -func (nb *_Msg3__ReprBuilder) Build() ipld.Node { +func (nb *_Msg3__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -1649,7 +1651,7 @@ func (na *_Msg3__ReprAssembler) reset() { na.ca_woot.reset() na.ca_waga.reset() } -func (na *_Msg3__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_Msg3__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -1662,7 +1664,7 @@ func (na *_Msg3__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_Msg3__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Msg3__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "gendemo.Msg3.Repr"}.BeginList(0) } func (na *_Msg3__ReprAssembler) AssignNull() error { @@ -1694,10 +1696,10 @@ func (_Msg3__ReprAssembler) AssignString(string) error { func (_Msg3__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "gendemo.Msg3.Repr"}.AssignBytes(nil) } -func (_Msg3__ReprAssembler) AssignLink(ipld.Link) error { +func (_Msg3__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "gendemo.Msg3.Repr"}.AssignLink(nil) } -func (na *_Msg3__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Msg3__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -1717,8 +1719,8 @@ func (na *_Msg3__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "gendemo.Msg3.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "gendemo.Msg3.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -1735,7 +1737,7 @@ func (na *_Msg3__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Msg3__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Msg3__ReprAssembler) Prototype() datamodel.NodePrototype { return _Msg3__ReprPrototype{} } func (ma *_Msg3__ReprAssembler) valueFinishTidy() bool { @@ -1771,7 +1773,7 @@ func (ma *_Msg3__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Msg3__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -1789,7 +1791,7 @@ func (ma *_Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, err switch k { case "whee": if ma.s&fieldBit__Msg3_Whee != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee_serial} } ma.s += fieldBit__Msg3_Whee ma.state = maState_midValue @@ -1799,7 +1801,7 @@ func (ma *_Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, err return &ma.ca_whee, nil case "woot": if ma.s&fieldBit__Msg3_Woot != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot_serial} } ma.s += fieldBit__Msg3_Woot ma.state = maState_midValue @@ -1809,7 +1811,7 @@ func (ma *_Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, err return &ma.ca_woot, nil case "waga": if ma.s&fieldBit__Msg3_Waga != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga_serial} } ma.s += fieldBit__Msg3_Waga ma.state = maState_midValue @@ -1819,9 +1821,9 @@ func (ma *_Msg3__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, err return &ma.ca_waga, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "gendemo.Msg3.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "gendemo.Msg3.Repr", Key: &_String{k}} } -func (ma *_Msg3__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Msg3__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -1839,7 +1841,7 @@ func (ma *_Msg3__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_Msg3__ReprKeyAssembler)(ma) } -func (ma *_Msg3__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Msg3__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -1886,7 +1888,7 @@ func (ma *_Msg3__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__Msg3_sufficient != fieldBits__Msg3_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__Msg3_Whee == 0 { err.Missing = append(err.Missing, "whee") } @@ -1902,19 +1904,19 @@ func (ma *_Msg3__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Msg3__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Msg3__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Msg3__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_Msg3__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _Msg3__ReprKeyAssembler _Msg3__ReprAssembler -func (_Msg3__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Msg3__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "gendemo.Msg3.Repr.KeyAssembler"}.BeginMap(0) } -func (_Msg3__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Msg3__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "gendemo.Msg3.Repr.KeyAssembler"}.BeginList(0) } func (na *_Msg3__ReprKeyAssembler) AssignNull() error { @@ -1936,7 +1938,7 @@ func (ka *_Msg3__ReprKeyAssembler) AssignString(k string) error { switch k { case "whee": if ka.s&fieldBit__Msg3_Whee != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Whee_serial} } ka.s += fieldBit__Msg3_Whee ka.state = maState_expectValue @@ -1944,7 +1946,7 @@ func (ka *_Msg3__ReprKeyAssembler) AssignString(k string) error { return nil case "woot": if ka.s&fieldBit__Msg3_Woot != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Woot_serial} } ka.s += fieldBit__Msg3_Woot ka.state = maState_expectValue @@ -1952,29 +1954,29 @@ func (ka *_Msg3__ReprKeyAssembler) AssignString(k string) error { return nil case "waga": if ka.s&fieldBit__Msg3_Waga != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Msg3_Waga_serial} } ka.s += fieldBit__Msg3_Waga ka.state = maState_expectValue ka.f = 2 return nil } - return ipld.ErrInvalidKey{TypeName: "gendemo.Msg3.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "gendemo.Msg3.Repr", Key: &_String{k}} } func (_Msg3__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "gendemo.Msg3.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_Msg3__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_Msg3__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "gendemo.Msg3.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_Msg3__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_Msg3__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_Msg3__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_Msg3__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -2005,12 +2007,12 @@ func (m MaybeString) IsAbsent() bool { func (m MaybeString) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeString) AsNode() ipld.Node { +func (m MaybeString) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -2024,28 +2026,28 @@ func (m MaybeString) Must() String { return &m.v } -var _ ipld.Node = (String)(&_String{}) +var _ datamodel.Node = (String)(&_String{}) var _ schema.TypedNode = (String)(&_String{}) -func (String) Kind() ipld.Kind { - return ipld.Kind_String +func (String) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (String) LookupByString(string) (ipld.Node, error) { +func (String) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "gendemo.String"}.LookupByString("") } -func (String) LookupByNode(ipld.Node) (ipld.Node, error) { +func (String) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "gendemo.String"}.LookupByNode(nil) } -func (String) LookupByIndex(idx int64) (ipld.Node, error) { +func (String) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "gendemo.String"}.LookupByIndex(0) } -func (String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (String) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "gendemo.String"}.LookupBySegment(seg) } -func (String) MapIterator() ipld.MapIterator { +func (String) MapIterator() datamodel.MapIterator { return nil } -func (String) ListIterator() ipld.ListIterator { +func (String) ListIterator() datamodel.ListIterator { return nil } func (String) Length() int64 { @@ -2072,16 +2074,16 @@ func (n String) AsString() (string, error) { func (String) AsBytes() ([]byte, error) { return mixins.String{TypeName: "gendemo.String"}.AsBytes() } -func (String) AsLink() (ipld.Link, error) { +func (String) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "gendemo.String"}.AsLink() } -func (String) Prototype() ipld.NodePrototype { +func (String) Prototype() datamodel.NodePrototype { return _String__Prototype{} } type _String__Prototype struct{} -func (_String__Prototype) NewBuilder() ipld.NodeBuilder { +func (_String__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _String__Builder nb.Reset() return &nb @@ -2091,7 +2093,7 @@ type _String__Builder struct { _String__Assembler } -func (nb *_String__Builder) Build() ipld.Node { +func (nb *_String__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -2109,10 +2111,10 @@ type _String__Assembler struct { } func (na *_String__Assembler) reset() {} -func (_String__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_String__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "gendemo.String"}.BeginMap(0) } -func (_String__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_String__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "gendemo.String"}.BeginList(0) } func (na *_String__Assembler) AssignNull() error { @@ -2148,10 +2150,10 @@ func (na *_String__Assembler) AssignString(v string) error { func (_String__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "gendemo.String"}.AssignBytes(nil) } -func (_String__Assembler) AssignLink(ipld.Link) error { +func (_String__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "gendemo.String"}.AssignLink(nil) } -func (na *_String__Assembler) AssignNode(v ipld.Node) error { +func (na *_String__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -2170,19 +2172,19 @@ func (na *_String__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_String__Assembler) Prototype() ipld.NodePrototype { +func (_String__Assembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (String) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n String) Representation() ipld.Node { +func (n String) Representation() datamodel.Node { return (*_String__Repr)(n) } type _String__Repr = _String -var _ ipld.Node = &_String__Repr{} +var _ datamodel.Node = &_String__Repr{} type _String__ReprPrototype = _String__Prototype type _String__ReprAssembler = _String__Assembler diff --git a/node/gendemo/ipldsch_types.go b/node/gendemo/ipldsch_types.go index 7a6f3aeb..b271b881 100644 --- a/node/gendemo/ipldsch_types.go +++ b/node/gendemo/ipldsch_types.go @@ -3,10 +3,10 @@ package gendemo // Code generated by go-ipld-prime gengo. DO NOT EDIT. import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) -var _ ipld.Node = nil // suppress errors when this dependency is not referenced +var _ datamodel.Node = nil // suppress errors when this dependency is not referenced // Type is a struct embeding a NodePrototype/Type for every Node implementation in this package. // One of its major uses is to start the construction of a value. // You can use it like this: diff --git a/node/mixins/bool.go b/node/mixins/bool.go index decfa23c..90f0f370 100644 --- a/node/mixins/bool.go +++ b/node/mixins/bool.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Bool can be embedded in a struct to provide all the methods that @@ -19,25 +19,25 @@ type Bool struct { TypeName string } -func (Bool) Kind() ipld.Kind { - return ipld.Kind_Bool +func (Bool) Kind() datamodel.Kind { + return datamodel.Kind_Bool } -func (x Bool) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Bool} +func (x Bool) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Bool} } -func (x Bool) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Bool} +func (x Bool) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Bool} } -func (x Bool) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Bool} +func (x Bool) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Bool} } -func (x Bool) LookupBySegment(ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_Bool} +func (x Bool) LookupBySegment(datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: datamodel.Kind_Bool} } -func (Bool) MapIterator() ipld.MapIterator { +func (Bool) MapIterator() datamodel.MapIterator { return nil } -func (Bool) ListIterator() ipld.ListIterator { +func (Bool) ListIterator() datamodel.ListIterator { return nil } func (Bool) Length() int64 { @@ -50,19 +50,19 @@ func (Bool) IsNull() bool { return false } func (x Bool) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Bool} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Bool} } func (x Bool) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Bool} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Bool} } func (x Bool) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Bool} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Bool} } func (x Bool) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Bool} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Bool} } -func (x Bool) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Bool} +func (x Bool) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Bool} } // BoolAssembler has similar purpose as Bool, but for (you guessed it) @@ -71,27 +71,27 @@ type BoolAssembler struct { TypeName string } -func (x BoolAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Bool} +func (x BoolAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Bool} } -func (x BoolAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Bool} +func (x BoolAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Bool} } func (x BoolAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_Bool} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_Bool} } func (x BoolAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Bool} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Bool} } func (x BoolAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Bool} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Bool} } func (x BoolAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Bool} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Bool} } func (x BoolAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Bool} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Bool} } -func (x BoolAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Bool} +func (x BoolAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Bool} } diff --git a/node/mixins/bytes.go b/node/mixins/bytes.go index 05a4e3bf..56a828aa 100644 --- a/node/mixins/bytes.go +++ b/node/mixins/bytes.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Bytes can be embedded in a struct to provide all the methods that @@ -19,25 +19,25 @@ type Bytes struct { TypeName string } -func (Bytes) Kind() ipld.Kind { - return ipld.Kind_Bytes +func (Bytes) Kind() datamodel.Kind { + return datamodel.Kind_Bytes } -func (x Bytes) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Bytes} +func (x Bytes) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Bytes} } -func (x Bytes) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Bytes} +func (x Bytes) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Bytes} } -func (x Bytes) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Bytes} +func (x Bytes) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Bytes} } -func (x Bytes) LookupBySegment(ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_Bytes} +func (x Bytes) LookupBySegment(datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: datamodel.Kind_Bytes} } -func (Bytes) MapIterator() ipld.MapIterator { +func (Bytes) MapIterator() datamodel.MapIterator { return nil } -func (Bytes) ListIterator() ipld.ListIterator { +func (Bytes) ListIterator() datamodel.ListIterator { return nil } func (Bytes) Length() int64 { @@ -50,19 +50,19 @@ func (Bytes) IsNull() bool { return false } func (x Bytes) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Bytes} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Bytes} } func (x Bytes) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Bytes} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Bytes} } func (x Bytes) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Bytes} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Bytes} } func (x Bytes) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Bytes} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Bytes} } -func (x Bytes) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Bytes} +func (x Bytes) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Bytes} } // BytesAssembler has similar purpose as Bytes, but for (you guessed it) @@ -71,27 +71,27 @@ type BytesAssembler struct { TypeName string } -func (x BytesAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Bytes} +func (x BytesAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Bytes} } -func (x BytesAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Bytes} +func (x BytesAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Bytes} } func (x BytesAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_Bytes} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_Bytes} } func (x BytesAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Bytes} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Bytes} } func (x BytesAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Bytes} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Bytes} } func (x BytesAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Bytes} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Bytes} } func (x BytesAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Bytes} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Bytes} } -func (x BytesAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Bytes} +func (x BytesAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Bytes} } diff --git a/node/mixins/float.go b/node/mixins/float.go index c42d6678..dba1bf00 100644 --- a/node/mixins/float.go +++ b/node/mixins/float.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Float can be embedded in a struct to provide all the methods that @@ -19,25 +19,25 @@ type Float struct { TypeName string } -func (Float) Kind() ipld.Kind { - return ipld.Kind_Float +func (Float) Kind() datamodel.Kind { + return datamodel.Kind_Float } -func (x Float) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Float} +func (x Float) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Float} } -func (x Float) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Float} +func (x Float) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Float} } -func (x Float) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Float} +func (x Float) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Float} } -func (x Float) LookupBySegment(ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_Float} +func (x Float) LookupBySegment(datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: datamodel.Kind_Float} } -func (Float) MapIterator() ipld.MapIterator { +func (Float) MapIterator() datamodel.MapIterator { return nil } -func (Float) ListIterator() ipld.ListIterator { +func (Float) ListIterator() datamodel.ListIterator { return nil } func (Float) Length() int64 { @@ -50,19 +50,19 @@ func (Float) IsNull() bool { return false } func (x Float) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Float} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Float} } func (x Float) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Float} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Float} } func (x Float) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Float} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Float} } func (x Float) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Float} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Float} } -func (x Float) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Float} +func (x Float) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Float} } // FloatAssembler has similar purpose as Float, but for (you guessed it) @@ -71,27 +71,27 @@ type FloatAssembler struct { TypeName string } -func (x FloatAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Float} +func (x FloatAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Float} } -func (x FloatAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Float} +func (x FloatAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Float} } func (x FloatAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_Float} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_Float} } func (x FloatAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Float} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Float} } func (x FloatAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Float} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Float} } func (x FloatAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Float} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Float} } func (x FloatAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Float} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Float} } -func (x FloatAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Float} +func (x FloatAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Float} } diff --git a/node/mixins/int.go b/node/mixins/int.go index 724b8150..062bc21c 100644 --- a/node/mixins/int.go +++ b/node/mixins/int.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Int can be embedded in a struct to provide all the methods that @@ -19,25 +19,25 @@ type Int struct { TypeName string } -func (Int) Kind() ipld.Kind { - return ipld.Kind_Int +func (Int) Kind() datamodel.Kind { + return datamodel.Kind_Int } -func (x Int) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Int} +func (x Int) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Int} } -func (x Int) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Int} +func (x Int) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Int} } -func (x Int) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Int} +func (x Int) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Int} } -func (x Int) LookupBySegment(ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_Int} +func (x Int) LookupBySegment(datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: datamodel.Kind_Int} } -func (Int) MapIterator() ipld.MapIterator { +func (Int) MapIterator() datamodel.MapIterator { return nil } -func (Int) ListIterator() ipld.ListIterator { +func (Int) ListIterator() datamodel.ListIterator { return nil } func (Int) Length() int64 { @@ -50,19 +50,19 @@ func (Int) IsNull() bool { return false } func (x Int) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Int} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Int} } func (x Int) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Int} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Int} } func (x Int) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Int} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Int} } func (x Int) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Int} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Int} } -func (x Int) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Int} +func (x Int) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Int} } // IntAssembler has similar purpose as Int, but for (you guessed it) @@ -71,27 +71,27 @@ type IntAssembler struct { TypeName string } -func (x IntAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Int} +func (x IntAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Int} } -func (x IntAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Int} +func (x IntAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Int} } func (x IntAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_Int} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_Int} } func (x IntAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Int} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Int} } func (x IntAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Int} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Int} } func (x IntAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Int} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Int} } func (x IntAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Int} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Int} } -func (x IntAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Int} +func (x IntAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Int} } diff --git a/node/mixins/link.go b/node/mixins/link.go index a13836ae..9fb1dff9 100644 --- a/node/mixins/link.go +++ b/node/mixins/link.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Link can be embedded in a struct to provide all the methods that @@ -19,25 +19,25 @@ type Link struct { TypeName string } -func (Link) Kind() ipld.Kind { - return ipld.Kind_Link +func (Link) Kind() datamodel.Kind { + return datamodel.Kind_Link } -func (x Link) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Link} +func (x Link) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Link} } -func (x Link) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Link} +func (x Link) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Link} } -func (x Link) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Link} +func (x Link) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Link} } -func (x Link) LookupBySegment(ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_Link} +func (x Link) LookupBySegment(datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: datamodel.Kind_Link} } -func (Link) MapIterator() ipld.MapIterator { +func (Link) MapIterator() datamodel.MapIterator { return nil } -func (Link) ListIterator() ipld.ListIterator { +func (Link) ListIterator() datamodel.ListIterator { return nil } func (Link) Length() int64 { @@ -50,19 +50,19 @@ func (Link) IsNull() bool { return false } func (x Link) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Link} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Link} } func (x Link) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Link} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Link} } func (x Link) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Link} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Link} } func (x Link) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Link} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Link} } func (x Link) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Link} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Link} } // LinkAssembler has similar purpose as Link, but for (you guessed it) @@ -71,27 +71,27 @@ type LinkAssembler struct { TypeName string } -func (x LinkAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_Link} +func (x LinkAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_Link} } -func (x LinkAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Link} +func (x LinkAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Link} } func (x LinkAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_Link} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_Link} } func (x LinkAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Link} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Link} } func (x LinkAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Link} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Link} } func (x LinkAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Link} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Link} } func (x LinkAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Link} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Link} } func (x LinkAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Link} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Link} } diff --git a/node/mixins/list.go b/node/mixins/list.go index 250830dd..d48f2a29 100644 --- a/node/mixins/list.go +++ b/node/mixins/list.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // List can be embedded in a struct to provide all the methods that @@ -19,16 +19,16 @@ type List struct { TypeName string } -func (List) Kind() ipld.Kind { - return ipld.Kind_List +func (List) Kind() datamodel.Kind { + return datamodel.Kind_List } -func (x List) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_List} +func (x List) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_List} } -func (x List) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_List} +func (x List) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_List} } -func (List) MapIterator() ipld.MapIterator { +func (List) MapIterator() datamodel.MapIterator { return nil } func (List) IsAbsent() bool { @@ -38,22 +38,22 @@ func (List) IsNull() bool { return false } func (x List) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_List} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_List} } func (x List) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_List} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_List} } func (x List) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_List} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_List} } func (x List) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_List} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_List} } func (x List) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_List} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_List} } -func (x List) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_List} +func (x List) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_List} } // ListAssembler has similar purpose as List, but for (you guessed it) @@ -62,27 +62,27 @@ type ListAssembler struct { TypeName string } -func (x ListAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_List} +func (x ListAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_List} } func (x ListAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_List} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_List} } func (x ListAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_List} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_List} } func (x ListAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_List} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_List} } func (x ListAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_List} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_List} } func (x ListAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_List} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_List} } func (x ListAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_List} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_List} } -func (x ListAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_List} +func (x ListAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_List} } diff --git a/node/mixins/map.go b/node/mixins/map.go index b9958768..d5f7c2c4 100644 --- a/node/mixins/map.go +++ b/node/mixins/map.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Map can be embedded in a struct to provide all the methods that @@ -19,13 +19,13 @@ type Map struct { TypeName string } -func (Map) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (x Map) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Map} +func (x Map) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Map} } -func (Map) ListIterator() ipld.ListIterator { +func (Map) ListIterator() datamodel.ListIterator { return nil } func (Map) IsAbsent() bool { @@ -35,22 +35,22 @@ func (Map) IsNull() bool { return false } func (x Map) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Map} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Map} } func (x Map) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Map} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Map} } func (x Map) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Map} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Map} } func (x Map) AsString() (string, error) { - return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Map} + return "", datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Map} } func (x Map) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Map} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Map} } -func (x Map) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Map} +func (x Map) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Map} } // MapAssembler has similar purpose as Map, but for (you guessed it) @@ -59,27 +59,27 @@ type MapAssembler struct { TypeName string } -func (x MapAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_Map} +func (x MapAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_Map} } func (x MapAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_Map} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_Map} } func (x MapAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_Map} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_Map} } func (x MapAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_Map} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_Map} } func (x MapAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_Map} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_Map} } func (x MapAssembler) AssignString(string) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_Map} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: datamodel.Kind_Map} } func (x MapAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_Map} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_Map} } -func (x MapAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_Map} +func (x MapAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_Map} } diff --git a/node/mixins/string.go b/node/mixins/string.go index a8d9e8fd..8149818f 100644 --- a/node/mixins/string.go +++ b/node/mixins/string.go @@ -1,7 +1,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // String can be embedded in a struct to provide all the methods that @@ -19,25 +19,25 @@ type String struct { TypeName string } -func (String) Kind() ipld.Kind { - return ipld.Kind_String +func (String) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (x String) LookupByString(string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_String} +func (x String) LookupByString(string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_String} } -func (x String) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_String} +func (x String) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_String} } -func (x String) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_String} +func (x String) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_String} } -func (x String) LookupBySegment(ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_String} +func (x String) LookupBySegment(datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: datamodel.Kind_String} } -func (String) MapIterator() ipld.MapIterator { +func (String) MapIterator() datamodel.MapIterator { return nil } -func (String) ListIterator() ipld.ListIterator { +func (String) ListIterator() datamodel.ListIterator { return nil } func (String) Length() int64 { @@ -50,19 +50,19 @@ func (String) IsNull() bool { return false } func (x String) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_String} + return false, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_String} } func (x String) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_String} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_String} } func (x String) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_String} + return 0, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_String} } func (x String) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_String} + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_String} } -func (x String) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_String} +func (x String) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_String} } // StringAssembler has similar purpose as String, but for (you guessed it) @@ -71,27 +71,27 @@ type StringAssembler struct { TypeName string } -func (x StringAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_String} +func (x StringAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: datamodel.Kind_String} } -func (x StringAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { - return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_String} +func (x StringAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { + return nil, datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: datamodel.KindSet_JustList, ActualKind: datamodel.Kind_String} } func (x StringAssembler) AssignNull() error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_String} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: datamodel.KindSet_JustNull, ActualKind: datamodel.Kind_String} } func (x StringAssembler) AssignBool(bool) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_String} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: datamodel.Kind_String} } func (x StringAssembler) AssignInt(int64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_String} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: datamodel.Kind_String} } func (x StringAssembler) AssignFloat(float64) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_String} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: datamodel.Kind_String} } func (x StringAssembler) AssignBytes([]byte) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_String} + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: datamodel.Kind_String} } -func (x StringAssembler) AssignLink(ipld.Link) error { - return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_String} +func (x StringAssembler) AssignLink(datamodel.Link) error { + return datamodel.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: datamodel.Kind_String} } diff --git a/node/mixins/tmplMixin.txt b/node/mixins/tmplMixin.txt index 18c78a8e..d74a2542 100644 --- a/node/mixins/tmplMixin.txt +++ b/node/mixins/tmplMixin.txt @@ -5,7 +5,7 @@ package mixins import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // @Kind@ can be embedded in a struct to provide all the methods that diff --git a/node/tests/listSpecs.go b/node/tests/listSpecs.go index f3a11b6c..de6e57ec 100644 --- a/node/tests/listSpecs.go +++ b/node/tests/listSpecs.go @@ -5,12 +5,12 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" ) -func SpecTestListString(t *testing.T, np ipld.NodePrototype) { +func SpecTestListString(t *testing.T, np datamodel.NodePrototype) { t.Run("list, 3 entries", func(t *testing.T) { n := fluent.MustBuildList(np, 3, func(la fluent.ListAssembler) { la.AssembleValue().AssignString("one") @@ -55,7 +55,7 @@ func SpecTestListString(t *testing.T, np ipld.NodePrototype) { Wish(t, itr.Done(), ShouldEqual, true) idx, v, err = itr.Next() - Wish(t, err, ShouldEqual, ipld.ErrIteratorOverread{}) + Wish(t, err, ShouldEqual, datamodel.ErrIteratorOverread{}) Wish(t, idx, ShouldEqual, int64(-1)) Wish(t, v, ShouldEqual, nil) }) diff --git a/node/tests/mapBenchmarks.go b/node/tests/mapBenchmarks.go index 165f8294..32710cad 100644 --- a/node/tests/mapBenchmarks.go +++ b/node/tests/mapBenchmarks.go @@ -3,17 +3,17 @@ package tests import ( "testing" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/must" ) -func SpecBenchmarkMapStrInt_3n_AssembleStandard(b *testing.B, np ipld.NodePrototype) { +func SpecBenchmarkMapStrInt_3n_AssembleStandard(b *testing.B, np datamodel.NodePrototype) { for i := 0; i < b.N; i++ { sink = buildMapStrIntN3(np) } } -func SpecBenchmarkMapStrInt_3n_AssembleEntry(b *testing.B, np ipld.NodePrototype) { +func SpecBenchmarkMapStrInt_3n_AssembleEntry(b *testing.B, np datamodel.NodePrototype) { for i := 0; i < b.N; i++ { nb := np.NewBuilder() ma, err := nb.BeginMap(3) @@ -40,7 +40,7 @@ func SpecBenchmarkMapStrInt_3n_AssembleEntry(b *testing.B, np ipld.NodePrototype } } -func SpecBenchmarkMapStrInt_3n_Iteration(b *testing.B, np ipld.NodePrototype) { +func SpecBenchmarkMapStrInt_3n_Iteration(b *testing.B, np datamodel.NodePrototype) { n := buildMapStrIntN3(np) b.ResetTimer() for i := 0; i < b.N; i++ { @@ -54,13 +54,13 @@ func SpecBenchmarkMapStrInt_3n_Iteration(b *testing.B, np ipld.NodePrototype) { // n25 --> -func SpecBenchmarkMapStrInt_25n_AssembleStandard(b *testing.B, np ipld.NodePrototype) { +func SpecBenchmarkMapStrInt_25n_AssembleStandard(b *testing.B, np datamodel.NodePrototype) { for i := 0; i < b.N; i++ { sink = buildMapStrIntN25(np) } } -func SpecBenchmarkMapStrInt_25n_AssembleEntry(b *testing.B, np ipld.NodePrototype) { +func SpecBenchmarkMapStrInt_25n_AssembleEntry(b *testing.B, np datamodel.NodePrototype) { for i := 0; i < b.N; i++ { nb := np.NewBuilder() ma, err := nb.BeginMap(25) @@ -79,7 +79,7 @@ func SpecBenchmarkMapStrInt_25n_AssembleEntry(b *testing.B, np ipld.NodePrototyp } } -func SpecBenchmarkMapStrInt_25n_Iteration(b *testing.B, np ipld.NodePrototype) { +func SpecBenchmarkMapStrInt_25n_Iteration(b *testing.B, np datamodel.NodePrototype) { n := buildMapStrIntN25(np) b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/node/tests/mapFixtures.go b/node/tests/mapFixtures.go index 1787a415..bd5979a5 100644 --- a/node/tests/mapFixtures.go +++ b/node/tests/mapFixtures.go @@ -3,7 +3,7 @@ package tests import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/must" ) @@ -22,7 +22,7 @@ func init() { } // extracted for reuse between correctness tests and benchmarks -func buildMapStrIntN3(np ipld.NodePrototype) ipld.Node { +func buildMapStrIntN3(np datamodel.NodePrototype) datamodel.Node { nb := np.NewBuilder() ma, err := nb.BeginMap(3) must.NotError(err) @@ -37,7 +37,7 @@ func buildMapStrIntN3(np ipld.NodePrototype) ipld.Node { } // extracted for reuse across benchmarks -func buildMapStrIntN25(np ipld.NodePrototype) ipld.Node { +func buildMapStrIntN25(np datamodel.NodePrototype) datamodel.Node { nb := np.NewBuilder() ma, err := nb.BeginMap(25) must.NotError(err) diff --git a/node/tests/mapSpecs.go b/node/tests/mapSpecs.go index 17c79f30..55dbf2d8 100644 --- a/node/tests/mapSpecs.go +++ b/node/tests/mapSpecs.go @@ -5,11 +5,11 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/must" ) -func SpecTestMapStrInt(t *testing.T, np ipld.NodePrototype) { +func SpecTestMapStrInt(t *testing.T, np datamodel.NodePrototype) { t.Run("map, 3 entries", func(t *testing.T) { n := buildMapStrIntN3(np) t.Run("reads back out", func(t *testing.T) { @@ -68,13 +68,13 @@ func SpecTestMapStrInt(t *testing.T, np ipld.NodePrototype) { Wish(t, itr.Done(), ShouldEqual, true) k, v, err = itr.Next() - Wish(t, err, ShouldEqual, ipld.ErrIteratorOverread{}) + Wish(t, err, ShouldEqual, datamodel.ErrIteratorOverread{}) Wish(t, k, ShouldEqual, nil) Wish(t, v, ShouldEqual, nil) }) t.Run("reads for absent keys error sensibly", func(t *testing.T) { v, err := n.LookupByString("nope") - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) Wish(t, err.Error(), ShouldEqual, `key not found: "nope"`) Wish(t, v, ShouldEqual, nil) }) @@ -92,7 +92,7 @@ func SpecTestMapStrInt(t *testing.T, np ipld.NodePrototype) { panic(err) } if err := ma.AssembleKey().AssignString("whee"); err != nil { - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrRepeatedMapKey{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrRepeatedMapKey{}) // No string assertion at present -- how that should be presented for typed stuff is unsettled // (and if it's clever, it'll differ from untyped, which will mean no assertion possible!). } @@ -136,13 +136,13 @@ func SpecTestMapStrInt(t *testing.T, np ipld.NodePrototype) { }) } -func SpecTestMapStrMapStrInt(t *testing.T, np ipld.NodePrototype) { +func SpecTestMapStrMapStrInt(t *testing.T, np datamodel.NodePrototype) { t.Run("map>", func(t *testing.T) { nb := np.NewBuilder() ma, err := nb.BeginMap(3) must.NotError(err) must.NotError(ma.AssembleKey().AssignString("whee")) - func(ma ipld.MapAssembler, err error) { + func(ma datamodel.MapAssembler, err error) { must.NotError(ma.AssembleKey().AssignString("m1k1")) must.NotError(ma.AssembleValue().AssignInt(1)) must.NotError(ma.AssembleKey().AssignString("m1k2")) @@ -150,7 +150,7 @@ func SpecTestMapStrMapStrInt(t *testing.T, np ipld.NodePrototype) { must.NotError(ma.Finish()) }(ma.AssembleValue().BeginMap(2)) must.NotError(ma.AssembleKey().AssignString("woot")) - func(ma ipld.MapAssembler, err error) { + func(ma datamodel.MapAssembler, err error) { must.NotError(ma.AssembleKey().AssignString("m2k1")) must.NotError(ma.AssembleValue().AssignInt(3)) must.NotError(ma.AssembleKey().AssignString("m2k2")) @@ -158,7 +158,7 @@ func SpecTestMapStrMapStrInt(t *testing.T, np ipld.NodePrototype) { must.NotError(ma.Finish()) }(ma.AssembleValue().BeginMap(2)) must.NotError(ma.AssembleKey().AssignString("waga")) - func(ma ipld.MapAssembler, err error) { + func(ma datamodel.MapAssembler, err error) { must.NotError(ma.AssembleKey().AssignString("m3k1")) must.NotError(ma.AssembleValue().AssignInt(5)) must.NotError(ma.AssembleKey().AssignString("m3k2")) @@ -187,26 +187,26 @@ func SpecTestMapStrMapStrInt(t *testing.T, np ipld.NodePrototype) { }) } -func SpecTestMapStrListStr(t *testing.T, np ipld.NodePrototype) { +func SpecTestMapStrListStr(t *testing.T, np datamodel.NodePrototype) { t.Run("map>", func(t *testing.T) { nb := np.NewBuilder() ma, err := nb.BeginMap(3) must.NotError(err) must.NotError(ma.AssembleKey().AssignString("asdf")) - func(la ipld.ListAssembler, err error) { + func(la datamodel.ListAssembler, err error) { must.NotError(la.AssembleValue().AssignString("eleven")) must.NotError(la.AssembleValue().AssignString("twelve")) must.NotError(la.AssembleValue().AssignString("thirteen")) must.NotError(la.Finish()) }(ma.AssembleValue().BeginList(3)) must.NotError(ma.AssembleKey().AssignString("qwer")) - func(la ipld.ListAssembler, err error) { + func(la datamodel.ListAssembler, err error) { must.NotError(la.AssembleValue().AssignString("twentyone")) must.NotError(la.AssembleValue().AssignString("twentytwo")) must.NotError(la.Finish()) }(ma.AssembleValue().BeginList(2)) must.NotError(ma.AssembleKey().AssignString("zxcv")) - func(la ipld.ListAssembler, err error) { + func(la datamodel.ListAssembler, err error) { must.NotError(la.AssembleValue().AssignString("thirtyone")) must.NotError(la.Finish()) }(ma.AssembleValue().BeginList(1)) diff --git a/node/tests/marshalBenchmarks.go b/node/tests/marshalBenchmarks.go index 3b472d90..5478a24c 100644 --- a/node/tests/marshalBenchmarks.go +++ b/node/tests/marshalBenchmarks.go @@ -6,11 +6,8 @@ import ( "strings" "testing" - refmtjson "github.com/polydawn/refmt/json" - "github.com/polydawn/refmt/tok" - - ipld "github.com/ipld/go-ipld-prime" - "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/codec/json" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/must" "github.com/ipld/go-ipld-prime/node/tests/corpus" ) @@ -24,15 +21,15 @@ import ( // - we can make direct comparisons to the standard library json marshalling // and unmarshalling, thus having a back-of-the-envelope baseline to compare. -func BenchmarkSpec_Marshal_Map3StrInt(b *testing.B, np ipld.NodePrototype) { +func BenchmarkSpec_Marshal_Map3StrInt(b *testing.B, np datamodel.NodePrototype) { nb := np.NewBuilder() - must.NotError(codec.Unmarshal(nb, refmtjson.NewDecoder(strings.NewReader(`{"whee":1,"woot":2,"waga":3}`)))) + must.NotError(json.Decode(nb, strings.NewReader(`{"whee":1,"woot":2,"waga":3}`))) n := nb.Build() b.ResetTimer() var err error for i := 0; i < b.N; i++ { var buf bytes.Buffer - err = codec.Marshal(n, refmtjson.NewEncoder(&buf, refmtjson.EncodeOptions{})) + err = json.Encode(n, &buf) sink = buf } if err != nil { @@ -40,30 +37,7 @@ func BenchmarkSpec_Marshal_Map3StrInt(b *testing.B, np ipld.NodePrototype) { } } -func BenchmarkSpec_Marshal_Map3StrInt_CodecNull(b *testing.B, np ipld.NodePrototype) { - nb := np.NewBuilder() - must.NotError(codec.Unmarshal(nb, refmtjson.NewDecoder(strings.NewReader(`{"whee":1,"woot":2,"waga":3}`)))) - n := nb.Build() - b.ResetTimer() - var err error - encoder := &nullTokenSink{} - for i := 0; i < b.N; i++ { - var buf bytes.Buffer - err = codec.Marshal(n, encoder) - sink = buf - } - if err != nil { - panic(err) - } -} - -type nullTokenSink struct{} - -func (nullTokenSink) Step(_ *tok.Token) (bool, error) { - return false, nil -} - -func BenchmarkSpec_Marshal_MapNStrMap3StrInt(b *testing.B, np ipld.NodePrototype) { +func BenchmarkSpec_Marshal_MapNStrMap3StrInt(b *testing.B, np datamodel.NodePrototype) { for _, n := range []int{0, 1, 2, 4, 8, 16, 32} { b.Run(fmt.Sprintf("n=%d", n), func(b *testing.B) { msg := corpus.MapNStrMap3StrInt(n) @@ -74,15 +48,15 @@ func BenchmarkSpec_Marshal_MapNStrMap3StrInt(b *testing.B, np ipld.NodePrototype var err error for i := 0; i < b.N; i++ { buf = bytes.Buffer{} - err = codec.Marshal(node, refmtjson.NewEncoder(&buf, refmtjson.EncodeOptions{})) + err = json.Encode(node, &buf) } b.StopTimer() if err != nil { - b.Fatalf("marshal errored: %s", err) + b.Fatalf("encode errored: %s", err) } if buf.String() != msg { - b.Fatalf("marshal didn't match corpus") + b.Fatalf("encode result didn't match corpus") } }) } diff --git a/node/tests/schemaLinks.go b/node/tests/schemaLinks.go index f00df044..1e719b07 100644 --- a/node/tests/schemaLinks.go +++ b/node/tests/schemaLinks.go @@ -8,11 +8,12 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipfs/go-cid" - ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/schema" "github.com/ipld/go-ipld-prime/storage" "github.com/ipld/go-ipld-prime/traversal" @@ -22,7 +23,7 @@ import ( var store = storage.Memory{} -func encode(n ipld.Node) (ipld.Node, ipld.Link) { +func encode(n datamodel.Node) (datamodel.Node, datamodel.Link) { lp := cidlink.LinkPrototype{cid.Prefix{ Version: 1, Codec: 0x0129, @@ -32,7 +33,7 @@ func encode(n ipld.Node) (ipld.Node, ipld.Link) { lsys := cidlink.DefaultLinkSystem() lsys.StorageWriteOpener = (&store).OpenWrite - lnk, err := lsys.Store(ipld.LinkContext{}, lp, n) + lnk, err := lsys.Store(linking.LinkContext{}, lp, n) if err != nil { panic(err) } @@ -64,7 +65,7 @@ func SchemaTestLinks(t *testing.T, engine Engine) { engine.Init(t, ts) t.Run("typed linkage traversal", func(t *testing.T) { - _, intNodeLnk := func() (ipld.Node, ipld.Link) { + _, intNodeLnk := func() (datamodel.Node, datamodel.Link) { np := engine.PrototypeByName("Int") nb := np.NewBuilder() nb.AssignInt(101) @@ -85,7 +86,7 @@ func SchemaTestLinks(t *testing.T, engine Engine) { ma.AssembleEntry("strlist").AssignLink(listOfStringsNodeLnk) })) - ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype__Any{}) + ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any) ss := ssb.ExploreRecursive(selector.RecursionLimitDepth(3), ssb.ExploreUnion( ssb.Matcher(), ssb.ExploreAll(ssb.ExploreRecursiveEdge()), @@ -99,14 +100,14 @@ func SchemaTestLinks(t *testing.T, engine Engine) { err = traversal.Progress{ Cfg: &traversal.Config{ LinkSystem: lsys, - LinkTargetNodePrototypeChooser: func(lnk ipld.Link, lnkCtx ipld.LinkContext) (ipld.NodePrototype, error) { + LinkTargetNodePrototypeChooser: func(lnk datamodel.Link, lnkCtx linking.LinkContext) (datamodel.NodePrototype, error) { if tlnkNd, ok := lnkCtx.LinkNode.(schema.TypedLinkNode); ok { return tlnkNd.LinkTargetNodePrototype(), nil } return basicnode.Prototype.Any, nil }, }, - }.WalkMatching(linkStructNode, s, func(prog traversal.Progress, n ipld.Node) error { + }.WalkMatching(linkStructNode, s, func(prog traversal.Progress, n datamodel.Node) error { buf := new(bytes.Buffer) dagjson.Encode(n, buf) fmt.Printf("Walked %d: %v\n", order, buf.String()) diff --git a/node/tests/schemaLists.go b/node/tests/schemaLists.go index 8c08ff94..e90b6354 100644 --- a/node/tests/schemaLists.go +++ b/node/tests/schemaLists.go @@ -5,10 +5,10 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/schema" ) @@ -32,31 +32,31 @@ func SchemaTestListsContainingMaybe(t *testing.T, engine Engine) { la.AssembleValue().AssignString("2") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(n.LookupByIndex(0))), ShouldEqual, "1") Wish(t, must.String(must.Node(n.LookupByIndex(1))), ShouldEqual, "2") - Wish(t, must.String(must.Node(n.LookupBySegment(ipld.PathSegmentOfInt(0)))), ShouldEqual, "1") + Wish(t, must.String(must.Node(n.LookupBySegment(datamodel.PathSegmentOfInt(0)))), ShouldEqual, "1") Wish(t, must.String(must.Node(n.LookupByNode(basicnode.NewInt(0)))), ShouldEqual, "1") _, err := n.LookupByIndex(3) - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, nr.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(nr.LookupByIndex(0))), ShouldEqual, "1") Wish(t, must.String(must.Node(nr.LookupByIndex(1))), ShouldEqual, "2") - Wish(t, must.String(must.Node(n.LookupBySegment(ipld.PathSegmentOfInt(0)))), ShouldEqual, "1") + Wish(t, must.String(must.Node(n.LookupBySegment(datamodel.PathSegmentOfInt(0)))), ShouldEqual, "1") Wish(t, must.String(must.Node(n.LookupByNode(basicnode.NewInt(0)))), ShouldEqual, "1") _, err := n.LookupByIndex(3) - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) }) t.Run("repr-create", func(t *testing.T) { @@ -64,7 +64,7 @@ func SchemaTestListsContainingMaybe(t *testing.T, engine Engine) { la.AssembleValue().AssignString("1") la.AssembleValue().AssignString("2") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) t.Run("nullable", func(t *testing.T) { @@ -77,21 +77,21 @@ func SchemaTestListsContainingMaybe(t *testing.T, engine Engine) { la.AssembleValue().AssignNull() }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(n.LookupByIndex(0))), ShouldEqual, "1") - Wish(t, must.Node(n.LookupByIndex(1)), ShouldEqual, ipld.Null) + Wish(t, must.Node(n.LookupByIndex(1)), ShouldEqual, datamodel.Null) _, err := n.LookupByIndex(3) - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, nr.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(n.LookupByIndex(0))), ShouldEqual, "1") - Wish(t, must.Node(n.LookupByIndex(1)), ShouldEqual, ipld.Null) + Wish(t, must.Node(n.LookupByIndex(1)), ShouldEqual, datamodel.Null) _, err := n.LookupByIndex(3) - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) }) t.Run("repr-create", func(t *testing.T) { @@ -99,7 +99,7 @@ func SchemaTestListsContainingMaybe(t *testing.T, engine Engine) { la.AssembleValue().AssignString("1") la.AssembleValue().AssignNull() }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) } @@ -145,7 +145,7 @@ func SchemaTestListsContainingLists(t *testing.T, engine Engine) { }) }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Require(t, n.Length(), ShouldEqual, int64(3)) Require(t, must.Node(n.LookupByIndex(0)).Length(), ShouldEqual, int64(3)) Require(t, must.Node(n.LookupByIndex(1)).Length(), ShouldEqual, int64(1)) @@ -158,7 +158,7 @@ func SchemaTestListsContainingLists(t *testing.T, engine Engine) { }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_List) Require(t, nr.Length(), ShouldEqual, int64(3)) Require(t, must.Node(nr.LookupByIndex(0)).Length(), ShouldEqual, int64(3)) Require(t, must.Node(nr.LookupByIndex(1)).Length(), ShouldEqual, int64(1)) @@ -186,6 +186,6 @@ func SchemaTestListsContainingLists(t *testing.T, engine Engine) { la.AssembleValue().CreateMap(1, func(ma fluent.MapAssembler) { ma.AssembleEntry("encoded").AssignString("32") }) }) }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) } diff --git a/node/tests/schemaMaps.go b/node/tests/schemaMaps.go index 49c6521f..6257fd94 100644 --- a/node/tests/schemaMaps.go +++ b/node/tests/schemaMaps.go @@ -5,7 +5,7 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" "github.com/ipld/go-ipld-prime/schema" @@ -31,21 +31,21 @@ func SchemaTestMapsContainingMaybe(t *testing.T, engine Engine) { ma.AssembleEntry("two").AssignString("2") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(n.LookupByString("one"))), ShouldEqual, "1") Wish(t, must.String(must.Node(n.LookupByString("two"))), ShouldEqual, "2") _, err := n.LookupByString("miss") - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, nr.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(nr.LookupByString("one"))), ShouldEqual, "1") Wish(t, must.String(must.Node(nr.LookupByString("two"))), ShouldEqual, "2") _, err := nr.LookupByString("miss") - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) }) t.Run("repr-create", func(t *testing.T) { @@ -53,7 +53,7 @@ func SchemaTestMapsContainingMaybe(t *testing.T, engine Engine) { ma.AssembleEntry("one").AssignString("1") ma.AssembleEntry("two").AssignString("2") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) t.Run("nullable", func(t *testing.T) { @@ -66,21 +66,21 @@ func SchemaTestMapsContainingMaybe(t *testing.T, engine Engine) { ma.AssembleEntry("none").AssignNull() }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(n.LookupByString("one"))), ShouldEqual, "1") - Wish(t, must.Node(n.LookupByString("none")), ShouldEqual, ipld.Null) + Wish(t, must.Node(n.LookupByString("none")), ShouldEqual, datamodel.Null) _, err := n.LookupByString("miss") - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, nr.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(nr.LookupByString("one"))), ShouldEqual, "1") - Wish(t, must.Node(nr.LookupByString("none")), ShouldEqual, ipld.Null) + Wish(t, must.Node(nr.LookupByString("none")), ShouldEqual, datamodel.Null) _, err := nr.LookupByString("miss") - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) }) t.Run("repr-create", func(t *testing.T) { @@ -88,7 +88,7 @@ func SchemaTestMapsContainingMaybe(t *testing.T, engine Engine) { ma.AssembleEntry("one").AssignString("1") ma.AssembleEntry("none").AssignNull() }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) } @@ -117,7 +117,7 @@ func SchemaTestMapsContainingMaps(t *testing.T, engine Engine) { np := engine.PrototypeByName("Map__String__nullableMap__String__Frub") nrp := engine.PrototypeByName("Map__String__nullableMap__String__Frub.Repr") - creation := func(t *testing.T, np ipld.NodePrototype, fieldName string) schema.TypedNode { + creation := func(t *testing.T, np datamodel.NodePrototype, fieldName string) schema.TypedNode { return fluent.MustBuildMap(np, 3, func(ma fluent.MapAssembler) { ma.AssembleEntry("one").CreateMap(2, func(ma fluent.MapAssembler) { ma.AssembleEntry("zot").CreateMap(1, func(ma fluent.MapAssembler) { ma.AssembleEntry(fieldName).AssignString("11") }) @@ -129,37 +129,37 @@ func SchemaTestMapsContainingMaps(t *testing.T, engine Engine) { ma.AssembleEntry("none").AssignNull() }).(schema.TypedNode) } - reading := func(t *testing.T, n ipld.Node, fieldName string) { - withNode(n, func(n ipld.Node) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + reading := func(t *testing.T, n datamodel.Node, fieldName string) { + withNode(n, func(n datamodel.Node) { + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(3)) - withNode(must.Node(n.LookupByString("one")), func(n ipld.Node) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + withNode(must.Node(n.LookupByString("one")), func(n datamodel.Node) { + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(2)) - withNode(must.Node(n.LookupByString("zot")), func(n ipld.Node) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + withNode(must.Node(n.LookupByString("zot")), func(n datamodel.Node) { + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(1)) Wish(t, must.String(must.Node(n.LookupByString(fieldName))), ShouldEqual, "11") }) - withNode(must.Node(n.LookupByString("zop")), func(n ipld.Node) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + withNode(must.Node(n.LookupByString("zop")), func(n datamodel.Node) { + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(1)) Wish(t, must.String(must.Node(n.LookupByString(fieldName))), ShouldEqual, "12") }) }) - withNode(must.Node(n.LookupByString("two")), func(n ipld.Node) { + withNode(must.Node(n.LookupByString("two")), func(n datamodel.Node) { Wish(t, n.Length(), ShouldEqual, int64(1)) - withNode(must.Node(n.LookupByString("zim")), func(n ipld.Node) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + withNode(must.Node(n.LookupByString("zim")), func(n datamodel.Node) { + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(1)) Wish(t, must.String(must.Node(n.LookupByString(fieldName))), ShouldEqual, "21") }) }) - withNode(must.Node(n.LookupByString("none")), func(n ipld.Node) { - Wish(t, ipld.DeepEqual(n, ipld.Null), ShouldEqual, true) + withNode(must.Node(n.LookupByString("none")), func(n datamodel.Node) { + Wish(t, datamodel.DeepEqual(n, datamodel.Null), ShouldEqual, true) }) _, err := n.LookupByString("miss") - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrNotExists{}) + Wish(t, err, ShouldBeSameTypeAs, datamodel.ErrNotExists{}) }) } var n schema.TypedNode @@ -174,7 +174,7 @@ func SchemaTestMapsContainingMaps(t *testing.T, engine Engine) { }) t.Run("repr-create", func(t *testing.T) { nr := creation(t, nrp, "encoded") - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) } @@ -215,18 +215,18 @@ func SchemaTestMapsWithComplexKeys(t *testing.T, engine Engine) { ma.AssembleValue().AssignString("3") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(3)) n2 := must.Node(n.LookupByString("c:d")) - Require(t, n2.Kind(), ShouldEqual, ipld.Kind_String) + Require(t, n2.Kind(), ShouldEqual, datamodel.Kind_String) Wish(t, must.String(n2), ShouldEqual, "2") }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, nr.Length(), ShouldEqual, int64(3)) n2 := must.Node(nr.LookupByString("c:d")) - Require(t, n2.Kind(), ShouldEqual, ipld.Kind_String) + Require(t, n2.Kind(), ShouldEqual, datamodel.Kind_String) Wish(t, must.String(n2), ShouldEqual, "2") }) }) @@ -236,6 +236,6 @@ func SchemaTestMapsWithComplexKeys(t *testing.T, engine Engine) { ma.AssembleEntry("c:d").AssignString("2") ma.AssembleEntry("e:f").AssignString("3") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) } diff --git a/node/tests/schemaScalars.go b/node/tests/schemaScalars.go index e99cac6b..799093e4 100644 --- a/node/tests/schemaScalars.go +++ b/node/tests/schemaScalars.go @@ -6,11 +6,11 @@ import ( qt "github.com/frankban/quicktest" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) -func assignValue(am ipld.NodeAssembler, value interface{}) error { +func assignValue(am datamodel.NodeAssembler, value interface{}) error { switch value := value.(type) { case bool: return am.AssignBool(value) @@ -40,14 +40,14 @@ func SchemaTestScalars(t *testing.T, engine Engine) { var tests = []struct { name string - kind ipld.Kind + kind datamodel.Kind value interface{} }{ - {"Bool", ipld.Kind_Bool, true}, - {"Int", ipld.Kind_Int, int64(23)}, - {"Float", ipld.Kind_Float, 12.25}, - {"String", ipld.Kind_String, "foo"}, - {"Bytes", ipld.Kind_Bytes, []byte("bar")}, + {"Bool", datamodel.Kind_Bool, true}, + {"Int", datamodel.Kind_Int, int64(23)}, + {"Float", datamodel.Kind_Float, 12.25}, + {"String", datamodel.Kind_String, "foo"}, + {"Bytes", datamodel.Kind_Bytes, []byte("bar")}, } // We test each of the five scalar prototypes in subtests. @@ -109,15 +109,15 @@ func SchemaTestScalars(t *testing.T, engine Engine) { var gotValue interface{} err = nil switch testAssign.kind { - case ipld.Kind_Bool: + case datamodel.Kind_Bool: gotValue, err = n.AsBool() - case ipld.Kind_Int: + case datamodel.Kind_Int: gotValue, err = n.AsInt() - case ipld.Kind_Float: + case datamodel.Kind_Float: gotValue, err = n.AsFloat() - case ipld.Kind_String: + case datamodel.Kind_String: gotValue, err = n.AsString() - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: gotValue, err = n.AsBytes() default: t.Fatal(testAssign.kind) diff --git a/node/tests/schemaStruct.go b/node/tests/schemaStruct.go index 18584620..191b05e5 100644 --- a/node/tests/schemaStruct.go +++ b/node/tests/schemaStruct.go @@ -5,10 +5,10 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/schema" ) @@ -43,7 +43,7 @@ func SchemaTestRequiredFields(t *testing.T, engine Engine) { ma, _ := nb.BeginMap(0) err := ma.Finish() - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrMissingRequiredField{}) + Wish(t, err, ShouldBeSameTypeAs, schema.ErrMissingRequiredField{}) Wish(t, err.Error(), ShouldEqual, `missing required fields: a,b`) }) t.Run("building-representation-without-required-fields-errors", func(t *testing.T) { @@ -53,7 +53,7 @@ func SchemaTestRequiredFields(t *testing.T, engine Engine) { ma, _ := nb.BeginMap(0) err := ma.Finish() - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrMissingRequiredField{}) + Wish(t, err, ShouldBeSameTypeAs, schema.ErrMissingRequiredField{}) Wish(t, err.Error(), ShouldEqual, `missing required fields: a,b`) }) t.Run("building-representation-with-renames-without-required-fields-errors", func(t *testing.T) { @@ -63,7 +63,7 @@ func SchemaTestRequiredFields(t *testing.T, engine Engine) { ma, _ := nb.BeginMap(0) err := ma.Finish() - Wish(t, err, ShouldBeSameTypeAs, ipld.ErrMissingRequiredField{}) + Wish(t, err, ShouldBeSameTypeAs, schema.ErrMissingRequiredField{}) Wish(t, err.Error(), ShouldEqual, `missing required fields: a,b (serial:"z")`) }) } @@ -100,33 +100,33 @@ func SchemaTestStructNesting(t *testing.T, engine Engine) { }) }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(1)) n2 := must.Node(n.LookupByString("x")) - Require(t, n2.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n2.Kind(), ShouldEqual, datamodel.Kind_Map) - n2Seg := must.Node(n.LookupBySegment(ipld.PathSegmentOfString("x"))) - Wish(t, ipld.DeepEqual(n2, n2Seg), ShouldEqual, true) + n2Seg := must.Node(n.LookupBySegment(datamodel.PathSegmentOfString("x"))) + Wish(t, datamodel.DeepEqual(n2, n2Seg), ShouldEqual, true) n2Node := must.Node(n.LookupByNode(basicnode.NewString("x"))) - Wish(t, ipld.DeepEqual(n2, n2Node), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n2, n2Node), ShouldEqual, true) Wish(t, must.String(must.Node(n2.LookupByString("s"))), ShouldEqual, "woo") }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, nr.Length(), ShouldEqual, int64(1)) n2 := must.Node(nr.LookupByString("r")) - Require(t, n2.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n2.Kind(), ShouldEqual, datamodel.Kind_Map) - n2Seg := must.Node(nr.LookupBySegment(ipld.PathSegmentOfString("r"))) - Wish(t, ipld.DeepEqual(n2, n2Seg), ShouldEqual, true) + n2Seg := must.Node(nr.LookupBySegment(datamodel.PathSegmentOfString("r"))) + Wish(t, datamodel.DeepEqual(n2, n2Seg), ShouldEqual, true) n2Node := must.Node(nr.LookupByNode(basicnode.NewString("r"))) - Wish(t, ipld.DeepEqual(n2, n2Node), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n2, n2Node), ShouldEqual, true) Wish(t, must.String(must.Node(n2.LookupByString("q"))), ShouldEqual, "woo") }) @@ -137,6 +137,6 @@ func SchemaTestStructNesting(t *testing.T, engine Engine) { ma.AssembleEntry("q").AssignString("woo") }) }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) } diff --git a/node/tests/schemaStructReprStringjoin.go b/node/tests/schemaStructReprStringjoin.go index 66775991..5290d9fb 100644 --- a/node/tests/schemaStructReprStringjoin.go +++ b/node/tests/schemaStructReprStringjoin.go @@ -5,7 +5,7 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" "github.com/ipld/go-ipld-prime/schema" @@ -51,13 +51,13 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { ma.AssembleEntry("field").AssignString("valoo") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(1)) Wish(t, must.String(must.Node(n.LookupByString("field"))), ShouldEqual, "valoo") }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_String) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_String) Wish(t, must.String(nr), ShouldEqual, "valoo") }) }) @@ -65,7 +65,7 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { nr := fluent.MustBuild(nrp, func(na fluent.NodeAssembler) { na.AssignString("valoo") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) @@ -79,14 +79,14 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { ma.AssembleEntry("bar").AssignString("v2") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(n.LookupByString("foo"))), ShouldEqual, "v1") Wish(t, must.String(must.Node(n.LookupByString("bar"))), ShouldEqual, "v2") }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_String) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_String) Wish(t, must.String(nr), ShouldEqual, "v1:v2") }) }) @@ -94,7 +94,7 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { nr := fluent.MustBuild(nrp, func(na fluent.NodeAssembler) { na.AssignString("v1:v2") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) @@ -112,7 +112,7 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { ma.AssembleEntry("bar").AssignString("v4") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(3)) Wish(t, must.String(must.Node(n.LookupByString("foo"))), ShouldEqual, "v1") Wish(t, must.String(must.Node(n.LookupByString("bar"))), ShouldEqual, "v4") @@ -123,7 +123,7 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_String) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_String) Wish(t, must.String(nr), ShouldEqual, "v1-v2:v3-v4") }) }) @@ -131,7 +131,7 @@ func SchemaTestStructReprStringjoin(t *testing.T, engine Engine) { nr := fluent.MustBuild(nrp, func(na fluent.NodeAssembler) { na.AssignString("v1-v2:v3-v4") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) } diff --git a/node/tests/schemaStructReprTuple.go b/node/tests/schemaStructReprTuple.go index 313a4899..54ecc869 100644 --- a/node/tests/schemaStructReprTuple.go +++ b/node/tests/schemaStructReprTuple.go @@ -5,7 +5,7 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" "github.com/ipld/go-ipld-prime/must" "github.com/ipld/go-ipld-prime/schema" @@ -41,13 +41,13 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { ma.AssembleEntry("field").AssignString("valoo") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(1)) Wish(t, must.String(must.Node(n.LookupByString("field"))), ShouldEqual, "valoo") }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, nr.Length(), ShouldEqual, int64(1)) Wish(t, must.String(must.Node(nr.LookupByIndex(0))), ShouldEqual, "valoo") }) @@ -56,7 +56,7 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { nr := fluent.MustBuildList(nrp, 1, func(la fluent.ListAssembler) { la.AssembleValue().AssignString("valoo") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) @@ -72,7 +72,7 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { ma.AssembleEntry("qux").AssignString("3") }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(4)) Wish(t, must.String(must.Node(n.LookupByString("foo"))), ShouldEqual, "0") Wish(t, must.String(must.Node(n.LookupByString("bar"))), ShouldEqual, "1") @@ -81,7 +81,7 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, nr.Length(), ShouldEqual, int64(4)) Wish(t, must.String(must.Node(nr.LookupByIndex(0))), ShouldEqual, "0") Wish(t, must.String(must.Node(nr.LookupByIndex(1))), ShouldEqual, "1") @@ -96,7 +96,7 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { la.AssembleValue().AssignString("2") la.AssembleValue().AssignString("3") }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) @@ -110,19 +110,19 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { ma.AssembleEntry("bar").AssignNull() }).(schema.TypedNode) t.Run("typed-read", func(t *testing.T) { - Require(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Require(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) Wish(t, n.Length(), ShouldEqual, int64(4)) Wish(t, must.String(must.Node(n.LookupByString("foo"))), ShouldEqual, "0") - Wish(t, must.Node(n.LookupByString("bar")), ShouldEqual, ipld.Null) - Wish(t, must.Node(n.LookupByString("baz")), ShouldEqual, ipld.Absent) - Wish(t, must.Node(n.LookupByString("qux")), ShouldEqual, ipld.Absent) + Wish(t, must.Node(n.LookupByString("bar")), ShouldEqual, datamodel.Null) + Wish(t, must.Node(n.LookupByString("baz")), ShouldEqual, datamodel.Absent) + Wish(t, must.Node(n.LookupByString("qux")), ShouldEqual, datamodel.Absent) }) t.Run("repr-read", func(t *testing.T) { nr := n.Representation() - Require(t, nr.Kind(), ShouldEqual, ipld.Kind_List) + Require(t, nr.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, nr.Length(), ShouldEqual, int64(2)) Wish(t, must.String(must.Node(nr.LookupByIndex(0))), ShouldEqual, "0") - Wish(t, must.Node(nr.LookupByIndex(1)), ShouldEqual, ipld.Null) + Wish(t, must.Node(nr.LookupByIndex(1)), ShouldEqual, datamodel.Null) }) }) t.Run("repr-create", func(t *testing.T) { @@ -130,7 +130,7 @@ func SchemaTestStructReprTuple(t *testing.T, engine Engine) { la.AssembleValue().AssignString("0") la.AssembleValue().AssignNull() }) - Wish(t, ipld.DeepEqual(n, nr), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, nr), ShouldEqual, true) }) }) } diff --git a/node/tests/schemaStructsContainingMaybe.go b/node/tests/schemaStructsContainingMaybe.go index e4010555..26f26fd4 100644 --- a/node/tests/schemaStructsContainingMaybe.go +++ b/node/tests/schemaStructsContainingMaybe.go @@ -3,7 +3,7 @@ package tests import ( "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -49,7 +49,7 @@ func SchemaTestStructsContainingMaybe(t *testing.T, engine Engine) { typeJson: `{"f1":"a","f2":"b","f3":"c","f4":"d","f5":"e"}`, reprJson: `{"f5":"e","r1":"a","r2":"b","r3":"c","r4":"d"}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"f1", "a"}, {"f2", "b"}, {"f3", "c"}, @@ -57,7 +57,7 @@ func SchemaTestStructsContainingMaybe(t *testing.T, engine Engine) { {"f5", "e"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"r1", "a"}, {"r2", "b"}, {"r3", "c"}, @@ -70,19 +70,19 @@ func SchemaTestStructsContainingMaybe(t *testing.T, engine Engine) { typeJson: `{"f1":"a","f2":"b","f3":null,"f4":null,"f5":"e"}`, reprJson: `{"f5":"e","r1":"a","r2":"b","r3":null,"r4":null}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"f1", "a"}, {"f2", "b"}, - {"f3", ipld.Null}, - {"f4", ipld.Null}, + {"f3", datamodel.Null}, + {"f4", datamodel.Null}, {"f5", "e"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"r1", "a"}, {"r2", "b"}, - {"r3", ipld.Null}, - {"r4", ipld.Null}, + {"r3", datamodel.Null}, + {"r4", datamodel.Null}, {"f5", "e"}, }, }, @@ -91,26 +91,26 @@ func SchemaTestStructsContainingMaybe(t *testing.T, engine Engine) { typeJson: `{"f1":"a","f3":"c","f5":"e"}`, reprJson: `{"f5":"e","r1":"a","r3":"c"}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"f1", "a"}, - {"f2", ipld.Absent}, + {"f2", datamodel.Absent}, {"f3", "c"}, - {"f4", ipld.Absent}, + {"f4", datamodel.Absent}, {"f5", "e"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"r1", "a"}, - //{"r2", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"r2", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. {"r3", "c"}, - //{"r4", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"r4", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. {"f5", "e"}, }, typeItr: []entry{ {"f1", "a"}, - {"f2", ipld.Absent}, + {"f2", datamodel.Absent}, {"f3", "c"}, - {"f4", ipld.Absent}, + {"f4", datamodel.Absent}, {"f5", "e"}, }, }, @@ -119,27 +119,27 @@ func SchemaTestStructsContainingMaybe(t *testing.T, engine Engine) { typeJson: `{"f1":"a","f2":"b","f3":null}`, reprJson: `{"r1":"a","r2":"b","r3":null}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"f1", "a"}, {"f2", "b"}, - {"f3", ipld.Null}, - {"f4", ipld.Absent}, - {"f5", ipld.Absent}, + {"f3", datamodel.Null}, + {"f4", datamodel.Absent}, + {"f5", datamodel.Absent}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"r1", "a"}, {"r2", "b"}, - {"r3", ipld.Null}, - //{"r4", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. - //{"f5", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"r3", datamodel.Null}, + //{"r4", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"f5", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, typeItr: []entry{ {"f1", "a"}, {"f2", "b"}, - {"f3", ipld.Null}, - {"f4", ipld.Absent}, - {"f5", ipld.Absent}, + {"f3", datamodel.Null}, + {"f4", datamodel.Absent}, + {"f5", datamodel.Absent}, }, }, } diff --git a/node/tests/schemaUnions.go b/node/tests/schemaUnions.go index b2a431d1..a696dc7a 100644 --- a/node/tests/schemaUnions.go +++ b/node/tests/schemaUnions.go @@ -3,7 +3,7 @@ package tests import ( "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -30,14 +30,14 @@ func SchemaTestUnionKeyed(t *testing.T, engine Engine) { typeJson: `{"String":"whee"}`, reprJson: `{"a":"whee"}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"String", "whee"}, - //{"Strung", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"Strung", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"a", "whee"}, - //{"b", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"b", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, }, { @@ -45,13 +45,13 @@ func SchemaTestUnionKeyed(t *testing.T, engine Engine) { typeJson: `{"Strung":"whee"}`, reprJson: `{"b":"whee"}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, - //{"String", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"", datamodel.Kind_Map}, + //{"String", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. {"Strung", "whee"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, - //{"a", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"", datamodel.Kind_Map}, + //{"a", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. {"b", "whee"}, }, }, @@ -101,14 +101,14 @@ func SchemaTestUnionKeyedComplexChildren(t *testing.T, engine Engine) { typeJson: `{"String":"whee"}`, reprJson: `{"a":"whee"}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"String", "whee"}, - //{"SmolStruct", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"SmolStruct", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"a", "whee"}, - //{"b", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"b", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, }, { @@ -116,15 +116,15 @@ func SchemaTestUnionKeyedComplexChildren(t *testing.T, engine Engine) { typeJson: `{"SmolStruct":{"s":"whee"}}`, reprJson: `{"b":{"q":"whee"}}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, - //{"String", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. - {"SmolStruct", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, + //{"String", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"SmolStruct", datamodel.Kind_Map}, {"SmolStruct/s", "whee"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, - //{"a", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. - {"b", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, + //{"a", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"b", datamodel.Kind_Map}, {"b/q", "whee"}, }, }, diff --git a/node/tests/schemaUnionsKinded.go b/node/tests/schemaUnionsKinded.go index 20a0c8d7..d239cb8b 100644 --- a/node/tests/schemaUnionsKinded.go +++ b/node/tests/schemaUnionsKinded.go @@ -3,7 +3,7 @@ package tests import ( "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -24,9 +24,9 @@ func SchemaTestUnionKinded(t *testing.T, engine Engine) { "String", "SmolStruct", }, - schema.SpawnUnionRepresentationKinded(map[ipld.Kind]schema.TypeName{ - ipld.Kind_String: "String", - ipld.Kind_Map: "SmolStruct", + schema.SpawnUnionRepresentationKinded(map[datamodel.Kind]schema.TypeName{ + datamodel.Kind_String: "String", + datamodel.Kind_Map: "SmolStruct", }), )) engine.Init(t, ts) @@ -39,12 +39,12 @@ func SchemaTestUnionKinded(t *testing.T, engine Engine) { typeJson: `{"String":"whee"}`, reprJson: `"whee"`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"String", "whee"}, - //{"SmolStruct", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"SmolStruct", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, reprPoints: []testcasePoint{ - {"", ipld.Kind_String}, + {"", datamodel.Kind_String}, {"", "whee"}, }, }, @@ -53,13 +53,13 @@ func SchemaTestUnionKinded(t *testing.T, engine Engine) { typeJson: `{"SmolStruct":{"s":"whee"}}`, reprJson: `{"q":"whee"}`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, - //{"String", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. - {"SmolStruct", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, + //{"String", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"SmolStruct", datamodel.Kind_Map}, {"SmolStruct/s", "whee"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"q", "whee"}, }, }, diff --git a/node/tests/schemaUnionsStringprefix.go b/node/tests/schemaUnionsStringprefix.go index f69ccb34..3edb9b2b 100644 --- a/node/tests/schemaUnionsStringprefix.go +++ b/node/tests/schemaUnionsStringprefix.go @@ -3,7 +3,7 @@ package tests import ( "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -41,12 +41,12 @@ func SchemaTestUnionStringprefix(t *testing.T, engine Engine) { typeJson: `{"String":"whee"}`, reprJson: `"simple:whee"`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, {"String", "whee"}, - //{"SmolStruct", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. + //{"SmolStruct", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. }, reprPoints: []testcasePoint{ - {"", ipld.Kind_String}, + {"", datamodel.Kind_String}, {"", "simple:whee"}, }, }, @@ -55,14 +55,14 @@ func SchemaTestUnionStringprefix(t *testing.T, engine Engine) { typeJson: `{"SmolStruct":{"a":"whee","b":"woo"}}`, reprJson: `"complex:whee:woo"`, typePoints: []testcasePoint{ - {"", ipld.Kind_Map}, - //{"String", ipld.ErrNotExists{}}, // TODO: need better error typing from traversal package. - {"SmolStruct", ipld.Kind_Map}, + {"", datamodel.Kind_Map}, + //{"String", datamodel.ErrNotExists{}}, // TODO: need better error typing from traversal package. + {"SmolStruct", datamodel.Kind_Map}, {"SmolStruct/a", "whee"}, {"SmolStruct/b", "woo"}, }, reprPoints: []testcasePoint{ - {"", ipld.Kind_String}, + {"", datamodel.Kind_String}, {"", "complex:whee:woo"}, }, }, diff --git a/node/tests/stringSpecs.go b/node/tests/stringSpecs.go index 9b822c6a..8ed03a28 100644 --- a/node/tests/stringSpecs.go +++ b/node/tests/stringSpecs.go @@ -5,17 +5,17 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) -func SpecTestString(t *testing.T, np ipld.NodePrototype) { +func SpecTestString(t *testing.T, np datamodel.NodePrototype) { t.Run("string node", func(t *testing.T) { nb := np.NewBuilder() err := nb.AssignString("asdf") Wish(t, err, ShouldEqual, nil) n := nb.Build() - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_String) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_String) Wish(t, n.IsNull(), ShouldEqual, false) x, err := n.AsString() Wish(t, err, ShouldEqual, nil) diff --git a/node/tests/testEngine.go b/node/tests/testEngine.go index 7236c278..bd6821a5 100644 --- a/node/tests/testEngine.go +++ b/node/tests/testEngine.go @@ -3,7 +3,7 @@ package tests import ( "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -18,5 +18,5 @@ import ( // their representation prototypes can be obtained by appending ".Repr". type Engine interface { Init(t *testing.T, ts schema.TypeSystem) - PrototypeByName(name string) ipld.NodePrototype + PrototypeByName(name string) datamodel.NodePrototype } diff --git a/node/tests/testcase.go b/node/tests/testcase.go index 5ccf1cba..7d7acc2c 100644 --- a/node/tests/testcase.go +++ b/node/tests/testcase.go @@ -10,9 +10,9 @@ import ( "github.com/polydawn/refmt/shared" . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" "github.com/ipld/go-ipld-prime/traversal" ) @@ -86,10 +86,10 @@ type entry struct { value interface{} // same rules as testcasePoint.expect } -func (tcase testcase) Test(t *testing.T, np, npr ipld.NodePrototype) { +func (tcase testcase) Test(t *testing.T, np, npr datamodel.NodePrototype) { t.Run(tcase.name, func(t *testing.T) { // We'll produce either one or two nodes, depending on the fixture; if two, we'll be expecting them to be equal. - var n, n2 ipld.Node + var n, n2 datamodel.Node // Attempt to produce a node by using unmarshal on type-level fixture data and the type-level NodePrototype. // This exercises creating a value using the AssembleEntry path (but note, not AssembleKey+AssembleValue path). @@ -125,7 +125,7 @@ func (tcase testcase) Test(t *testing.T, np, npr ipld.NodePrototype) { } if n2 != nil { t.Run("type-create and repr-create match", func(t *testing.T) { - Wish(t, ipld.DeepEqual(n, n2), ShouldEqual, true) + Wish(t, datamodel.DeepEqual(n, n2), ShouldEqual, true) }) } @@ -172,7 +172,7 @@ func (tcase testcase) Test(t *testing.T, np, npr ipld.NodePrototype) { k, v, err := itr.Next() Wish(t, k, ShouldEqual, nil) Wish(t, v, ShouldEqual, nil) - Wish(t, err, ShouldEqual, ipld.ErrIteratorOverread{}) + Wish(t, err, ShouldEqual, datamodel.ErrIteratorOverread{}) } else if tcase.typeJson != "" { t.Run("type-marshal", func(t *testing.T) { testMarshal(t, n, tcase.typeJson) @@ -189,7 +189,7 @@ func (tcase testcase) Test(t *testing.T, np, npr ipld.NodePrototype) { }) } -func testUnmarshal(t *testing.T, np ipld.NodePrototype, data string, expectFail error) ipld.Node { +func testUnmarshal(t *testing.T, np datamodel.NodePrototype, data string, expectFail error) datamodel.Node { t.Helper() nb := np.NewBuilder() err := dagjson.Decode(nb, strings.NewReader(data)) @@ -206,7 +206,7 @@ func testUnmarshal(t *testing.T, np ipld.NodePrototype, data string, expectFail return nb.Build() } -func testMarshal(t *testing.T, n ipld.Node, data string) { +func testMarshal(t *testing.T, n datamodel.Node, data string) { t.Helper() // We'll marshal with "pretty" linebreaks and indents (and re-format the fixture to the same) for better diffing. prettyprint := json.EncodeOptions{Line: []byte{'\n'}, Indent: []byte{'\t'}} @@ -222,9 +222,9 @@ func testMarshal(t *testing.T, n ipld.Node, data string) { Wish(t, buf.String(), ShouldEqual, reformat(data, prettyprint)) } -func wishPoint(t *testing.T, n ipld.Node, point testcasePoint) { +func wishPoint(t *testing.T, n datamodel.Node, point testcasePoint) { t.Helper() - reached, err := traversal.Get(n, ipld.ParsePath(point.path)) + reached, err := traversal.Get(n, datamodel.ParsePath(point.path)) switch point.expect.(type) { case error: Wish(t, err, ShouldBeSameTypeAs, point.expect) @@ -243,33 +243,33 @@ func wishPoint(t *testing.T, n ipld.Node, point testcasePoint) { // // If the expected value is a primitive string, it'll AsStrong on the Node; etc. // -// Using an ipld.Kind value is also possible, which will just check the kind and not the value contents. +// Using an datamodel.Kind value is also possible, which will just check the kind and not the value contents. // -// If an ipld.Node is the expected value, a full deep ShouldEqual is used as normal. +// If an datamodel.Node is the expected value, a full deep ShouldEqual is used as normal. func closeEnough(actual, expected interface{}) (string, bool) { if expected == nil { return ShouldEqual(actual, nil) } - a, ok := actual.(ipld.Node) + a, ok := actual.(datamodel.Node) if !ok { - return "this checker only supports checking ipld.Node values", false + return "this checker only supports checking datamodel.Node values", false } switch expected.(type) { - case ipld.Kind: + case datamodel.Kind: return ShouldEqual(a.Kind(), expected) case string: - if a.Kind() != ipld.Kind_String { + if a.Kind() != datamodel.Kind_String { return fmt.Sprintf("expected something with kind string, got kind %s", a.Kind()), false } x, _ := a.AsString() return ShouldEqual(x, expected) case int: - if a.Kind() != ipld.Kind_Int { + if a.Kind() != datamodel.Kind_Int { return fmt.Sprintf("expected something with kind int, got kind %s", a.Kind()), false } x, _ := a.AsInt() return ShouldEqual(x, expected) - case ipld.Node: + case datamodel.Node: return ShouldEqual(actual, expected) default: return fmt.Sprintf("this checker doesn't support an expected value of type %T", expected), false diff --git a/node/tests/testutil.go b/node/tests/testutil.go index 063a7193..2c4b92d3 100644 --- a/node/tests/testutil.go +++ b/node/tests/testutil.go @@ -1,7 +1,7 @@ package tests import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // This file is full of helper functions. Most are moderately embarassing. @@ -10,14 +10,14 @@ import ( // they'd probably be much less fragile and give better error messages that way. // On the other hand, the functions for condensing two-arg returns wouldn't go away anyway. -func plz(n ipld.Node, e error) ipld.Node { +func plz(n datamodel.Node, e error) datamodel.Node { if e != nil { panic(e) } return n } -func plzStr(n ipld.Node, e error) string { +func plzStr(n datamodel.Node, e error) string { if e != nil { panic(e) } @@ -28,7 +28,7 @@ func plzStr(n ipld.Node, e error) string { } } -func str(n ipld.Node) string { +func str(n datamodel.Node) string { if s, ok := n.AsString(); ok == nil { return s } else { @@ -36,7 +36,7 @@ func str(n ipld.Node) string { } } -func erp(n ipld.Node, e error) interface{} { +func erp(n datamodel.Node, e error) interface{} { if e != nil { return e } @@ -44,6 +44,6 @@ func erp(n ipld.Node, e error) interface{} { } // purely to syntactically flip large inline closures so we can see the argument at the top rather than the bottom of the block. -func withNode(n ipld.Node, cb func(n ipld.Node)) { +func withNode(n datamodel.Node, cb func(n datamodel.Node)) { cb(n) } diff --git a/node/tests/traversalBenchmarks.go b/node/tests/traversalBenchmarks.go index 9572db3e..1d3e648a 100644 --- a/node/tests/traversalBenchmarks.go +++ b/node/tests/traversalBenchmarks.go @@ -4,12 +4,12 @@ import ( "fmt" "testing" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/tests/corpus" "github.com/ipld/go-ipld-prime/traversal" ) -func BenchmarkSpec_Walk_Map3StrInt(b *testing.B, np ipld.NodePrototype) { +func BenchmarkSpec_Walk_Map3StrInt(b *testing.B, np datamodel.NodePrototype) { node := mustNodeFromJsonString(np, corpus.Map3StrInt()) sel := mustSelectorFromJsonString(np, `{"a":{">":{".":{}}}}`) b.ResetTimer() @@ -17,7 +17,7 @@ func BenchmarkSpec_Walk_Map3StrInt(b *testing.B, np ipld.NodePrototype) { var visitCountSanityCheck int for i := 0; i < b.N; i++ { visitCountSanityCheck = 0 - traversal.WalkMatching(node, sel, func(tp traversal.Progress, n ipld.Node) error { + traversal.WalkMatching(node, sel, func(tp traversal.Progress, n datamodel.Node) error { visitCountSanityCheck++ // this sanity check is sufficiently cheap to be worth it return nil // no need to do anything here; just care about exercising the walk internals. }) @@ -27,7 +27,7 @@ func BenchmarkSpec_Walk_Map3StrInt(b *testing.B, np ipld.NodePrototype) { } } -func BenchmarkSpec_Walk_MapNStrMap3StrInt(b *testing.B, np ipld.NodePrototype) { +func BenchmarkSpec_Walk_MapNStrMap3StrInt(b *testing.B, np datamodel.NodePrototype) { sel := mustSelectorFromJsonString(np, `{"a":{">":{"a":{">":{".":{}}}}}}`) for _, n := range []int{0, 1, 2, 4, 8, 16, 32} { @@ -38,7 +38,7 @@ func BenchmarkSpec_Walk_MapNStrMap3StrInt(b *testing.B, np ipld.NodePrototype) { var visitCountSanityCheck int for i := 0; i < b.N; i++ { visitCountSanityCheck = 0 - traversal.WalkMatching(node, sel, func(tp traversal.Progress, n ipld.Node) error { + traversal.WalkMatching(node, sel, func(tp traversal.Progress, n datamodel.Node) error { visitCountSanityCheck++ // this sanity check is sufficiently cheap to be worth it return nil // no need to do anything here; just care about exercising the walk internals. }) diff --git a/node/tests/unmarshalBenchmarks.go b/node/tests/unmarshalBenchmarks.go index 70c74ced..63cbf70c 100644 --- a/node/tests/unmarshalBenchmarks.go +++ b/node/tests/unmarshalBenchmarks.go @@ -6,10 +6,8 @@ import ( "strings" "testing" - refmtjson "github.com/polydawn/refmt/json" - - ipld "github.com/ipld/go-ipld-prime" - "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/codec/json" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/tests/corpus" ) @@ -22,11 +20,11 @@ import ( // - we can make direct comparisons to the standard library json marshalling // and unmarshalling, thus having a back-of-the-envelope baseline to compare. -func BenchmarkSpec_Unmarshal_Map3StrInt(b *testing.B, np ipld.NodePrototype) { +func BenchmarkSpec_Unmarshal_Map3StrInt(b *testing.B, np datamodel.NodePrototype) { var err error for i := 0; i < b.N; i++ { nb := np.NewBuilder() - err = codec.Unmarshal(nb, refmtjson.NewDecoder(strings.NewReader(`{"whee":1,"woot":2,"waga":3}`))) + err = json.Decode(nb, strings.NewReader(`{"whee":1,"woot":2,"waga":3}`)) sink = nb.Build() } if err != nil { @@ -34,29 +32,29 @@ func BenchmarkSpec_Unmarshal_Map3StrInt(b *testing.B, np ipld.NodePrototype) { } } -func BenchmarkSpec_Unmarshal_MapNStrMap3StrInt(b *testing.B, np ipld.NodePrototype) { +func BenchmarkSpec_Unmarshal_MapNStrMap3StrInt(b *testing.B, np datamodel.NodePrototype) { for _, n := range []int{0, 1, 2, 4, 8, 16, 32} { b.Run(fmt.Sprintf("n=%d", n), func(b *testing.B) { msg := corpus.MapNStrMap3StrInt(n) b.ResetTimer() - var node ipld.Node + var node datamodel.Node var err error nb := np.NewBuilder() for i := 0; i < b.N; i++ { - err = codec.Unmarshal(nb, refmtjson.NewDecoder(strings.NewReader(msg))) + err = json.Decode(nb, strings.NewReader(msg)) node = nb.Build() nb.Reset() } b.StopTimer() if err != nil { - b.Fatalf("unmarshal errored: %s", err) + b.Fatalf("decode errored: %s", err) } var buf bytes.Buffer - codec.Marshal(node, refmtjson.NewEncoder(&buf, refmtjson.EncodeOptions{})) + json.Encode(node, &buf) if buf.String() != msg { - b.Fatalf("remarshal didn't match corpus") + b.Fatalf("re-encode result didn't match corpus") } }) } diff --git a/node/tests/util.go b/node/tests/util.go index 375e4bb3..0ce32e93 100644 --- a/node/tests/util.go +++ b/node/tests/util.go @@ -3,10 +3,8 @@ package tests import ( "strings" - refmtjson "github.com/polydawn/refmt/json" - - ipld "github.com/ipld/go-ipld-prime" - "github.com/ipld/go-ipld-prime/codec" + "github.com/ipld/go-ipld-prime/codec/json" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/must" "github.com/ipld/go-ipld-prime/traversal/selector" ) @@ -15,13 +13,13 @@ import ( // in order to defuse the possibility of their work being elided. var sink interface{} -func mustNodeFromJsonString(np ipld.NodePrototype, str string) ipld.Node { +func mustNodeFromJsonString(np datamodel.NodePrototype, str string) datamodel.Node { nb := np.NewBuilder() - must.NotError(codec.Unmarshal(nb, refmtjson.NewDecoder(strings.NewReader(str)))) + must.NotError(json.Decode(nb, strings.NewReader(str))) return nb.Build() } -func mustSelectorFromJsonString(np ipld.NodePrototype, str string) selector.Selector { +func mustSelectorFromJsonString(np datamodel.NodePrototype, str string) selector.Selector { // Needing an 'ns' parameter here is sort of off-topic, to be honest. // Someday the selector package will probably contain codegen'd nodes of its own schema, and we'll use those unconditionally. // For now... we'll just use whatever node you're already testing, because it oughta work diff --git a/operations.go b/operations.go new file mode 100644 index 00000000..570f7e58 --- /dev/null +++ b/operations.go @@ -0,0 +1,13 @@ +package ipld + +import ( + "github.com/ipld/go-ipld-prime/datamodel" +) + +// DeepEqual reports whether x and y are "deeply equal" as IPLD nodes. +// This is similar to reflect.DeepEqual, but based around the Node interface. +// +// This is exactly equivalent to the datamodel.DeepEqual function. +func DeepEqual(x, y Node) bool { + return datamodel.DeepEqual(x, y) +} diff --git a/schema/dmt/gen.go b/schema/dmt/gen.go index 9ff290eb..6211f4b4 100644 --- a/schema/dmt/gen.go +++ b/schema/dmt/gen.go @@ -6,7 +6,7 @@ package main import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" gengo "github.com/ipld/go-ipld-prime/schema/gen/go" ) @@ -81,9 +81,9 @@ func main() { "TypeName", "TypeDefnInline", }, - schema.SpawnUnionRepresentationKinded(map[ipld.Kind]schema.TypeName{ - ipld.Kind_String: "TypeName", - ipld.Kind_Map: "TypeDefnInline", + schema.SpawnUnionRepresentationKinded(map[datamodel.Kind]schema.TypeName{ + datamodel.Kind_String: "TypeName", + datamodel.Kind_Map: "TypeDefnInline", }), )) ts.Accumulate(schema.SpawnUnion("TypeDefnInline", // n.b. previously called "TypeTerm". @@ -371,12 +371,12 @@ func main() { "Int", "Float", }, - schema.SpawnUnionRepresentationKinded(map[ipld.Kind]schema.TypeName{ - ipld.Kind_Bool: "Bool", - ipld.Kind_String: "String", - ipld.Kind_Bytes: "Bytes", - ipld.Kind_Int: "Int", - ipld.Kind_Float: "Float", + schema.SpawnUnionRepresentationKinded(map[datamodel.Kind]schema.TypeName{ + datamodel.Kind_Bool: "Bool", + datamodel.Kind_String: "String", + datamodel.Kind_Bytes: "Bytes", + datamodel.Kind_Int: "Int", + datamodel.Kind_Float: "Float", }), )) diff --git a/schema/dmt/ipldsch_minima.go b/schema/dmt/ipldsch_minima.go index 4c6e319d..ad45175a 100644 --- a/schema/dmt/ipldsch_minima.go +++ b/schema/dmt/ipldsch_minima.go @@ -5,7 +5,7 @@ package schemadmt import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -36,16 +36,16 @@ type _ErrorThunkAssembler struct { e error } -func (ea _ErrorThunkAssembler) BeginMap(_ int64) (ipld.MapAssembler, error) { return nil, ea.e } -func (ea _ErrorThunkAssembler) BeginList(_ int64) (ipld.ListAssembler, error) { return nil, ea.e } -func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e } -func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignLink(ipld.Link) error { return ea.e } -func (ea _ErrorThunkAssembler) AssignNode(ipld.Node) error { return ea.e } -func (ea _ErrorThunkAssembler) Prototype() ipld.NodePrototype { +func (ea _ErrorThunkAssembler) BeginMap(_ int64) (datamodel.MapAssembler, error) { return nil, ea.e } +func (ea _ErrorThunkAssembler) BeginList(_ int64) (datamodel.ListAssembler, error) { return nil, ea.e } +func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e } +func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignLink(datamodel.Link) error { return ea.e } +func (ea _ErrorThunkAssembler) AssignNode(datamodel.Node) error { return ea.e } +func (ea _ErrorThunkAssembler) Prototype() datamodel.NodePrototype { panic(fmt.Errorf("cannot get prototype from error-carrying assembler: already derailed with error: %w", ea.e)) } diff --git a/schema/dmt/ipldsch_satisfaction.go b/schema/dmt/ipldsch_satisfaction.go index 38c3d5c0..5dd22e33 100644 --- a/schema/dmt/ipldsch_satisfaction.go +++ b/schema/dmt/ipldsch_satisfaction.go @@ -3,7 +3,7 @@ package schemadmt // Code generated by go-ipld-prime gengo. DO NOT EDIT. import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/mixins" "github.com/ipld/go-ipld-prime/schema" ) @@ -40,12 +40,12 @@ func (m MaybeAnyScalar) IsAbsent() bool { func (m MaybeAnyScalar) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeAnyScalar) AsNode() ipld.Node { +func (m MaybeAnyScalar) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -66,57 +66,57 @@ var ( memberName__AnyScalar_Int = _String{"Int"} memberName__AnyScalar_Float = _String{"Float"} ) -var _ ipld.Node = (AnyScalar)(&_AnyScalar{}) +var _ datamodel.Node = (AnyScalar)(&_AnyScalar{}) var _ schema.TypedNode = (AnyScalar)(&_AnyScalar{}) -func (AnyScalar) Kind() ipld.Kind { - return ipld.Kind_Map +func (AnyScalar) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n AnyScalar) LookupByString(key string) (ipld.Node, error) { +func (n AnyScalar) LookupByString(key string) (datamodel.Node, error) { switch key { case "Bool": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "String": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil case "Bytes": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x3, nil case "Int": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x4, nil case "Float": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x5, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n AnyScalar) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n AnyScalar) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (AnyScalar) LookupByIndex(idx int64) (ipld.Node, error) { +func (AnyScalar) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.AnyScalar"}.LookupByIndex(0) } -func (n AnyScalar) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n AnyScalar) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n AnyScalar) MapIterator() ipld.MapIterator { +func (n AnyScalar) MapIterator() datamodel.MapIterator { return &_AnyScalar__MapItr{n, false} } @@ -125,9 +125,9 @@ type _AnyScalar__MapItr struct { done bool } -func (itr *_AnyScalar__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_AnyScalar__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -150,7 +150,7 @@ func (itr *_AnyScalar__MapItr) Done() bool { return itr.done } -func (AnyScalar) ListIterator() ipld.ListIterator { +func (AnyScalar) ListIterator() datamodel.ListIterator { return nil } func (AnyScalar) Length() int64 { @@ -177,16 +177,16 @@ func (AnyScalar) AsString() (string, error) { func (AnyScalar) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.AnyScalar"}.AsBytes() } -func (AnyScalar) AsLink() (ipld.Link, error) { +func (AnyScalar) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.AnyScalar"}.AsLink() } -func (AnyScalar) Prototype() ipld.NodePrototype { +func (AnyScalar) Prototype() datamodel.NodePrototype { return _AnyScalar__Prototype{} } type _AnyScalar__Prototype struct{} -func (_AnyScalar__Prototype) NewBuilder() ipld.NodeBuilder { +func (_AnyScalar__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _AnyScalar__Builder nb.Reset() return &nb @@ -196,7 +196,7 @@ type _AnyScalar__Builder struct { _AnyScalar__Assembler } -func (nb *_AnyScalar__Builder) Build() ipld.Node { +func (nb *_AnyScalar__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -251,7 +251,7 @@ func (na *_AnyScalar__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_AnyScalar__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_AnyScalar__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -264,7 +264,7 @@ func (na *_AnyScalar__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_AnyScalar__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_AnyScalar__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.AnyScalar"}.BeginList(0) } func (na *_AnyScalar__Assembler) AssignNull() error { @@ -296,10 +296,10 @@ func (_AnyScalar__Assembler) AssignString(string) error { func (_AnyScalar__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.AnyScalar"}.AssignBytes(nil) } -func (_AnyScalar__Assembler) AssignLink(ipld.Link) error { +func (_AnyScalar__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.AnyScalar"}.AssignLink(nil) } -func (na *_AnyScalar__Assembler) AssignNode(v ipld.Node) error { +func (na *_AnyScalar__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -319,8 +319,8 @@ func (na *_AnyScalar__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -337,7 +337,7 @@ func (na *_AnyScalar__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_AnyScalar__Assembler) Prototype() ipld.NodePrototype { +func (_AnyScalar__Assembler) Prototype() datamodel.NodePrototype { return _AnyScalar__Prototype{} } func (ma *_AnyScalar__Assembler) valueFinishTidy() bool { @@ -349,7 +349,7 @@ func (ma *_AnyScalar__Assembler) valueFinishTidy() bool { return false } } -func (ma *_AnyScalar__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_AnyScalar__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -404,9 +404,9 @@ func (ma *_AnyScalar__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er ma.ca5.m = &ma.cm return &ma.ca5, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.AnyScalar", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.AnyScalar", Key: &_String{k}} } -func (ma *_AnyScalar__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_AnyScalar__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -424,7 +424,7 @@ func (ma *_AnyScalar__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_AnyScalar__KeyAssembler)(ma) } -func (ma *_AnyScalar__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_AnyScalar__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -485,10 +485,10 @@ func (ma *_AnyScalar__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_AnyScalar__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_AnyScalar__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_AnyScalar__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_AnyScalar__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "Bool": return _Bool__Prototype{} @@ -507,10 +507,10 @@ func (ma *_AnyScalar__Assembler) ValuePrototype(k string) ipld.NodePrototype { type _AnyScalar__KeyAssembler _AnyScalar__Assembler -func (_AnyScalar__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_AnyScalar__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.AnyScalar.KeyAssembler"}.BeginMap(0) } -func (_AnyScalar__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_AnyScalar__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.AnyScalar.KeyAssembler"}.BeginList(0) } func (na *_AnyScalar__KeyAssembler) AssignNull() error { @@ -559,67 +559,67 @@ func (ka *_AnyScalar__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.AnyScalar", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.AnyScalar", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_AnyScalar__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.AnyScalar.KeyAssembler"}.AssignBytes(nil) } -func (_AnyScalar__KeyAssembler) AssignLink(ipld.Link) error { +func (_AnyScalar__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.AnyScalar.KeyAssembler"}.AssignLink(nil) } -func (ka *_AnyScalar__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_AnyScalar__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_AnyScalar__KeyAssembler) Prototype() ipld.NodePrototype { +func (_AnyScalar__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (AnyScalar) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n AnyScalar) Representation() ipld.Node { +func (n AnyScalar) Representation() datamodel.Node { return (*_AnyScalar__Repr)(n) } type _AnyScalar__Repr _AnyScalar -var _ ipld.Node = &_AnyScalar__Repr{} +var _ datamodel.Node = &_AnyScalar__Repr{} -func (n *_AnyScalar__Repr) Kind() ipld.Kind { +func (n *_AnyScalar__Repr) Kind() datamodel.Kind { switch n.tag { case 1: - return ipld.Kind_Bool + return datamodel.Kind_Bool case 2: - return ipld.Kind_String + return datamodel.Kind_String case 3: - return ipld.Kind_Bytes + return datamodel.Kind_Bytes case 4: - return ipld.Kind_Int + return datamodel.Kind_Int case 5: - return ipld.Kind_Float + return datamodel.Kind_Float default: panic("unreachable") } } -func (n *_AnyScalar__Repr) LookupByString(key string) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: n.Kind()} +func (n *_AnyScalar__Repr) LookupByString(key string) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: n.Kind()} } -func (n *_AnyScalar__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_Recursive, ActualKind: n.Kind()} +func (n *_AnyScalar__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: n.Kind()} } -func (n *_AnyScalar__Repr) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: n.Kind()} +func (n *_AnyScalar__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: n.Kind()} } -func (n *_AnyScalar__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: n.Kind()} +func (n *_AnyScalar__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: n.Kind()} } -func (n *_AnyScalar__Repr) MapIterator() ipld.MapIterator { +func (n *_AnyScalar__Repr) MapIterator() datamodel.MapIterator { return nil } -func (n *_AnyScalar__Repr) ListIterator() ipld.ListIterator { +func (n *_AnyScalar__Repr) ListIterator() datamodel.ListIterator { return nil } func (n *_AnyScalar__Repr) Length() int64 { @@ -636,7 +636,7 @@ func (n *_AnyScalar__Repr) AsBool() (bool, error) { case 1: return n.x1.Representation().AsBool() default: - return false, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: n.Kind()} + return false, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: n.Kind()} } } func (n *_AnyScalar__Repr) AsInt() (int64, error) { @@ -644,7 +644,7 @@ func (n *_AnyScalar__Repr) AsInt() (int64, error) { case 4: return n.x4.Representation().AsInt() default: - return 0, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: n.Kind()} + return 0, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: n.Kind()} } } func (n *_AnyScalar__Repr) AsFloat() (float64, error) { @@ -652,7 +652,7 @@ func (n *_AnyScalar__Repr) AsFloat() (float64, error) { case 5: return n.x5.Representation().AsFloat() default: - return 0, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: n.Kind()} + return 0, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: n.Kind()} } } func (n *_AnyScalar__Repr) AsString() (string, error) { @@ -660,7 +660,7 @@ func (n *_AnyScalar__Repr) AsString() (string, error) { case 2: return n.x2.Representation().AsString() default: - return "", ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: n.Kind()} + return "", datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: n.Kind()} } } func (n *_AnyScalar__Repr) AsBytes() ([]byte, error) { @@ -668,19 +668,19 @@ func (n *_AnyScalar__Repr) AsBytes() ([]byte, error) { case 3: return n.x3.Representation().AsBytes() default: - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: n.Kind()} + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: n.Kind()} } } -func (n *_AnyScalar__Repr) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: n.Kind()} +func (n *_AnyScalar__Repr) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.AnyScalar.Repr", MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: n.Kind()} } -func (_AnyScalar__Repr) Prototype() ipld.NodePrototype { +func (_AnyScalar__Repr) Prototype() datamodel.NodePrototype { return _AnyScalar__ReprPrototype{} } type _AnyScalar__ReprPrototype struct{} -func (_AnyScalar__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_AnyScalar__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _AnyScalar__ReprBuilder nb.Reset() return &nb @@ -690,7 +690,7 @@ type _AnyScalar__ReprBuilder struct { _AnyScalar__ReprAssembler } -func (nb *_AnyScalar__ReprBuilder) Build() ipld.Node { +func (nb *_AnyScalar__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -732,7 +732,7 @@ func (na *_AnyScalar__ReprAssembler) reset() { } na.ca = 0 } -func (na *_AnyScalar__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_AnyScalar__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -741,7 +741,7 @@ func (na *_AnyScalar__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler } return nil, schema.ErrNotUnionStructure{TypeName: "schemadmt.AnyScalar.Repr", Detail: "BeginMap called but is not valid for any of the kinds that are valid members of this union"} } -func (na *_AnyScalar__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *_AnyScalar__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -839,7 +839,7 @@ func (na *_AnyScalar__ReprAssembler) AssignBytes(v []byte) error { na.ca3.m = na.m return na.ca3.AssignBytes(v) } -func (na *_AnyScalar__ReprAssembler) AssignLink(v ipld.Link) error { +func (na *_AnyScalar__ReprAssembler) AssignLink(v datamodel.Link) error { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -848,7 +848,7 @@ func (na *_AnyScalar__ReprAssembler) AssignLink(v ipld.Link) error { } return schema.ErrNotUnionStructure{TypeName: "schemadmt.AnyScalar.Repr", Detail: "AssignLink called but is not valid for any of the kinds that are valid members of this union"} } -func (na *_AnyScalar__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_AnyScalar__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -869,22 +869,22 @@ func (na *_AnyScalar__ReprAssembler) AssignNode(v ipld.Node) error { return nil } switch v.Kind() { - case ipld.Kind_Bool: + case datamodel.Kind_Bool: v2, _ := v.AsBool() return na.AssignBool(v2) - case ipld.Kind_Int: + case datamodel.Kind_Int: v2, _ := v.AsInt() return na.AssignInt(v2) - case ipld.Kind_Float: + case datamodel.Kind_Float: v2, _ := v.AsFloat() return na.AssignFloat(v2) - case ipld.Kind_String: + case datamodel.Kind_String: v2, _ := v.AsString() return na.AssignString(v2) - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: v2, _ := v.AsBytes() return na.AssignBytes(v2) - case ipld.Kind_Map: + case datamodel.Kind_Map: na, err := na.BeginMap(v.Length()) if err != nil { return err @@ -903,7 +903,7 @@ func (na *_AnyScalar__ReprAssembler) AssignNode(v ipld.Node) error { } } return na.Finish() - case ipld.Kind_List: + case datamodel.Kind_List: na, err := na.BeginList(v.Length()) if err != nil { return err @@ -919,14 +919,14 @@ func (na *_AnyScalar__ReprAssembler) AssignNode(v ipld.Node) error { } } return na.Finish() - case ipld.Kind_Link: + case datamodel.Kind_Link: v2, _ := v.AsLink() return na.AssignLink(v2) default: panic("unreachable") } } -func (na *_AnyScalar__ReprAssembler) Prototype() ipld.NodePrototype { +func (na *_AnyScalar__ReprAssembler) Prototype() datamodel.NodePrototype { return _AnyScalar__ReprPrototype{} } @@ -953,12 +953,12 @@ func (m MaybeBool) IsAbsent() bool { func (m MaybeBool) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeBool) AsNode() ipld.Node { +func (m MaybeBool) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -972,28 +972,28 @@ func (m MaybeBool) Must() Bool { return &m.v } -var _ ipld.Node = (Bool)(&_Bool{}) +var _ datamodel.Node = (Bool)(&_Bool{}) var _ schema.TypedNode = (Bool)(&_Bool{}) -func (Bool) Kind() ipld.Kind { - return ipld.Kind_Bool +func (Bool) Kind() datamodel.Kind { + return datamodel.Kind_Bool } -func (Bool) LookupByString(string) (ipld.Node, error) { +func (Bool) LookupByString(string) (datamodel.Node, error) { return mixins.Bool{TypeName: "schemadmt.Bool"}.LookupByString("") } -func (Bool) LookupByNode(ipld.Node) (ipld.Node, error) { +func (Bool) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.Bool{TypeName: "schemadmt.Bool"}.LookupByNode(nil) } -func (Bool) LookupByIndex(idx int64) (ipld.Node, error) { +func (Bool) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Bool{TypeName: "schemadmt.Bool"}.LookupByIndex(0) } -func (Bool) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (Bool) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Bool{TypeName: "schemadmt.Bool"}.LookupBySegment(seg) } -func (Bool) MapIterator() ipld.MapIterator { +func (Bool) MapIterator() datamodel.MapIterator { return nil } -func (Bool) ListIterator() ipld.ListIterator { +func (Bool) ListIterator() datamodel.ListIterator { return nil } func (Bool) Length() int64 { @@ -1020,16 +1020,16 @@ func (Bool) AsString() (string, error) { func (Bool) AsBytes() ([]byte, error) { return mixins.Bool{TypeName: "schemadmt.Bool"}.AsBytes() } -func (Bool) AsLink() (ipld.Link, error) { +func (Bool) AsLink() (datamodel.Link, error) { return mixins.Bool{TypeName: "schemadmt.Bool"}.AsLink() } -func (Bool) Prototype() ipld.NodePrototype { +func (Bool) Prototype() datamodel.NodePrototype { return _Bool__Prototype{} } type _Bool__Prototype struct{} -func (_Bool__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Bool__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Bool__Builder nb.Reset() return &nb @@ -1039,7 +1039,7 @@ type _Bool__Builder struct { _Bool__Assembler } -func (nb *_Bool__Builder) Build() ipld.Node { +func (nb *_Bool__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -1057,10 +1057,10 @@ type _Bool__Assembler struct { } func (na *_Bool__Assembler) reset() {} -func (_Bool__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Bool__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.BoolAssembler{TypeName: "schemadmt.Bool"}.BeginMap(0) } -func (_Bool__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Bool__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.BoolAssembler{TypeName: "schemadmt.Bool"}.BeginList(0) } func (na *_Bool__Assembler) AssignNull() error { @@ -1096,10 +1096,10 @@ func (_Bool__Assembler) AssignString(string) error { func (_Bool__Assembler) AssignBytes([]byte) error { return mixins.BoolAssembler{TypeName: "schemadmt.Bool"}.AssignBytes(nil) } -func (_Bool__Assembler) AssignLink(ipld.Link) error { +func (_Bool__Assembler) AssignLink(datamodel.Link) error { return mixins.BoolAssembler{TypeName: "schemadmt.Bool"}.AssignLink(nil) } -func (na *_Bool__Assembler) AssignNode(v ipld.Node) error { +func (na *_Bool__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -1118,19 +1118,19 @@ func (na *_Bool__Assembler) AssignNode(v ipld.Node) error { return na.AssignBool(v2) } } -func (_Bool__Assembler) Prototype() ipld.NodePrototype { +func (_Bool__Assembler) Prototype() datamodel.NodePrototype { return _Bool__Prototype{} } func (Bool) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Bool) Representation() ipld.Node { +func (n Bool) Representation() datamodel.Node { return (*_Bool__Repr)(n) } type _Bool__Repr = _Bool -var _ ipld.Node = &_Bool__Repr{} +var _ datamodel.Node = &_Bool__Repr{} type _Bool__ReprPrototype = _Bool__Prototype type _Bool__ReprAssembler = _Bool__Assembler @@ -1158,12 +1158,12 @@ func (m MaybeBytes) IsAbsent() bool { func (m MaybeBytes) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeBytes) AsNode() ipld.Node { +func (m MaybeBytes) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -1177,28 +1177,28 @@ func (m MaybeBytes) Must() Bytes { return &m.v } -var _ ipld.Node = (Bytes)(&_Bytes{}) +var _ datamodel.Node = (Bytes)(&_Bytes{}) var _ schema.TypedNode = (Bytes)(&_Bytes{}) -func (Bytes) Kind() ipld.Kind { - return ipld.Kind_Bytes +func (Bytes) Kind() datamodel.Kind { + return datamodel.Kind_Bytes } -func (Bytes) LookupByString(string) (ipld.Node, error) { +func (Bytes) LookupByString(string) (datamodel.Node, error) { return mixins.Bytes{TypeName: "schemadmt.Bytes"}.LookupByString("") } -func (Bytes) LookupByNode(ipld.Node) (ipld.Node, error) { +func (Bytes) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.Bytes{TypeName: "schemadmt.Bytes"}.LookupByNode(nil) } -func (Bytes) LookupByIndex(idx int64) (ipld.Node, error) { +func (Bytes) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Bytes{TypeName: "schemadmt.Bytes"}.LookupByIndex(0) } -func (Bytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (Bytes) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Bytes{TypeName: "schemadmt.Bytes"}.LookupBySegment(seg) } -func (Bytes) MapIterator() ipld.MapIterator { +func (Bytes) MapIterator() datamodel.MapIterator { return nil } -func (Bytes) ListIterator() ipld.ListIterator { +func (Bytes) ListIterator() datamodel.ListIterator { return nil } func (Bytes) Length() int64 { @@ -1225,16 +1225,16 @@ func (Bytes) AsString() (string, error) { func (n Bytes) AsBytes() ([]byte, error) { return n.x, nil } -func (Bytes) AsLink() (ipld.Link, error) { +func (Bytes) AsLink() (datamodel.Link, error) { return mixins.Bytes{TypeName: "schemadmt.Bytes"}.AsLink() } -func (Bytes) Prototype() ipld.NodePrototype { +func (Bytes) Prototype() datamodel.NodePrototype { return _Bytes__Prototype{} } type _Bytes__Prototype struct{} -func (_Bytes__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Bytes__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Bytes__Builder nb.Reset() return &nb @@ -1244,7 +1244,7 @@ type _Bytes__Builder struct { _Bytes__Assembler } -func (nb *_Bytes__Builder) Build() ipld.Node { +func (nb *_Bytes__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -1262,10 +1262,10 @@ type _Bytes__Assembler struct { } func (na *_Bytes__Assembler) reset() {} -func (_Bytes__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Bytes__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.BytesAssembler{TypeName: "schemadmt.Bytes"}.BeginMap(0) } -func (_Bytes__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Bytes__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.BytesAssembler{TypeName: "schemadmt.Bytes"}.BeginList(0) } func (na *_Bytes__Assembler) AssignNull() error { @@ -1301,10 +1301,10 @@ func (na *_Bytes__Assembler) AssignBytes(v []byte) error { *na.m = schema.Maybe_Value return nil } -func (_Bytes__Assembler) AssignLink(ipld.Link) error { +func (_Bytes__Assembler) AssignLink(datamodel.Link) error { return mixins.BytesAssembler{TypeName: "schemadmt.Bytes"}.AssignLink(nil) } -func (na *_Bytes__Assembler) AssignNode(v ipld.Node) error { +func (na *_Bytes__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -1323,19 +1323,19 @@ func (na *_Bytes__Assembler) AssignNode(v ipld.Node) error { return na.AssignBytes(v2) } } -func (_Bytes__Assembler) Prototype() ipld.NodePrototype { +func (_Bytes__Assembler) Prototype() datamodel.NodePrototype { return _Bytes__Prototype{} } func (Bytes) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Bytes) Representation() ipld.Node { +func (n Bytes) Representation() datamodel.Node { return (*_Bytes__Repr)(n) } type _Bytes__Repr = _Bytes -var _ ipld.Node = &_Bytes__Repr{} +var _ datamodel.Node = &_Bytes__Repr{} type _Bytes__ReprPrototype = _Bytes__Prototype type _Bytes__ReprAssembler = _Bytes__Assembler @@ -1366,12 +1366,12 @@ func (m MaybeEnumRepresentation) IsAbsent() bool { func (m MaybeEnumRepresentation) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeEnumRepresentation) AsNode() ipld.Node { +func (m MaybeEnumRepresentation) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -1389,42 +1389,42 @@ var ( memberName__EnumRepresentation_EnumRepresentation_String = _String{"EnumRepresentation_String"} memberName__EnumRepresentation_EnumRepresentation_Int = _String{"EnumRepresentation_Int"} ) -var _ ipld.Node = (EnumRepresentation)(&_EnumRepresentation{}) +var _ datamodel.Node = (EnumRepresentation)(&_EnumRepresentation{}) var _ schema.TypedNode = (EnumRepresentation)(&_EnumRepresentation{}) -func (EnumRepresentation) Kind() ipld.Kind { - return ipld.Kind_Map +func (EnumRepresentation) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n EnumRepresentation) LookupByString(key string) (ipld.Node, error) { +func (n EnumRepresentation) LookupByString(key string) (datamodel.Node, error) { switch key { case "EnumRepresentation_String": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "EnumRepresentation_Int": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n EnumRepresentation) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n EnumRepresentation) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (EnumRepresentation) LookupByIndex(idx int64) (ipld.Node, error) { +func (EnumRepresentation) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation"}.LookupByIndex(0) } -func (n EnumRepresentation) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n EnumRepresentation) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n EnumRepresentation) MapIterator() ipld.MapIterator { +func (n EnumRepresentation) MapIterator() datamodel.MapIterator { return &_EnumRepresentation__MapItr{n, false} } @@ -1433,9 +1433,9 @@ type _EnumRepresentation__MapItr struct { done bool } -func (itr *_EnumRepresentation__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_EnumRepresentation__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -1452,7 +1452,7 @@ func (itr *_EnumRepresentation__MapItr) Done() bool { return itr.done } -func (EnumRepresentation) ListIterator() ipld.ListIterator { +func (EnumRepresentation) ListIterator() datamodel.ListIterator { return nil } func (EnumRepresentation) Length() int64 { @@ -1479,16 +1479,16 @@ func (EnumRepresentation) AsString() (string, error) { func (EnumRepresentation) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation"}.AsBytes() } -func (EnumRepresentation) AsLink() (ipld.Link, error) { +func (EnumRepresentation) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation"}.AsLink() } -func (EnumRepresentation) Prototype() ipld.NodePrototype { +func (EnumRepresentation) Prototype() datamodel.NodePrototype { return _EnumRepresentation__Prototype{} } type _EnumRepresentation__Prototype struct{} -func (_EnumRepresentation__Prototype) NewBuilder() ipld.NodeBuilder { +func (_EnumRepresentation__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumRepresentation__Builder nb.Reset() return &nb @@ -1498,7 +1498,7 @@ type _EnumRepresentation__Builder struct { _EnumRepresentation__Assembler } -func (nb *_EnumRepresentation__Builder) Build() ipld.Node { +func (nb *_EnumRepresentation__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -1538,7 +1538,7 @@ func (na *_EnumRepresentation__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_EnumRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_EnumRepresentation__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -1551,7 +1551,7 @@ func (na *_EnumRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, er } return na, nil } -func (_EnumRepresentation__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation"}.BeginList(0) } func (na *_EnumRepresentation__Assembler) AssignNull() error { @@ -1583,10 +1583,10 @@ func (_EnumRepresentation__Assembler) AssignString(string) error { func (_EnumRepresentation__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation"}.AssignBytes(nil) } -func (_EnumRepresentation__Assembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation"}.AssignLink(nil) } -func (na *_EnumRepresentation__Assembler) AssignNode(v ipld.Node) error { +func (na *_EnumRepresentation__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -1606,8 +1606,8 @@ func (na *_EnumRepresentation__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -1624,7 +1624,7 @@ func (na *_EnumRepresentation__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_EnumRepresentation__Assembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation__Assembler) Prototype() datamodel.NodePrototype { return _EnumRepresentation__Prototype{} } func (ma *_EnumRepresentation__Assembler) valueFinishTidy() bool { @@ -1636,7 +1636,7 @@ func (ma *_EnumRepresentation__Assembler) valueFinishTidy() bool { return false } } -func (ma *_EnumRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_EnumRepresentation__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -1670,9 +1670,9 @@ func (ma *_EnumRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAsse ma.ca2.m = &ma.cm return &ma.ca2, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation", Key: &_String{k}} } -func (ma *_EnumRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_EnumRepresentation__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -1690,7 +1690,7 @@ func (ma *_EnumRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_EnumRepresentation__KeyAssembler)(ma) } -func (ma *_EnumRepresentation__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_EnumRepresentation__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -1739,10 +1739,10 @@ func (ma *_EnumRepresentation__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_EnumRepresentation__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_EnumRepresentation__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_EnumRepresentation__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_EnumRepresentation__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "EnumRepresentation_String": return _EnumRepresentation_String__Prototype{} @@ -1755,10 +1755,10 @@ func (ma *_EnumRepresentation__Assembler) ValuePrototype(k string) ipld.NodeProt type _EnumRepresentation__KeyAssembler _EnumRepresentation__Assembler -func (_EnumRepresentation__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_EnumRepresentation__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.KeyAssembler"}.BeginMap(0) } -func (_EnumRepresentation__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.KeyAssembler"}.BeginList(0) } func (na *_EnumRepresentation__KeyAssembler) AssignNull() error { @@ -1792,28 +1792,28 @@ func (ka *_EnumRepresentation__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_EnumRepresentation__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.KeyAssembler"}.AssignBytes(nil) } -func (_EnumRepresentation__KeyAssembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.KeyAssembler"}.AssignLink(nil) } -func (ka *_EnumRepresentation__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_EnumRepresentation__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_EnumRepresentation__KeyAssembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (EnumRepresentation) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n EnumRepresentation) Representation() ipld.Node { +func (n EnumRepresentation) Representation() datamodel.Node { return (*_EnumRepresentation__Repr)(n) } @@ -1823,41 +1823,41 @@ var ( memberName__EnumRepresentation_EnumRepresentation_String_serial = _String{"string"} memberName__EnumRepresentation_EnumRepresentation_Int_serial = _String{"int"} ) -var _ ipld.Node = &_EnumRepresentation__Repr{} +var _ datamodel.Node = &_EnumRepresentation__Repr{} -func (_EnumRepresentation__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_EnumRepresentation__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_EnumRepresentation__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_EnumRepresentation__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "string": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x1.Representation(), nil case "int": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x2.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_EnumRepresentation__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_EnumRepresentation__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_EnumRepresentation__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_EnumRepresentation__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation.Repr"}.LookupByIndex(0) } -func (n _EnumRepresentation__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _EnumRepresentation__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_EnumRepresentation__Repr) MapIterator() ipld.MapIterator { +func (n *_EnumRepresentation__Repr) MapIterator() datamodel.MapIterator { return &_EnumRepresentation__ReprMapItr{n, false} } @@ -1866,9 +1866,9 @@ type _EnumRepresentation__ReprMapItr struct { done bool } -func (itr *_EnumRepresentation__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_EnumRepresentation__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -1885,7 +1885,7 @@ func (itr *_EnumRepresentation__ReprMapItr) Done() bool { return itr.done } -func (_EnumRepresentation__Repr) ListIterator() ipld.ListIterator { +func (_EnumRepresentation__Repr) ListIterator() datamodel.ListIterator { return nil } func (_EnumRepresentation__Repr) Length() int64 { @@ -1912,16 +1912,16 @@ func (_EnumRepresentation__Repr) AsString() (string, error) { func (_EnumRepresentation__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation.Repr"}.AsBytes() } -func (_EnumRepresentation__Repr) AsLink() (ipld.Link, error) { +func (_EnumRepresentation__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation.Repr"}.AsLink() } -func (_EnumRepresentation__Repr) Prototype() ipld.NodePrototype { +func (_EnumRepresentation__Repr) Prototype() datamodel.NodePrototype { return _EnumRepresentation__ReprPrototype{} } type _EnumRepresentation__ReprPrototype struct{} -func (_EnumRepresentation__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_EnumRepresentation__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumRepresentation__ReprBuilder nb.Reset() return &nb @@ -1931,7 +1931,7 @@ type _EnumRepresentation__ReprBuilder struct { _EnumRepresentation__ReprAssembler } -func (nb *_EnumRepresentation__ReprBuilder) Build() ipld.Node { +func (nb *_EnumRepresentation__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -1971,7 +1971,7 @@ func (na *_EnumRepresentation__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_EnumRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_EnumRepresentation__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -1984,7 +1984,7 @@ func (na *_EnumRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler } return na, nil } -func (_EnumRepresentation__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation.Repr"}.BeginList(0) } func (na *_EnumRepresentation__ReprAssembler) AssignNull() error { @@ -2016,10 +2016,10 @@ func (_EnumRepresentation__ReprAssembler) AssignString(string) error { func (_EnumRepresentation__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation.Repr"}.AssignBytes(nil) } -func (_EnumRepresentation__ReprAssembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation.Repr"}.AssignLink(nil) } -func (na *_EnumRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_EnumRepresentation__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -2039,8 +2039,8 @@ func (na *_EnumRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -2057,7 +2057,7 @@ func (na *_EnumRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_EnumRepresentation__ReprAssembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation__ReprAssembler) Prototype() datamodel.NodePrototype { return _EnumRepresentation__ReprPrototype{} } func (ma *_EnumRepresentation__ReprAssembler) valueFinishTidy() bool { @@ -2069,7 +2069,7 @@ func (ma *_EnumRepresentation__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_EnumRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_EnumRepresentation__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -2103,9 +2103,9 @@ func (ma *_EnumRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.Node ma.ca2.m = &ma.cm return &ma.ca2, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation.Repr", Key: &_String{k}} } -func (ma *_EnumRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_EnumRepresentation__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -2123,7 +2123,7 @@ func (ma *_EnumRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_EnumRepresentation__ReprKeyAssembler)(ma) } -func (ma *_EnumRepresentation__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_EnumRepresentation__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -2172,10 +2172,10 @@ func (ma *_EnumRepresentation__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_EnumRepresentation__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_EnumRepresentation__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_EnumRepresentation__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_EnumRepresentation__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "EnumRepresentation_String": return _EnumRepresentation_String__ReprPrototype{} @@ -2188,10 +2188,10 @@ func (ma *_EnumRepresentation__ReprAssembler) ValuePrototype(k string) ipld.Node type _EnumRepresentation__ReprKeyAssembler _EnumRepresentation__ReprAssembler -func (_EnumRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_EnumRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.Repr.KeyAssembler"}.BeginMap(0) } -func (_EnumRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.Repr.KeyAssembler"}.BeginList(0) } func (na *_EnumRepresentation__ReprKeyAssembler) AssignNull() error { @@ -2225,22 +2225,22 @@ func (ka *_EnumRepresentation__ReprKeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.EnumRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_EnumRepresentation__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_EnumRepresentation__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.EnumRepresentation.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_EnumRepresentation__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_EnumRepresentation__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_EnumRepresentation__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -2302,12 +2302,12 @@ func (m MaybeEnumRepresentation_Int) IsAbsent() bool { func (m MaybeEnumRepresentation_Int) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeEnumRepresentation_Int) AsNode() ipld.Node { +func (m MaybeEnumRepresentation_Int) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -2321,42 +2321,42 @@ func (m MaybeEnumRepresentation_Int) Must() EnumRepresentation_Int { return &m.v } -var _ ipld.Node = (EnumRepresentation_Int)(&_EnumRepresentation_Int{}) +var _ datamodel.Node = (EnumRepresentation_Int)(&_EnumRepresentation_Int{}) var _ schema.TypedNode = (EnumRepresentation_Int)(&_EnumRepresentation_Int{}) -func (EnumRepresentation_Int) Kind() ipld.Kind { - return ipld.Kind_Map +func (EnumRepresentation_Int) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n EnumRepresentation_Int) LookupByString(k string) (ipld.Node, error) { +func (n EnumRepresentation_Int) LookupByString(k string) (datamodel.Node, error) { var k2 _EnumValue if err := (_EnumValue__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n EnumRepresentation_Int) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n EnumRepresentation_Int) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(EnumValue) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.EnumRepresentation_Int", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.EnumRepresentation_Int", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (EnumRepresentation_Int) LookupByIndex(idx int64) (ipld.Node, error) { +func (EnumRepresentation_Int) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_Int"}.LookupByIndex(0) } -func (n EnumRepresentation_Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n EnumRepresentation_Int) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n EnumRepresentation_Int) MapIterator() ipld.MapIterator { +func (n EnumRepresentation_Int) MapIterator() datamodel.MapIterator { return &_EnumRepresentation_Int__MapItr{n, 0} } @@ -2365,9 +2365,9 @@ type _EnumRepresentation_Int__MapItr struct { idx int } -func (itr *_EnumRepresentation_Int__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_EnumRepresentation_Int__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -2379,7 +2379,7 @@ func (itr *_EnumRepresentation_Int__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (EnumRepresentation_Int) ListIterator() ipld.ListIterator { +func (EnumRepresentation_Int) ListIterator() datamodel.ListIterator { return nil } func (n EnumRepresentation_Int) Length() int64 { @@ -2406,16 +2406,16 @@ func (EnumRepresentation_Int) AsString() (string, error) { func (EnumRepresentation_Int) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_Int"}.AsBytes() } -func (EnumRepresentation_Int) AsLink() (ipld.Link, error) { +func (EnumRepresentation_Int) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_Int"}.AsLink() } -func (EnumRepresentation_Int) Prototype() ipld.NodePrototype { +func (EnumRepresentation_Int) Prototype() datamodel.NodePrototype { return _EnumRepresentation_Int__Prototype{} } type _EnumRepresentation_Int__Prototype struct{} -func (_EnumRepresentation_Int__Prototype) NewBuilder() ipld.NodeBuilder { +func (_EnumRepresentation_Int__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumRepresentation_Int__Builder nb.Reset() return &nb @@ -2425,7 +2425,7 @@ type _EnumRepresentation_Int__Builder struct { _EnumRepresentation_Int__Assembler } -func (nb *_EnumRepresentation_Int__Builder) Build() ipld.Node { +func (nb *_EnumRepresentation_Int__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -2452,7 +2452,7 @@ func (na *_EnumRepresentation_Int__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_EnumRepresentation_Int__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_EnumRepresentation_Int__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -2467,7 +2467,7 @@ func (na *_EnumRepresentation_Int__Assembler) BeginMap(sizeHint int64) (ipld.Map na.w.t = make([]_EnumRepresentation_Int__entry, 0, sizeHint) return na, nil } -func (_EnumRepresentation_Int__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation_Int__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_Int"}.BeginList(0) } func (na *_EnumRepresentation_Int__Assembler) AssignNull() error { @@ -2499,10 +2499,10 @@ func (_EnumRepresentation_Int__Assembler) AssignString(string) error { func (_EnumRepresentation_Int__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_Int"}.AssignBytes(nil) } -func (_EnumRepresentation_Int__Assembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation_Int__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_Int"}.AssignLink(nil) } -func (na *_EnumRepresentation_Int__Assembler) AssignNode(v ipld.Node) error { +func (na *_EnumRepresentation_Int__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -2517,8 +2517,8 @@ func (na *_EnumRepresentation_Int__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_Int", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_Int", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -2535,7 +2535,7 @@ func (na *_EnumRepresentation_Int__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_EnumRepresentation_Int__Assembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation_Int__Assembler) Prototype() datamodel.NodePrototype { return _EnumRepresentation_Int__Prototype{} } func (ma *_EnumRepresentation_Int__Assembler) keyFinishTidy() bool { @@ -2566,7 +2566,7 @@ func (ma *_EnumRepresentation_Int__Assembler) valueFinishTidy() bool { return false } } -func (ma *_EnumRepresentation_Int__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_EnumRepresentation_Int__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -2587,7 +2587,7 @@ func (ma *_EnumRepresentation_Int__Assembler) AssembleEntry(k string) (ipld.Node return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _EnumRepresentation_Int__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -2598,7 +2598,7 @@ func (ma *_EnumRepresentation_Int__Assembler) AssembleEntry(k string) (ipld.Node ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_EnumRepresentation_Int__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_EnumRepresentation_Int__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -2619,7 +2619,7 @@ func (ma *_EnumRepresentation_Int__Assembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_EnumRepresentation_Int__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_EnumRepresentation_Int__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -2656,55 +2656,55 @@ func (ma *_EnumRepresentation_Int__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_EnumRepresentation_Int__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_EnumRepresentation_Int__Assembler) KeyPrototype() datamodel.NodePrototype { return _EnumValue__Prototype{} } -func (ma *_EnumRepresentation_Int__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_EnumRepresentation_Int__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Int__Prototype{} } func (EnumRepresentation_Int) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n EnumRepresentation_Int) Representation() ipld.Node { +func (n EnumRepresentation_Int) Representation() datamodel.Node { return (*_EnumRepresentation_Int__Repr)(n) } type _EnumRepresentation_Int__Repr _EnumRepresentation_Int -var _ ipld.Node = &_EnumRepresentation_Int__Repr{} +var _ datamodel.Node = &_EnumRepresentation_Int__Repr{} -func (_EnumRepresentation_Int__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_EnumRepresentation_Int__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_EnumRepresentation_Int__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_EnumRepresentation_Int__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (EnumRepresentation_Int)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Int).Representation(), nil } -func (nr *_EnumRepresentation_Int__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_EnumRepresentation_Int__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (EnumRepresentation_Int)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Int).Representation(), nil } -func (_EnumRepresentation_Int__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_EnumRepresentation_Int__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_Int.Repr"}.LookupByIndex(0) } -func (n _EnumRepresentation_Int__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _EnumRepresentation_Int__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_EnumRepresentation_Int__Repr) MapIterator() ipld.MapIterator { +func (nr *_EnumRepresentation_Int__Repr) MapIterator() datamodel.MapIterator { return &_EnumRepresentation_Int__ReprMapItr{(EnumRepresentation_Int)(nr), 0} } type _EnumRepresentation_Int__ReprMapItr _EnumRepresentation_Int__MapItr -func (itr *_EnumRepresentation_Int__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_EnumRepresentation_Int__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_EnumRepresentation_Int__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(Int).Representation(), nil @@ -2713,7 +2713,7 @@ func (itr *_EnumRepresentation_Int__ReprMapItr) Done() bool { return (*_EnumRepresentation_Int__MapItr)(itr).Done() } -func (_EnumRepresentation_Int__Repr) ListIterator() ipld.ListIterator { +func (_EnumRepresentation_Int__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_EnumRepresentation_Int__Repr) Length() int64 { @@ -2740,16 +2740,16 @@ func (_EnumRepresentation_Int__Repr) AsString() (string, error) { func (_EnumRepresentation_Int__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_Int.Repr"}.AsBytes() } -func (_EnumRepresentation_Int__Repr) AsLink() (ipld.Link, error) { +func (_EnumRepresentation_Int__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_Int.Repr"}.AsLink() } -func (_EnumRepresentation_Int__Repr) Prototype() ipld.NodePrototype { +func (_EnumRepresentation_Int__Repr) Prototype() datamodel.NodePrototype { return _EnumRepresentation_Int__ReprPrototype{} } type _EnumRepresentation_Int__ReprPrototype struct{} -func (_EnumRepresentation_Int__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_EnumRepresentation_Int__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumRepresentation_Int__ReprBuilder nb.Reset() return &nb @@ -2759,7 +2759,7 @@ type _EnumRepresentation_Int__ReprBuilder struct { _EnumRepresentation_Int__ReprAssembler } -func (nb *_EnumRepresentation_Int__ReprBuilder) Build() ipld.Node { +func (nb *_EnumRepresentation_Int__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -2786,7 +2786,7 @@ func (na *_EnumRepresentation_Int__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_EnumRepresentation_Int__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_EnumRepresentation_Int__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -2801,7 +2801,7 @@ func (na *_EnumRepresentation_Int__ReprAssembler) BeginMap(sizeHint int64) (ipld na.w.t = make([]_EnumRepresentation_Int__entry, 0, sizeHint) return na, nil } -func (_EnumRepresentation_Int__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation_Int__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_Int.Repr"}.BeginList(0) } func (na *_EnumRepresentation_Int__ReprAssembler) AssignNull() error { @@ -2833,10 +2833,10 @@ func (_EnumRepresentation_Int__ReprAssembler) AssignString(string) error { func (_EnumRepresentation_Int__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_Int.Repr"}.AssignBytes(nil) } -func (_EnumRepresentation_Int__ReprAssembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation_Int__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_Int.Repr"}.AssignLink(nil) } -func (na *_EnumRepresentation_Int__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_EnumRepresentation_Int__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -2851,8 +2851,8 @@ func (na *_EnumRepresentation_Int__ReprAssembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_Int.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_Int.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -2869,7 +2869,7 @@ func (na *_EnumRepresentation_Int__ReprAssembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_EnumRepresentation_Int__ReprAssembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation_Int__ReprAssembler) Prototype() datamodel.NodePrototype { return _EnumRepresentation_Int__ReprPrototype{} } func (ma *_EnumRepresentation_Int__ReprAssembler) keyFinishTidy() bool { @@ -2900,7 +2900,7 @@ func (ma *_EnumRepresentation_Int__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -2921,7 +2921,7 @@ func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleEntry(k string) (ipld. return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _EnumRepresentation_Int__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -2932,7 +2932,7 @@ func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleEntry(k string) (ipld. ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -2953,7 +2953,7 @@ func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleKey() ipld.NodeAssembl ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_EnumRepresentation_Int__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -2990,10 +2990,10 @@ func (ma *_EnumRepresentation_Int__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_EnumRepresentation_Int__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_EnumRepresentation_Int__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _EnumValue__ReprPrototype{} } -func (ma *_EnumRepresentation_Int__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_EnumRepresentation_Int__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Int__ReprPrototype{} } @@ -3055,12 +3055,12 @@ func (m MaybeEnumRepresentation_String) IsAbsent() bool { func (m MaybeEnumRepresentation_String) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeEnumRepresentation_String) AsNode() ipld.Node { +func (m MaybeEnumRepresentation_String) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -3074,42 +3074,42 @@ func (m MaybeEnumRepresentation_String) Must() EnumRepresentation_String { return &m.v } -var _ ipld.Node = (EnumRepresentation_String)(&_EnumRepresentation_String{}) +var _ datamodel.Node = (EnumRepresentation_String)(&_EnumRepresentation_String{}) var _ schema.TypedNode = (EnumRepresentation_String)(&_EnumRepresentation_String{}) -func (EnumRepresentation_String) Kind() ipld.Kind { - return ipld.Kind_Map +func (EnumRepresentation_String) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n EnumRepresentation_String) LookupByString(k string) (ipld.Node, error) { +func (n EnumRepresentation_String) LookupByString(k string) (datamodel.Node, error) { var k2 _EnumValue if err := (_EnumValue__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n EnumRepresentation_String) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n EnumRepresentation_String) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(EnumValue) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.EnumRepresentation_String", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.EnumRepresentation_String", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (EnumRepresentation_String) LookupByIndex(idx int64) (ipld.Node, error) { +func (EnumRepresentation_String) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_String"}.LookupByIndex(0) } -func (n EnumRepresentation_String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n EnumRepresentation_String) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n EnumRepresentation_String) MapIterator() ipld.MapIterator { +func (n EnumRepresentation_String) MapIterator() datamodel.MapIterator { return &_EnumRepresentation_String__MapItr{n, 0} } @@ -3118,9 +3118,9 @@ type _EnumRepresentation_String__MapItr struct { idx int } -func (itr *_EnumRepresentation_String__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_EnumRepresentation_String__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -3132,7 +3132,7 @@ func (itr *_EnumRepresentation_String__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (EnumRepresentation_String) ListIterator() ipld.ListIterator { +func (EnumRepresentation_String) ListIterator() datamodel.ListIterator { return nil } func (n EnumRepresentation_String) Length() int64 { @@ -3159,16 +3159,16 @@ func (EnumRepresentation_String) AsString() (string, error) { func (EnumRepresentation_String) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_String"}.AsBytes() } -func (EnumRepresentation_String) AsLink() (ipld.Link, error) { +func (EnumRepresentation_String) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_String"}.AsLink() } -func (EnumRepresentation_String) Prototype() ipld.NodePrototype { +func (EnumRepresentation_String) Prototype() datamodel.NodePrototype { return _EnumRepresentation_String__Prototype{} } type _EnumRepresentation_String__Prototype struct{} -func (_EnumRepresentation_String__Prototype) NewBuilder() ipld.NodeBuilder { +func (_EnumRepresentation_String__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumRepresentation_String__Builder nb.Reset() return &nb @@ -3178,7 +3178,7 @@ type _EnumRepresentation_String__Builder struct { _EnumRepresentation_String__Assembler } -func (nb *_EnumRepresentation_String__Builder) Build() ipld.Node { +func (nb *_EnumRepresentation_String__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -3205,7 +3205,7 @@ func (na *_EnumRepresentation_String__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_EnumRepresentation_String__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_EnumRepresentation_String__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -3220,7 +3220,7 @@ func (na *_EnumRepresentation_String__Assembler) BeginMap(sizeHint int64) (ipld. na.w.t = make([]_EnumRepresentation_String__entry, 0, sizeHint) return na, nil } -func (_EnumRepresentation_String__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation_String__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_String"}.BeginList(0) } func (na *_EnumRepresentation_String__Assembler) AssignNull() error { @@ -3252,10 +3252,10 @@ func (_EnumRepresentation_String__Assembler) AssignString(string) error { func (_EnumRepresentation_String__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_String"}.AssignBytes(nil) } -func (_EnumRepresentation_String__Assembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation_String__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_String"}.AssignLink(nil) } -func (na *_EnumRepresentation_String__Assembler) AssignNode(v ipld.Node) error { +func (na *_EnumRepresentation_String__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -3270,8 +3270,8 @@ func (na *_EnumRepresentation_String__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_String", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_String", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -3288,7 +3288,7 @@ func (na *_EnumRepresentation_String__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_EnumRepresentation_String__Assembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation_String__Assembler) Prototype() datamodel.NodePrototype { return _EnumRepresentation_String__Prototype{} } func (ma *_EnumRepresentation_String__Assembler) keyFinishTidy() bool { @@ -3319,7 +3319,7 @@ func (ma *_EnumRepresentation_String__Assembler) valueFinishTidy() bool { return false } } -func (ma *_EnumRepresentation_String__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_EnumRepresentation_String__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -3340,7 +3340,7 @@ func (ma *_EnumRepresentation_String__Assembler) AssembleEntry(k string) (ipld.N return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _EnumRepresentation_String__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -3351,7 +3351,7 @@ func (ma *_EnumRepresentation_String__Assembler) AssembleEntry(k string) (ipld.N ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_EnumRepresentation_String__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_EnumRepresentation_String__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -3372,7 +3372,7 @@ func (ma *_EnumRepresentation_String__Assembler) AssembleKey() ipld.NodeAssemble ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_EnumRepresentation_String__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_EnumRepresentation_String__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -3409,55 +3409,55 @@ func (ma *_EnumRepresentation_String__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_EnumRepresentation_String__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_EnumRepresentation_String__Assembler) KeyPrototype() datamodel.NodePrototype { return _EnumValue__Prototype{} } -func (ma *_EnumRepresentation_String__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_EnumRepresentation_String__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _String__Prototype{} } func (EnumRepresentation_String) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n EnumRepresentation_String) Representation() ipld.Node { +func (n EnumRepresentation_String) Representation() datamodel.Node { return (*_EnumRepresentation_String__Repr)(n) } type _EnumRepresentation_String__Repr _EnumRepresentation_String -var _ ipld.Node = &_EnumRepresentation_String__Repr{} +var _ datamodel.Node = &_EnumRepresentation_String__Repr{} -func (_EnumRepresentation_String__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_EnumRepresentation_String__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_EnumRepresentation_String__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_EnumRepresentation_String__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (EnumRepresentation_String)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(String).Representation(), nil } -func (nr *_EnumRepresentation_String__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_EnumRepresentation_String__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (EnumRepresentation_String)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(String).Representation(), nil } -func (_EnumRepresentation_String__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_EnumRepresentation_String__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_String.Repr"}.LookupByIndex(0) } -func (n _EnumRepresentation_String__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _EnumRepresentation_String__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_EnumRepresentation_String__Repr) MapIterator() ipld.MapIterator { +func (nr *_EnumRepresentation_String__Repr) MapIterator() datamodel.MapIterator { return &_EnumRepresentation_String__ReprMapItr{(EnumRepresentation_String)(nr), 0} } type _EnumRepresentation_String__ReprMapItr _EnumRepresentation_String__MapItr -func (itr *_EnumRepresentation_String__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_EnumRepresentation_String__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_EnumRepresentation_String__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(String).Representation(), nil @@ -3466,7 +3466,7 @@ func (itr *_EnumRepresentation_String__ReprMapItr) Done() bool { return (*_EnumRepresentation_String__MapItr)(itr).Done() } -func (_EnumRepresentation_String__Repr) ListIterator() ipld.ListIterator { +func (_EnumRepresentation_String__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_EnumRepresentation_String__Repr) Length() int64 { @@ -3493,16 +3493,16 @@ func (_EnumRepresentation_String__Repr) AsString() (string, error) { func (_EnumRepresentation_String__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_String.Repr"}.AsBytes() } -func (_EnumRepresentation_String__Repr) AsLink() (ipld.Link, error) { +func (_EnumRepresentation_String__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.EnumRepresentation_String.Repr"}.AsLink() } -func (_EnumRepresentation_String__Repr) Prototype() ipld.NodePrototype { +func (_EnumRepresentation_String__Repr) Prototype() datamodel.NodePrototype { return _EnumRepresentation_String__ReprPrototype{} } type _EnumRepresentation_String__ReprPrototype struct{} -func (_EnumRepresentation_String__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_EnumRepresentation_String__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumRepresentation_String__ReprBuilder nb.Reset() return &nb @@ -3512,7 +3512,7 @@ type _EnumRepresentation_String__ReprBuilder struct { _EnumRepresentation_String__ReprAssembler } -func (nb *_EnumRepresentation_String__ReprBuilder) Build() ipld.Node { +func (nb *_EnumRepresentation_String__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -3539,7 +3539,7 @@ func (na *_EnumRepresentation_String__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_EnumRepresentation_String__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_EnumRepresentation_String__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -3554,7 +3554,7 @@ func (na *_EnumRepresentation_String__ReprAssembler) BeginMap(sizeHint int64) (i na.w.t = make([]_EnumRepresentation_String__entry, 0, sizeHint) return na, nil } -func (_EnumRepresentation_String__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumRepresentation_String__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_String.Repr"}.BeginList(0) } func (na *_EnumRepresentation_String__ReprAssembler) AssignNull() error { @@ -3586,10 +3586,10 @@ func (_EnumRepresentation_String__ReprAssembler) AssignString(string) error { func (_EnumRepresentation_String__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_String.Repr"}.AssignBytes(nil) } -func (_EnumRepresentation_String__ReprAssembler) AssignLink(ipld.Link) error { +func (_EnumRepresentation_String__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.EnumRepresentation_String.Repr"}.AssignLink(nil) } -func (na *_EnumRepresentation_String__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_EnumRepresentation_String__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -3604,8 +3604,8 @@ func (na *_EnumRepresentation_String__ReprAssembler) AssignNode(v ipld.Node) err *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_String.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.EnumRepresentation_String.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -3622,7 +3622,7 @@ func (na *_EnumRepresentation_String__ReprAssembler) AssignNode(v ipld.Node) err } return na.Finish() } -func (_EnumRepresentation_String__ReprAssembler) Prototype() ipld.NodePrototype { +func (_EnumRepresentation_String__ReprAssembler) Prototype() datamodel.NodePrototype { return _EnumRepresentation_String__ReprPrototype{} } func (ma *_EnumRepresentation_String__ReprAssembler) keyFinishTidy() bool { @@ -3653,7 +3653,7 @@ func (ma *_EnumRepresentation_String__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_EnumRepresentation_String__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_EnumRepresentation_String__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -3674,7 +3674,7 @@ func (ma *_EnumRepresentation_String__ReprAssembler) AssembleEntry(k string) (ip return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _EnumRepresentation_String__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -3685,7 +3685,7 @@ func (ma *_EnumRepresentation_String__ReprAssembler) AssembleEntry(k string) (ip ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_EnumRepresentation_String__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_EnumRepresentation_String__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -3706,7 +3706,7 @@ func (ma *_EnumRepresentation_String__ReprAssembler) AssembleKey() ipld.NodeAsse ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_EnumRepresentation_String__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_EnumRepresentation_String__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -3743,10 +3743,10 @@ func (ma *_EnumRepresentation_String__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_EnumRepresentation_String__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_EnumRepresentation_String__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _EnumValue__ReprPrototype{} } -func (ma *_EnumRepresentation_String__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_EnumRepresentation_String__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _String__ReprPrototype{} } @@ -3777,12 +3777,12 @@ func (m MaybeEnumValue) IsAbsent() bool { func (m MaybeEnumValue) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeEnumValue) AsNode() ipld.Node { +func (m MaybeEnumValue) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -3796,28 +3796,28 @@ func (m MaybeEnumValue) Must() EnumValue { return &m.v } -var _ ipld.Node = (EnumValue)(&_EnumValue{}) +var _ datamodel.Node = (EnumValue)(&_EnumValue{}) var _ schema.TypedNode = (EnumValue)(&_EnumValue{}) -func (EnumValue) Kind() ipld.Kind { - return ipld.Kind_String +func (EnumValue) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (EnumValue) LookupByString(string) (ipld.Node, error) { +func (EnumValue) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.EnumValue"}.LookupByString("") } -func (EnumValue) LookupByNode(ipld.Node) (ipld.Node, error) { +func (EnumValue) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.EnumValue"}.LookupByNode(nil) } -func (EnumValue) LookupByIndex(idx int64) (ipld.Node, error) { +func (EnumValue) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.EnumValue"}.LookupByIndex(0) } -func (EnumValue) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (EnumValue) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.EnumValue"}.LookupBySegment(seg) } -func (EnumValue) MapIterator() ipld.MapIterator { +func (EnumValue) MapIterator() datamodel.MapIterator { return nil } -func (EnumValue) ListIterator() ipld.ListIterator { +func (EnumValue) ListIterator() datamodel.ListIterator { return nil } func (EnumValue) Length() int64 { @@ -3844,16 +3844,16 @@ func (n EnumValue) AsString() (string, error) { func (EnumValue) AsBytes() ([]byte, error) { return mixins.String{TypeName: "schemadmt.EnumValue"}.AsBytes() } -func (EnumValue) AsLink() (ipld.Link, error) { +func (EnumValue) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "schemadmt.EnumValue"}.AsLink() } -func (EnumValue) Prototype() ipld.NodePrototype { +func (EnumValue) Prototype() datamodel.NodePrototype { return _EnumValue__Prototype{} } type _EnumValue__Prototype struct{} -func (_EnumValue__Prototype) NewBuilder() ipld.NodeBuilder { +func (_EnumValue__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _EnumValue__Builder nb.Reset() return &nb @@ -3863,7 +3863,7 @@ type _EnumValue__Builder struct { _EnumValue__Assembler } -func (nb *_EnumValue__Builder) Build() ipld.Node { +func (nb *_EnumValue__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -3881,10 +3881,10 @@ type _EnumValue__Assembler struct { } func (na *_EnumValue__Assembler) reset() {} -func (_EnumValue__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_EnumValue__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.EnumValue"}.BeginMap(0) } -func (_EnumValue__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_EnumValue__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.EnumValue"}.BeginList(0) } func (na *_EnumValue__Assembler) AssignNull() error { @@ -3920,10 +3920,10 @@ func (na *_EnumValue__Assembler) AssignString(v string) error { func (_EnumValue__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.EnumValue"}.AssignBytes(nil) } -func (_EnumValue__Assembler) AssignLink(ipld.Link) error { +func (_EnumValue__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.EnumValue"}.AssignLink(nil) } -func (na *_EnumValue__Assembler) AssignNode(v ipld.Node) error { +func (na *_EnumValue__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -3942,19 +3942,19 @@ func (na *_EnumValue__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_EnumValue__Assembler) Prototype() ipld.NodePrototype { +func (_EnumValue__Assembler) Prototype() datamodel.NodePrototype { return _EnumValue__Prototype{} } func (EnumValue) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n EnumValue) Representation() ipld.Node { +func (n EnumValue) Representation() datamodel.Node { return (*_EnumValue__Repr)(n) } type _EnumValue__Repr = _EnumValue -var _ ipld.Node = &_EnumValue__Repr{} +var _ datamodel.Node = &_EnumValue__Repr{} type _EnumValue__ReprPrototype = _EnumValue__Prototype type _EnumValue__ReprAssembler = _EnumValue__Assembler @@ -3986,12 +3986,12 @@ func (m MaybeFieldName) IsAbsent() bool { func (m MaybeFieldName) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeFieldName) AsNode() ipld.Node { +func (m MaybeFieldName) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -4005,28 +4005,28 @@ func (m MaybeFieldName) Must() FieldName { return &m.v } -var _ ipld.Node = (FieldName)(&_FieldName{}) +var _ datamodel.Node = (FieldName)(&_FieldName{}) var _ schema.TypedNode = (FieldName)(&_FieldName{}) -func (FieldName) Kind() ipld.Kind { - return ipld.Kind_String +func (FieldName) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (FieldName) LookupByString(string) (ipld.Node, error) { +func (FieldName) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.FieldName"}.LookupByString("") } -func (FieldName) LookupByNode(ipld.Node) (ipld.Node, error) { +func (FieldName) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.FieldName"}.LookupByNode(nil) } -func (FieldName) LookupByIndex(idx int64) (ipld.Node, error) { +func (FieldName) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.FieldName"}.LookupByIndex(0) } -func (FieldName) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (FieldName) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.FieldName"}.LookupBySegment(seg) } -func (FieldName) MapIterator() ipld.MapIterator { +func (FieldName) MapIterator() datamodel.MapIterator { return nil } -func (FieldName) ListIterator() ipld.ListIterator { +func (FieldName) ListIterator() datamodel.ListIterator { return nil } func (FieldName) Length() int64 { @@ -4053,16 +4053,16 @@ func (n FieldName) AsString() (string, error) { func (FieldName) AsBytes() ([]byte, error) { return mixins.String{TypeName: "schemadmt.FieldName"}.AsBytes() } -func (FieldName) AsLink() (ipld.Link, error) { +func (FieldName) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "schemadmt.FieldName"}.AsLink() } -func (FieldName) Prototype() ipld.NodePrototype { +func (FieldName) Prototype() datamodel.NodePrototype { return _FieldName__Prototype{} } type _FieldName__Prototype struct{} -func (_FieldName__Prototype) NewBuilder() ipld.NodeBuilder { +func (_FieldName__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _FieldName__Builder nb.Reset() return &nb @@ -4072,7 +4072,7 @@ type _FieldName__Builder struct { _FieldName__Assembler } -func (nb *_FieldName__Builder) Build() ipld.Node { +func (nb *_FieldName__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -4090,10 +4090,10 @@ type _FieldName__Assembler struct { } func (na *_FieldName__Assembler) reset() {} -func (_FieldName__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_FieldName__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.FieldName"}.BeginMap(0) } -func (_FieldName__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_FieldName__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.FieldName"}.BeginList(0) } func (na *_FieldName__Assembler) AssignNull() error { @@ -4129,10 +4129,10 @@ func (na *_FieldName__Assembler) AssignString(v string) error { func (_FieldName__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.FieldName"}.AssignBytes(nil) } -func (_FieldName__Assembler) AssignLink(ipld.Link) error { +func (_FieldName__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.FieldName"}.AssignLink(nil) } -func (na *_FieldName__Assembler) AssignNode(v ipld.Node) error { +func (na *_FieldName__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -4151,19 +4151,19 @@ func (na *_FieldName__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_FieldName__Assembler) Prototype() ipld.NodePrototype { +func (_FieldName__Assembler) Prototype() datamodel.NodePrototype { return _FieldName__Prototype{} } func (FieldName) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n FieldName) Representation() ipld.Node { +func (n FieldName) Representation() datamodel.Node { return (*_FieldName__Repr)(n) } type _FieldName__Repr = _FieldName -var _ ipld.Node = &_FieldName__Repr{} +var _ datamodel.Node = &_FieldName__Repr{} type _FieldName__ReprPrototype = _FieldName__Prototype type _FieldName__ReprAssembler = _FieldName__Assembler @@ -4191,12 +4191,12 @@ func (m MaybeFloat) IsAbsent() bool { func (m MaybeFloat) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeFloat) AsNode() ipld.Node { +func (m MaybeFloat) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -4210,28 +4210,28 @@ func (m MaybeFloat) Must() Float { return &m.v } -var _ ipld.Node = (Float)(&_Float{}) +var _ datamodel.Node = (Float)(&_Float{}) var _ schema.TypedNode = (Float)(&_Float{}) -func (Float) Kind() ipld.Kind { - return ipld.Kind_Float +func (Float) Kind() datamodel.Kind { + return datamodel.Kind_Float } -func (Float) LookupByString(string) (ipld.Node, error) { +func (Float) LookupByString(string) (datamodel.Node, error) { return mixins.Float{TypeName: "schemadmt.Float"}.LookupByString("") } -func (Float) LookupByNode(ipld.Node) (ipld.Node, error) { +func (Float) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.Float{TypeName: "schemadmt.Float"}.LookupByNode(nil) } -func (Float) LookupByIndex(idx int64) (ipld.Node, error) { +func (Float) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Float{TypeName: "schemadmt.Float"}.LookupByIndex(0) } -func (Float) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (Float) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Float{TypeName: "schemadmt.Float"}.LookupBySegment(seg) } -func (Float) MapIterator() ipld.MapIterator { +func (Float) MapIterator() datamodel.MapIterator { return nil } -func (Float) ListIterator() ipld.ListIterator { +func (Float) ListIterator() datamodel.ListIterator { return nil } func (Float) Length() int64 { @@ -4258,16 +4258,16 @@ func (Float) AsString() (string, error) { func (Float) AsBytes() ([]byte, error) { return mixins.Float{TypeName: "schemadmt.Float"}.AsBytes() } -func (Float) AsLink() (ipld.Link, error) { +func (Float) AsLink() (datamodel.Link, error) { return mixins.Float{TypeName: "schemadmt.Float"}.AsLink() } -func (Float) Prototype() ipld.NodePrototype { +func (Float) Prototype() datamodel.NodePrototype { return _Float__Prototype{} } type _Float__Prototype struct{} -func (_Float__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Float__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Float__Builder nb.Reset() return &nb @@ -4277,7 +4277,7 @@ type _Float__Builder struct { _Float__Assembler } -func (nb *_Float__Builder) Build() ipld.Node { +func (nb *_Float__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -4295,10 +4295,10 @@ type _Float__Assembler struct { } func (na *_Float__Assembler) reset() {} -func (_Float__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Float__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.FloatAssembler{TypeName: "schemadmt.Float"}.BeginMap(0) } -func (_Float__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Float__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.FloatAssembler{TypeName: "schemadmt.Float"}.BeginList(0) } func (na *_Float__Assembler) AssignNull() error { @@ -4334,10 +4334,10 @@ func (_Float__Assembler) AssignString(string) error { func (_Float__Assembler) AssignBytes([]byte) error { return mixins.FloatAssembler{TypeName: "schemadmt.Float"}.AssignBytes(nil) } -func (_Float__Assembler) AssignLink(ipld.Link) error { +func (_Float__Assembler) AssignLink(datamodel.Link) error { return mixins.FloatAssembler{TypeName: "schemadmt.Float"}.AssignLink(nil) } -func (na *_Float__Assembler) AssignNode(v ipld.Node) error { +func (na *_Float__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -4356,19 +4356,19 @@ func (na *_Float__Assembler) AssignNode(v ipld.Node) error { return na.AssignFloat(v2) } } -func (_Float__Assembler) Prototype() ipld.NodePrototype { +func (_Float__Assembler) Prototype() datamodel.NodePrototype { return _Float__Prototype{} } func (Float) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Float) Representation() ipld.Node { +func (n Float) Representation() datamodel.Node { return (*_Float__Repr)(n) } type _Float__Repr = _Float -var _ ipld.Node = &_Float__Repr{} +var _ datamodel.Node = &_Float__Repr{} type _Float__ReprPrototype = _Float__Prototype type _Float__ReprAssembler = _Float__Assembler @@ -4396,12 +4396,12 @@ func (m MaybeInt) IsAbsent() bool { func (m MaybeInt) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeInt) AsNode() ipld.Node { +func (m MaybeInt) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -4415,28 +4415,28 @@ func (m MaybeInt) Must() Int { return &m.v } -var _ ipld.Node = (Int)(&_Int{}) +var _ datamodel.Node = (Int)(&_Int{}) var _ schema.TypedNode = (Int)(&_Int{}) -func (Int) Kind() ipld.Kind { - return ipld.Kind_Int +func (Int) Kind() datamodel.Kind { + return datamodel.Kind_Int } -func (Int) LookupByString(string) (ipld.Node, error) { +func (Int) LookupByString(string) (datamodel.Node, error) { return mixins.Int{TypeName: "schemadmt.Int"}.LookupByString("") } -func (Int) LookupByNode(ipld.Node) (ipld.Node, error) { +func (Int) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.Int{TypeName: "schemadmt.Int"}.LookupByNode(nil) } -func (Int) LookupByIndex(idx int64) (ipld.Node, error) { +func (Int) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Int{TypeName: "schemadmt.Int"}.LookupByIndex(0) } -func (Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (Int) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.Int{TypeName: "schemadmt.Int"}.LookupBySegment(seg) } -func (Int) MapIterator() ipld.MapIterator { +func (Int) MapIterator() datamodel.MapIterator { return nil } -func (Int) ListIterator() ipld.ListIterator { +func (Int) ListIterator() datamodel.ListIterator { return nil } func (Int) Length() int64 { @@ -4463,16 +4463,16 @@ func (Int) AsString() (string, error) { func (Int) AsBytes() ([]byte, error) { return mixins.Int{TypeName: "schemadmt.Int"}.AsBytes() } -func (Int) AsLink() (ipld.Link, error) { +func (Int) AsLink() (datamodel.Link, error) { return mixins.Int{TypeName: "schemadmt.Int"}.AsLink() } -func (Int) Prototype() ipld.NodePrototype { +func (Int) Prototype() datamodel.NodePrototype { return _Int__Prototype{} } type _Int__Prototype struct{} -func (_Int__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Int__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Int__Builder nb.Reset() return &nb @@ -4482,7 +4482,7 @@ type _Int__Builder struct { _Int__Assembler } -func (nb *_Int__Builder) Build() ipld.Node { +func (nb *_Int__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -4500,10 +4500,10 @@ type _Int__Assembler struct { } func (na *_Int__Assembler) reset() {} -func (_Int__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Int__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.IntAssembler{TypeName: "schemadmt.Int"}.BeginMap(0) } -func (_Int__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Int__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.IntAssembler{TypeName: "schemadmt.Int"}.BeginList(0) } func (na *_Int__Assembler) AssignNull() error { @@ -4539,10 +4539,10 @@ func (_Int__Assembler) AssignString(string) error { func (_Int__Assembler) AssignBytes([]byte) error { return mixins.IntAssembler{TypeName: "schemadmt.Int"}.AssignBytes(nil) } -func (_Int__Assembler) AssignLink(ipld.Link) error { +func (_Int__Assembler) AssignLink(datamodel.Link) error { return mixins.IntAssembler{TypeName: "schemadmt.Int"}.AssignLink(nil) } -func (na *_Int__Assembler) AssignNode(v ipld.Node) error { +func (na *_Int__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -4561,19 +4561,19 @@ func (na *_Int__Assembler) AssignNode(v ipld.Node) error { return na.AssignInt(v2) } } -func (_Int__Assembler) Prototype() ipld.NodePrototype { +func (_Int__Assembler) Prototype() datamodel.NodePrototype { return _Int__Prototype{} } func (Int) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Int) Representation() ipld.Node { +func (n Int) Representation() datamodel.Node { return (*_Int__Repr)(n) } type _Int__Repr = _Int -var _ ipld.Node = &_Int__Repr{} +var _ datamodel.Node = &_Int__Repr{} type _Int__ReprPrototype = _Int__Prototype type _Int__ReprAssembler = _Int__Assembler @@ -4602,12 +4602,12 @@ func (m MaybeListRepresentation) IsAbsent() bool { func (m MaybeListRepresentation) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeListRepresentation) AsNode() ipld.Node { +func (m MaybeListRepresentation) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -4624,37 +4624,37 @@ func (m MaybeListRepresentation) Must() ListRepresentation { var ( memberName__ListRepresentation_ListRepresentation_List = _String{"ListRepresentation_List"} ) -var _ ipld.Node = (ListRepresentation)(&_ListRepresentation{}) +var _ datamodel.Node = (ListRepresentation)(&_ListRepresentation{}) var _ schema.TypedNode = (ListRepresentation)(&_ListRepresentation{}) -func (ListRepresentation) Kind() ipld.Kind { - return ipld.Kind_Map +func (ListRepresentation) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n ListRepresentation) LookupByString(key string) (ipld.Node, error) { +func (n ListRepresentation) LookupByString(key string) (datamodel.Node, error) { switch key { case "ListRepresentation_List": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n ListRepresentation) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n ListRepresentation) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (ListRepresentation) LookupByIndex(idx int64) (ipld.Node, error) { +func (ListRepresentation) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation"}.LookupByIndex(0) } -func (n ListRepresentation) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n ListRepresentation) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n ListRepresentation) MapIterator() ipld.MapIterator { +func (n ListRepresentation) MapIterator() datamodel.MapIterator { return &_ListRepresentation__MapItr{n, false} } @@ -4663,9 +4663,9 @@ type _ListRepresentation__MapItr struct { done bool } -func (itr *_ListRepresentation__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_ListRepresentation__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -4680,7 +4680,7 @@ func (itr *_ListRepresentation__MapItr) Done() bool { return itr.done } -func (ListRepresentation) ListIterator() ipld.ListIterator { +func (ListRepresentation) ListIterator() datamodel.ListIterator { return nil } func (ListRepresentation) Length() int64 { @@ -4707,16 +4707,16 @@ func (ListRepresentation) AsString() (string, error) { func (ListRepresentation) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation"}.AsBytes() } -func (ListRepresentation) AsLink() (ipld.Link, error) { +func (ListRepresentation) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation"}.AsLink() } -func (ListRepresentation) Prototype() ipld.NodePrototype { +func (ListRepresentation) Prototype() datamodel.NodePrototype { return _ListRepresentation__Prototype{} } type _ListRepresentation__Prototype struct{} -func (_ListRepresentation__Prototype) NewBuilder() ipld.NodeBuilder { +func (_ListRepresentation__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _ListRepresentation__Builder nb.Reset() return &nb @@ -4726,7 +4726,7 @@ type _ListRepresentation__Builder struct { _ListRepresentation__Assembler } -func (nb *_ListRepresentation__Builder) Build() ipld.Node { +func (nb *_ListRepresentation__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -4761,7 +4761,7 @@ func (na *_ListRepresentation__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_ListRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_ListRepresentation__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -4774,7 +4774,7 @@ func (na *_ListRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, er } return na, nil } -func (_ListRepresentation__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation"}.BeginList(0) } func (na *_ListRepresentation__Assembler) AssignNull() error { @@ -4806,10 +4806,10 @@ func (_ListRepresentation__Assembler) AssignString(string) error { func (_ListRepresentation__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation"}.AssignBytes(nil) } -func (_ListRepresentation__Assembler) AssignLink(ipld.Link) error { +func (_ListRepresentation__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation"}.AssignLink(nil) } -func (na *_ListRepresentation__Assembler) AssignNode(v ipld.Node) error { +func (na *_ListRepresentation__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -4829,8 +4829,8 @@ func (na *_ListRepresentation__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.ListRepresentation", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.ListRepresentation", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -4847,7 +4847,7 @@ func (na *_ListRepresentation__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_ListRepresentation__Assembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation__Assembler) Prototype() datamodel.NodePrototype { return _ListRepresentation__Prototype{} } func (ma *_ListRepresentation__Assembler) valueFinishTidy() bool { @@ -4859,7 +4859,7 @@ func (ma *_ListRepresentation__Assembler) valueFinishTidy() bool { return false } } -func (ma *_ListRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_ListRepresentation__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -4886,9 +4886,9 @@ func (ma *_ListRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAsse ma.ca1.m = &ma.cm return &ma.ca1, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation", Key: &_String{k}} } -func (ma *_ListRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_ListRepresentation__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -4906,7 +4906,7 @@ func (ma *_ListRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_ListRepresentation__KeyAssembler)(ma) } -func (ma *_ListRepresentation__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_ListRepresentation__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -4951,10 +4951,10 @@ func (ma *_ListRepresentation__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_ListRepresentation__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_ListRepresentation__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_ListRepresentation__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_ListRepresentation__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "ListRepresentation_List": return _ListRepresentation_List__Prototype{} @@ -4965,10 +4965,10 @@ func (ma *_ListRepresentation__Assembler) ValuePrototype(k string) ipld.NodeProt type _ListRepresentation__KeyAssembler _ListRepresentation__Assembler -func (_ListRepresentation__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_ListRepresentation__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.KeyAssembler"}.BeginMap(0) } -func (_ListRepresentation__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.KeyAssembler"}.BeginList(0) } func (na *_ListRepresentation__KeyAssembler) AssignNull() error { @@ -4997,28 +4997,28 @@ func (ka *_ListRepresentation__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_ListRepresentation__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.KeyAssembler"}.AssignBytes(nil) } -func (_ListRepresentation__KeyAssembler) AssignLink(ipld.Link) error { +func (_ListRepresentation__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.KeyAssembler"}.AssignLink(nil) } -func (ka *_ListRepresentation__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_ListRepresentation__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_ListRepresentation__KeyAssembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (ListRepresentation) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n ListRepresentation) Representation() ipld.Node { +func (n ListRepresentation) Representation() datamodel.Node { return (*_ListRepresentation__Repr)(n) } @@ -5027,36 +5027,36 @@ type _ListRepresentation__Repr _ListRepresentation var ( memberName__ListRepresentation_ListRepresentation_List_serial = _String{"list"} ) -var _ ipld.Node = &_ListRepresentation__Repr{} +var _ datamodel.Node = &_ListRepresentation__Repr{} -func (_ListRepresentation__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_ListRepresentation__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_ListRepresentation__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_ListRepresentation__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "list": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x1.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_ListRepresentation__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_ListRepresentation__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_ListRepresentation__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_ListRepresentation__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation.Repr"}.LookupByIndex(0) } -func (n _ListRepresentation__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _ListRepresentation__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_ListRepresentation__Repr) MapIterator() ipld.MapIterator { +func (n *_ListRepresentation__Repr) MapIterator() datamodel.MapIterator { return &_ListRepresentation__ReprMapItr{n, false} } @@ -5065,9 +5065,9 @@ type _ListRepresentation__ReprMapItr struct { done bool } -func (itr *_ListRepresentation__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_ListRepresentation__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -5082,7 +5082,7 @@ func (itr *_ListRepresentation__ReprMapItr) Done() bool { return itr.done } -func (_ListRepresentation__Repr) ListIterator() ipld.ListIterator { +func (_ListRepresentation__Repr) ListIterator() datamodel.ListIterator { return nil } func (_ListRepresentation__Repr) Length() int64 { @@ -5109,16 +5109,16 @@ func (_ListRepresentation__Repr) AsString() (string, error) { func (_ListRepresentation__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation.Repr"}.AsBytes() } -func (_ListRepresentation__Repr) AsLink() (ipld.Link, error) { +func (_ListRepresentation__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation.Repr"}.AsLink() } -func (_ListRepresentation__Repr) Prototype() ipld.NodePrototype { +func (_ListRepresentation__Repr) Prototype() datamodel.NodePrototype { return _ListRepresentation__ReprPrototype{} } type _ListRepresentation__ReprPrototype struct{} -func (_ListRepresentation__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_ListRepresentation__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _ListRepresentation__ReprBuilder nb.Reset() return &nb @@ -5128,7 +5128,7 @@ type _ListRepresentation__ReprBuilder struct { _ListRepresentation__ReprAssembler } -func (nb *_ListRepresentation__ReprBuilder) Build() ipld.Node { +func (nb *_ListRepresentation__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -5163,7 +5163,7 @@ func (na *_ListRepresentation__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_ListRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_ListRepresentation__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -5176,7 +5176,7 @@ func (na *_ListRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler } return na, nil } -func (_ListRepresentation__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation.Repr"}.BeginList(0) } func (na *_ListRepresentation__ReprAssembler) AssignNull() error { @@ -5208,10 +5208,10 @@ func (_ListRepresentation__ReprAssembler) AssignString(string) error { func (_ListRepresentation__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation.Repr"}.AssignBytes(nil) } -func (_ListRepresentation__ReprAssembler) AssignLink(ipld.Link) error { +func (_ListRepresentation__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation.Repr"}.AssignLink(nil) } -func (na *_ListRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_ListRepresentation__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -5231,8 +5231,8 @@ func (na *_ListRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.ListRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.ListRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -5249,7 +5249,7 @@ func (na *_ListRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_ListRepresentation__ReprAssembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation__ReprAssembler) Prototype() datamodel.NodePrototype { return _ListRepresentation__ReprPrototype{} } func (ma *_ListRepresentation__ReprAssembler) valueFinishTidy() bool { @@ -5261,7 +5261,7 @@ func (ma *_ListRepresentation__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_ListRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_ListRepresentation__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -5288,9 +5288,9 @@ func (ma *_ListRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.Node ma.ca1.m = &ma.cm return &ma.ca1, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation.Repr", Key: &_String{k}} } -func (ma *_ListRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_ListRepresentation__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -5308,7 +5308,7 @@ func (ma *_ListRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_ListRepresentation__ReprKeyAssembler)(ma) } -func (ma *_ListRepresentation__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_ListRepresentation__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -5353,10 +5353,10 @@ func (ma *_ListRepresentation__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_ListRepresentation__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_ListRepresentation__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_ListRepresentation__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_ListRepresentation__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "ListRepresentation_List": return _ListRepresentation_List__ReprPrototype{} @@ -5367,10 +5367,10 @@ func (ma *_ListRepresentation__ReprAssembler) ValuePrototype(k string) ipld.Node type _ListRepresentation__ReprKeyAssembler _ListRepresentation__ReprAssembler -func (_ListRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_ListRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.Repr.KeyAssembler"}.BeginMap(0) } -func (_ListRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.Repr.KeyAssembler"}.BeginList(0) } func (na *_ListRepresentation__ReprKeyAssembler) AssignNull() error { @@ -5399,22 +5399,22 @@ func (ka *_ListRepresentation__ReprKeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_ListRepresentation__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_ListRepresentation__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_ListRepresentation__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_ListRepresentation__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_ListRepresentation__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_ListRepresentation__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -5433,12 +5433,12 @@ func (m MaybeListRepresentation_List) IsAbsent() bool { func (m MaybeListRepresentation_List) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeListRepresentation_List) AsNode() ipld.Node { +func (m MaybeListRepresentation_List) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -5453,32 +5453,32 @@ func (m MaybeListRepresentation_List) Must() ListRepresentation_List { } var () -var _ ipld.Node = (ListRepresentation_List)(&_ListRepresentation_List{}) +var _ datamodel.Node = (ListRepresentation_List)(&_ListRepresentation_List{}) var _ schema.TypedNode = (ListRepresentation_List)(&_ListRepresentation_List{}) -func (ListRepresentation_List) Kind() ipld.Kind { - return ipld.Kind_Map +func (ListRepresentation_List) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n ListRepresentation_List) LookupByString(key string) (ipld.Node, error) { +func (n ListRepresentation_List) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n ListRepresentation_List) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n ListRepresentation_List) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (ListRepresentation_List) LookupByIndex(idx int64) (ipld.Node, error) { +func (ListRepresentation_List) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation_List"}.LookupByIndex(0) } -func (n ListRepresentation_List) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n ListRepresentation_List) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n ListRepresentation_List) MapIterator() ipld.MapIterator { +func (n ListRepresentation_List) MapIterator() datamodel.MapIterator { return &_ListRepresentation_List__MapItr{n, 0} } @@ -5487,15 +5487,15 @@ type _ListRepresentation_List__MapItr struct { idx int } -func (itr *_ListRepresentation_List__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_ListRepresentation_List__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_ListRepresentation_List__MapItr) Done() bool { return itr.idx >= 0 } -func (ListRepresentation_List) ListIterator() ipld.ListIterator { +func (ListRepresentation_List) ListIterator() datamodel.ListIterator { return nil } func (ListRepresentation_List) Length() int64 { @@ -5522,16 +5522,16 @@ func (ListRepresentation_List) AsString() (string, error) { func (ListRepresentation_List) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation_List"}.AsBytes() } -func (ListRepresentation_List) AsLink() (ipld.Link, error) { +func (ListRepresentation_List) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation_List"}.AsLink() } -func (ListRepresentation_List) Prototype() ipld.NodePrototype { +func (ListRepresentation_List) Prototype() datamodel.NodePrototype { return _ListRepresentation_List__Prototype{} } type _ListRepresentation_List__Prototype struct{} -func (_ListRepresentation_List__Prototype) NewBuilder() ipld.NodeBuilder { +func (_ListRepresentation_List__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _ListRepresentation_List__Builder nb.Reset() return &nb @@ -5541,7 +5541,7 @@ type _ListRepresentation_List__Builder struct { _ListRepresentation_List__Assembler } -func (nb *_ListRepresentation_List__Builder) Build() ipld.Node { +func (nb *_ListRepresentation_List__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -5572,7 +5572,7 @@ var ( fieldBits__ListRepresentation_List_sufficient = 0 ) -func (na *_ListRepresentation_List__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_ListRepresentation_List__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -5585,7 +5585,7 @@ func (na *_ListRepresentation_List__Assembler) BeginMap(int64) (ipld.MapAssemble } return na, nil } -func (_ListRepresentation_List__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation_List__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation_List"}.BeginList(0) } func (na *_ListRepresentation_List__Assembler) AssignNull() error { @@ -5617,10 +5617,10 @@ func (_ListRepresentation_List__Assembler) AssignString(string) error { func (_ListRepresentation_List__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation_List"}.AssignBytes(nil) } -func (_ListRepresentation_List__Assembler) AssignLink(ipld.Link) error { +func (_ListRepresentation_List__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation_List"}.AssignLink(nil) } -func (na *_ListRepresentation_List__Assembler) AssignNode(v ipld.Node) error { +func (na *_ListRepresentation_List__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -5640,8 +5640,8 @@ func (na *_ListRepresentation_List__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.ListRepresentation_List", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.ListRepresentation_List", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -5658,7 +5658,7 @@ func (na *_ListRepresentation_List__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_ListRepresentation_List__Assembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation_List__Assembler) Prototype() datamodel.NodePrototype { return _ListRepresentation_List__Prototype{} } func (ma *_ListRepresentation_List__Assembler) valueFinishTidy() bool { @@ -5667,7 +5667,7 @@ func (ma *_ListRepresentation_List__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_ListRepresentation_List__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_ListRepresentation_List__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -5682,9 +5682,9 @@ func (ma *_ListRepresentation_List__Assembler) AssembleEntry(k string) (ipld.Nod case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List", Key: &_String{k}} } -func (ma *_ListRepresentation_List__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_ListRepresentation_List__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -5702,7 +5702,7 @@ func (ma *_ListRepresentation_List__Assembler) AssembleKey() ipld.NodeAssembler ma.state = maState_midKey return (*_ListRepresentation_List__KeyAssembler)(ma) } -func (ma *_ListRepresentation_List__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_ListRepresentation_List__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -5737,26 +5737,26 @@ func (ma *_ListRepresentation_List__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__ListRepresentation_List_sufficient != fieldBits__ListRepresentation_List_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_ListRepresentation_List__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_ListRepresentation_List__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_ListRepresentation_List__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_ListRepresentation_List__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _ListRepresentation_List__KeyAssembler _ListRepresentation_List__Assembler -func (_ListRepresentation_List__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_ListRepresentation_List__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.KeyAssembler"}.BeginMap(0) } -func (_ListRepresentation_List__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation_List__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.KeyAssembler"}.BeginList(0) } func (na *_ListRepresentation_List__KeyAssembler) AssignNull() error { @@ -5777,60 +5777,60 @@ func (ka *_ListRepresentation_List__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List", Key: &_String{k}} } } func (_ListRepresentation_List__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.KeyAssembler"}.AssignBytes(nil) } -func (_ListRepresentation_List__KeyAssembler) AssignLink(ipld.Link) error { +func (_ListRepresentation_List__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.KeyAssembler"}.AssignLink(nil) } -func (ka *_ListRepresentation_List__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_ListRepresentation_List__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_ListRepresentation_List__KeyAssembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation_List__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (ListRepresentation_List) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n ListRepresentation_List) Representation() ipld.Node { +func (n ListRepresentation_List) Representation() datamodel.Node { return (*_ListRepresentation_List__Repr)(n) } type _ListRepresentation_List__Repr _ListRepresentation_List var () -var _ ipld.Node = &_ListRepresentation_List__Repr{} +var _ datamodel.Node = &_ListRepresentation_List__Repr{} -func (_ListRepresentation_List__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_ListRepresentation_List__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_ListRepresentation_List__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_ListRepresentation_List__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_ListRepresentation_List__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_ListRepresentation_List__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_ListRepresentation_List__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_ListRepresentation_List__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation_List.Repr"}.LookupByIndex(0) } -func (n _ListRepresentation_List__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _ListRepresentation_List__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_ListRepresentation_List__Repr) MapIterator() ipld.MapIterator { +func (n *_ListRepresentation_List__Repr) MapIterator() datamodel.MapIterator { return &_ListRepresentation_List__ReprMapItr{n, 0} } @@ -5839,14 +5839,14 @@ type _ListRepresentation_List__ReprMapItr struct { idx int } -func (itr *_ListRepresentation_List__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_ListRepresentation_List__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_ListRepresentation_List__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_ListRepresentation_List__Repr) ListIterator() ipld.ListIterator { +func (_ListRepresentation_List__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_ListRepresentation_List__Repr) Length() int64 { @@ -5874,16 +5874,16 @@ func (_ListRepresentation_List__Repr) AsString() (string, error) { func (_ListRepresentation_List__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation_List.Repr"}.AsBytes() } -func (_ListRepresentation_List__Repr) AsLink() (ipld.Link, error) { +func (_ListRepresentation_List__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.ListRepresentation_List.Repr"}.AsLink() } -func (_ListRepresentation_List__Repr) Prototype() ipld.NodePrototype { +func (_ListRepresentation_List__Repr) Prototype() datamodel.NodePrototype { return _ListRepresentation_List__ReprPrototype{} } type _ListRepresentation_List__ReprPrototype struct{} -func (_ListRepresentation_List__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_ListRepresentation_List__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _ListRepresentation_List__ReprBuilder nb.Reset() return &nb @@ -5893,7 +5893,7 @@ type _ListRepresentation_List__ReprBuilder struct { _ListRepresentation_List__ReprAssembler } -func (nb *_ListRepresentation_List__ReprBuilder) Build() ipld.Node { +func (nb *_ListRepresentation_List__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -5919,7 +5919,7 @@ func (na *_ListRepresentation_List__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_ListRepresentation_List__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_ListRepresentation_List__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -5932,7 +5932,7 @@ func (na *_ListRepresentation_List__ReprAssembler) BeginMap(int64) (ipld.MapAsse } return na, nil } -func (_ListRepresentation_List__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation_List__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr"}.BeginList(0) } func (na *_ListRepresentation_List__ReprAssembler) AssignNull() error { @@ -5964,10 +5964,10 @@ func (_ListRepresentation_List__ReprAssembler) AssignString(string) error { func (_ListRepresentation_List__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr"}.AssignBytes(nil) } -func (_ListRepresentation_List__ReprAssembler) AssignLink(ipld.Link) error { +func (_ListRepresentation_List__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr"}.AssignLink(nil) } -func (na *_ListRepresentation_List__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_ListRepresentation_List__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -5987,8 +5987,8 @@ func (na *_ListRepresentation_List__ReprAssembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.ListRepresentation_List.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.ListRepresentation_List.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -6005,7 +6005,7 @@ func (na *_ListRepresentation_List__ReprAssembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_ListRepresentation_List__ReprAssembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation_List__ReprAssembler) Prototype() datamodel.NodePrototype { return _ListRepresentation_List__ReprPrototype{} } func (ma *_ListRepresentation_List__ReprAssembler) valueFinishTidy() bool { @@ -6014,7 +6014,7 @@ func (ma *_ListRepresentation_List__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_ListRepresentation_List__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_ListRepresentation_List__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -6029,9 +6029,9 @@ func (ma *_ListRepresentation_List__ReprAssembler) AssembleEntry(k string) (ipld case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List.Repr", Key: &_String{k}} } -func (ma *_ListRepresentation_List__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_ListRepresentation_List__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -6049,7 +6049,7 @@ func (ma *_ListRepresentation_List__ReprAssembler) AssembleKey() ipld.NodeAssemb ma.state = maState_midKey return (*_ListRepresentation_List__ReprKeyAssembler)(ma) } -func (ma *_ListRepresentation_List__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_ListRepresentation_List__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -6084,26 +6084,26 @@ func (ma *_ListRepresentation_List__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__ListRepresentation_List_sufficient != fieldBits__ListRepresentation_List_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_ListRepresentation_List__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_ListRepresentation_List__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_ListRepresentation_List__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_ListRepresentation_List__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _ListRepresentation_List__ReprKeyAssembler _ListRepresentation_List__ReprAssembler -func (_ListRepresentation_List__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_ListRepresentation_List__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr.KeyAssembler"}.BeginMap(0) } -func (_ListRepresentation_List__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_ListRepresentation_List__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr.KeyAssembler"}.BeginList(0) } func (na *_ListRepresentation_List__ReprKeyAssembler) AssignNull() error { @@ -6122,22 +6122,22 @@ func (ka *_ListRepresentation_List__ReprKeyAssembler) AssignString(k string) err if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.ListRepresentation_List.Repr", Key: &_String{k}} } func (_ListRepresentation_List__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_ListRepresentation_List__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_ListRepresentation_List__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.ListRepresentation_List.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_ListRepresentation_List__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_ListRepresentation_List__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_ListRepresentation_List__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_ListRepresentation_List__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -6198,12 +6198,12 @@ func (m MaybeList__FieldName) IsAbsent() bool { func (m MaybeList__FieldName) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeList__FieldName) AsNode() ipld.Node { +func (m MaybeList__FieldName) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -6217,40 +6217,40 @@ func (m MaybeList__FieldName) Must() List__FieldName { return &m.v } -var _ ipld.Node = (List__FieldName)(&_List__FieldName{}) +var _ datamodel.Node = (List__FieldName)(&_List__FieldName{}) var _ schema.TypedNode = (List__FieldName)(&_List__FieldName{}) -func (List__FieldName) Kind() ipld.Kind { - return ipld.Kind_List +func (List__FieldName) Kind() datamodel.Kind { + return datamodel.Kind_List } -func (List__FieldName) LookupByString(string) (ipld.Node, error) { +func (List__FieldName) LookupByString(string) (datamodel.Node, error) { return mixins.List{TypeName: "schemadmt.List__FieldName"}.LookupByString("") } -func (n List__FieldName) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n List__FieldName) LookupByNode(k datamodel.Node) (datamodel.Node, error) { idx, err := k.AsInt() if err != nil { return nil, err } return n.LookupByIndex(idx) } -func (n List__FieldName) LookupByIndex(idx int64) (ipld.Node, error) { +func (n List__FieldName) LookupByIndex(idx int64) (datamodel.Node, error) { if n.Length() <= idx { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)} } v := &n.x[idx] return v, nil } -func (n List__FieldName) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n List__FieldName) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { i, err := seg.Index() if err != nil { - return nil, ipld.ErrInvalidSegmentForList{TypeName: "schemadmt.List__FieldName", TroubleSegment: seg, Reason: err} + return nil, datamodel.ErrInvalidSegmentForList{TypeName: "schemadmt.List__FieldName", TroubleSegment: seg, Reason: err} } return n.LookupByIndex(i) } -func (List__FieldName) MapIterator() ipld.MapIterator { +func (List__FieldName) MapIterator() datamodel.MapIterator { return nil } -func (n List__FieldName) ListIterator() ipld.ListIterator { +func (n List__FieldName) ListIterator() datamodel.ListIterator { return &_List__FieldName__ListItr{n, 0} } @@ -6259,9 +6259,9 @@ type _List__FieldName__ListItr struct { idx int } -func (itr *_List__FieldName__ListItr) Next() (idx int64, v ipld.Node, _ error) { +func (itr *_List__FieldName__ListItr) Next() (idx int64, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.x) { - return -1, nil, ipld.ErrIteratorOverread{} + return -1, nil, datamodel.ErrIteratorOverread{} } idx = int64(itr.idx) x := &itr.n.x[itr.idx] @@ -6297,16 +6297,16 @@ func (List__FieldName) AsString() (string, error) { func (List__FieldName) AsBytes() ([]byte, error) { return mixins.List{TypeName: "schemadmt.List__FieldName"}.AsBytes() } -func (List__FieldName) AsLink() (ipld.Link, error) { +func (List__FieldName) AsLink() (datamodel.Link, error) { return mixins.List{TypeName: "schemadmt.List__FieldName"}.AsLink() } -func (List__FieldName) Prototype() ipld.NodePrototype { +func (List__FieldName) Prototype() datamodel.NodePrototype { return _List__FieldName__Prototype{} } type _List__FieldName__Prototype struct{} -func (_List__FieldName__Prototype) NewBuilder() ipld.NodeBuilder { +func (_List__FieldName__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _List__FieldName__Builder nb.Reset() return &nb @@ -6316,7 +6316,7 @@ type _List__FieldName__Builder struct { _List__FieldName__Assembler } -func (nb *_List__FieldName__Builder) Build() ipld.Node { +func (nb *_List__FieldName__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -6341,10 +6341,10 @@ func (na *_List__FieldName__Assembler) reset() { na.state = laState_initial na.va.reset() } -func (_List__FieldName__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_List__FieldName__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.ListAssembler{TypeName: "schemadmt.List__FieldName"}.BeginMap(0) } -func (na *_List__FieldName__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *_List__FieldName__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -6389,10 +6389,10 @@ func (_List__FieldName__Assembler) AssignString(string) error { func (_List__FieldName__Assembler) AssignBytes([]byte) error { return mixins.ListAssembler{TypeName: "schemadmt.List__FieldName"}.AssignBytes(nil) } -func (_List__FieldName__Assembler) AssignLink(ipld.Link) error { +func (_List__FieldName__Assembler) AssignLink(datamodel.Link) error { return mixins.ListAssembler{TypeName: "schemadmt.List__FieldName"}.AssignLink(nil) } -func (na *_List__FieldName__Assembler) AssignNode(v ipld.Node) error { +func (na *_List__FieldName__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -6407,8 +6407,8 @@ func (na *_List__FieldName__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_List { - return ipld.ErrWrongKind{TypeName: "schemadmt.List__FieldName", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_List { + return datamodel.ErrWrongKind{TypeName: "schemadmt.List__FieldName", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustList, ActualKind: v.Kind()} } itr := v.ListIterator() for !itr.Done() { @@ -6422,7 +6422,7 @@ func (na *_List__FieldName__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_List__FieldName__Assembler) Prototype() ipld.NodePrototype { +func (_List__FieldName__Assembler) Prototype() datamodel.NodePrototype { return _List__FieldName__Prototype{} } func (la *_List__FieldName__Assembler) valueFinishTidy() bool { @@ -6437,7 +6437,7 @@ func (la *_List__FieldName__Assembler) valueFinishTidy() bool { return false } } -func (la *_List__FieldName__Assembler) AssembleValue() ipld.NodeAssembler { +func (la *_List__FieldName__Assembler) AssembleValue() datamodel.NodeAssembler { switch la.state { case laState_initial: // carry on @@ -6470,59 +6470,59 @@ func (la *_List__FieldName__Assembler) Finish() error { *la.m = schema.Maybe_Value return nil } -func (la *_List__FieldName__Assembler) ValuePrototype(_ int64) ipld.NodePrototype { +func (la *_List__FieldName__Assembler) ValuePrototype(_ int64) datamodel.NodePrototype { return _FieldName__Prototype{} } func (List__FieldName) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n List__FieldName) Representation() ipld.Node { +func (n List__FieldName) Representation() datamodel.Node { return (*_List__FieldName__Repr)(n) } type _List__FieldName__Repr _List__FieldName -var _ ipld.Node = &_List__FieldName__Repr{} +var _ datamodel.Node = &_List__FieldName__Repr{} -func (_List__FieldName__Repr) Kind() ipld.Kind { - return ipld.Kind_List +func (_List__FieldName__Repr) Kind() datamodel.Kind { + return datamodel.Kind_List } -func (_List__FieldName__Repr) LookupByString(string) (ipld.Node, error) { +func (_List__FieldName__Repr) LookupByString(string) (datamodel.Node, error) { return mixins.List{TypeName: "schemadmt.List__FieldName.Repr"}.LookupByString("") } -func (nr *_List__FieldName__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_List__FieldName__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (List__FieldName)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(FieldName).Representation(), nil } -func (nr *_List__FieldName__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (nr *_List__FieldName__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { v, err := (List__FieldName)(nr).LookupByIndex(idx) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(FieldName).Representation(), nil } -func (n _List__FieldName__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _List__FieldName__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { i, err := seg.Index() if err != nil { - return nil, ipld.ErrInvalidSegmentForList{TypeName: "schemadmt.List__FieldName.Repr", TroubleSegment: seg, Reason: err} + return nil, datamodel.ErrInvalidSegmentForList{TypeName: "schemadmt.List__FieldName.Repr", TroubleSegment: seg, Reason: err} } return n.LookupByIndex(i) } -func (_List__FieldName__Repr) MapIterator() ipld.MapIterator { +func (_List__FieldName__Repr) MapIterator() datamodel.MapIterator { return nil } -func (nr *_List__FieldName__Repr) ListIterator() ipld.ListIterator { +func (nr *_List__FieldName__Repr) ListIterator() datamodel.ListIterator { return &_List__FieldName__ReprListItr{(List__FieldName)(nr), 0} } type _List__FieldName__ReprListItr _List__FieldName__ListItr -func (itr *_List__FieldName__ReprListItr) Next() (idx int64, v ipld.Node, err error) { +func (itr *_List__FieldName__ReprListItr) Next() (idx int64, v datamodel.Node, err error) { idx, v, err = (*_List__FieldName__ListItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return idx, v.(FieldName).Representation(), nil @@ -6555,16 +6555,16 @@ func (_List__FieldName__Repr) AsString() (string, error) { func (_List__FieldName__Repr) AsBytes() ([]byte, error) { return mixins.List{TypeName: "schemadmt.List__FieldName.Repr"}.AsBytes() } -func (_List__FieldName__Repr) AsLink() (ipld.Link, error) { +func (_List__FieldName__Repr) AsLink() (datamodel.Link, error) { return mixins.List{TypeName: "schemadmt.List__FieldName.Repr"}.AsLink() } -func (_List__FieldName__Repr) Prototype() ipld.NodePrototype { +func (_List__FieldName__Repr) Prototype() datamodel.NodePrototype { return _List__FieldName__ReprPrototype{} } type _List__FieldName__ReprPrototype struct{} -func (_List__FieldName__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_List__FieldName__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _List__FieldName__ReprBuilder nb.Reset() return &nb @@ -6574,7 +6574,7 @@ type _List__FieldName__ReprBuilder struct { _List__FieldName__ReprAssembler } -func (nb *_List__FieldName__ReprBuilder) Build() ipld.Node { +func (nb *_List__FieldName__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -6599,10 +6599,10 @@ func (na *_List__FieldName__ReprAssembler) reset() { na.state = laState_initial na.va.reset() } -func (_List__FieldName__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_List__FieldName__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.ListAssembler{TypeName: "schemadmt.List__FieldName.Repr"}.BeginMap(0) } -func (na *_List__FieldName__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *_List__FieldName__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -6647,10 +6647,10 @@ func (_List__FieldName__ReprAssembler) AssignString(string) error { func (_List__FieldName__ReprAssembler) AssignBytes([]byte) error { return mixins.ListAssembler{TypeName: "schemadmt.List__FieldName.Repr"}.AssignBytes(nil) } -func (_List__FieldName__ReprAssembler) AssignLink(ipld.Link) error { +func (_List__FieldName__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.ListAssembler{TypeName: "schemadmt.List__FieldName.Repr"}.AssignLink(nil) } -func (na *_List__FieldName__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_List__FieldName__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -6665,8 +6665,8 @@ func (na *_List__FieldName__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_List { - return ipld.ErrWrongKind{TypeName: "schemadmt.List__FieldName.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_List { + return datamodel.ErrWrongKind{TypeName: "schemadmt.List__FieldName.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustList, ActualKind: v.Kind()} } itr := v.ListIterator() for !itr.Done() { @@ -6680,7 +6680,7 @@ func (na *_List__FieldName__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_List__FieldName__ReprAssembler) Prototype() ipld.NodePrototype { +func (_List__FieldName__ReprAssembler) Prototype() datamodel.NodePrototype { return _List__FieldName__ReprPrototype{} } func (la *_List__FieldName__ReprAssembler) valueFinishTidy() bool { @@ -6695,7 +6695,7 @@ func (la *_List__FieldName__ReprAssembler) valueFinishTidy() bool { return false } } -func (la *_List__FieldName__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (la *_List__FieldName__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch la.state { case laState_initial: // carry on @@ -6728,7 +6728,7 @@ func (la *_List__FieldName__ReprAssembler) Finish() error { *la.m = schema.Maybe_Value return nil } -func (la *_List__FieldName__ReprAssembler) ValuePrototype(_ int64) ipld.NodePrototype { +func (la *_List__FieldName__ReprAssembler) ValuePrototype(_ int64) datamodel.NodePrototype { return _FieldName__ReprPrototype{} } @@ -6789,12 +6789,12 @@ func (m MaybeList__TypeName) IsAbsent() bool { func (m MaybeList__TypeName) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeList__TypeName) AsNode() ipld.Node { +func (m MaybeList__TypeName) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -6808,40 +6808,40 @@ func (m MaybeList__TypeName) Must() List__TypeName { return &m.v } -var _ ipld.Node = (List__TypeName)(&_List__TypeName{}) +var _ datamodel.Node = (List__TypeName)(&_List__TypeName{}) var _ schema.TypedNode = (List__TypeName)(&_List__TypeName{}) -func (List__TypeName) Kind() ipld.Kind { - return ipld.Kind_List +func (List__TypeName) Kind() datamodel.Kind { + return datamodel.Kind_List } -func (List__TypeName) LookupByString(string) (ipld.Node, error) { +func (List__TypeName) LookupByString(string) (datamodel.Node, error) { return mixins.List{TypeName: "schemadmt.List__TypeName"}.LookupByString("") } -func (n List__TypeName) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n List__TypeName) LookupByNode(k datamodel.Node) (datamodel.Node, error) { idx, err := k.AsInt() if err != nil { return nil, err } return n.LookupByIndex(idx) } -func (n List__TypeName) LookupByIndex(idx int64) (ipld.Node, error) { +func (n List__TypeName) LookupByIndex(idx int64) (datamodel.Node, error) { if n.Length() <= idx { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)} } v := &n.x[idx] return v, nil } -func (n List__TypeName) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n List__TypeName) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { i, err := seg.Index() if err != nil { - return nil, ipld.ErrInvalidSegmentForList{TypeName: "schemadmt.List__TypeName", TroubleSegment: seg, Reason: err} + return nil, datamodel.ErrInvalidSegmentForList{TypeName: "schemadmt.List__TypeName", TroubleSegment: seg, Reason: err} } return n.LookupByIndex(i) } -func (List__TypeName) MapIterator() ipld.MapIterator { +func (List__TypeName) MapIterator() datamodel.MapIterator { return nil } -func (n List__TypeName) ListIterator() ipld.ListIterator { +func (n List__TypeName) ListIterator() datamodel.ListIterator { return &_List__TypeName__ListItr{n, 0} } @@ -6850,9 +6850,9 @@ type _List__TypeName__ListItr struct { idx int } -func (itr *_List__TypeName__ListItr) Next() (idx int64, v ipld.Node, _ error) { +func (itr *_List__TypeName__ListItr) Next() (idx int64, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.x) { - return -1, nil, ipld.ErrIteratorOverread{} + return -1, nil, datamodel.ErrIteratorOverread{} } idx = int64(itr.idx) x := &itr.n.x[itr.idx] @@ -6888,16 +6888,16 @@ func (List__TypeName) AsString() (string, error) { func (List__TypeName) AsBytes() ([]byte, error) { return mixins.List{TypeName: "schemadmt.List__TypeName"}.AsBytes() } -func (List__TypeName) AsLink() (ipld.Link, error) { +func (List__TypeName) AsLink() (datamodel.Link, error) { return mixins.List{TypeName: "schemadmt.List__TypeName"}.AsLink() } -func (List__TypeName) Prototype() ipld.NodePrototype { +func (List__TypeName) Prototype() datamodel.NodePrototype { return _List__TypeName__Prototype{} } type _List__TypeName__Prototype struct{} -func (_List__TypeName__Prototype) NewBuilder() ipld.NodeBuilder { +func (_List__TypeName__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _List__TypeName__Builder nb.Reset() return &nb @@ -6907,7 +6907,7 @@ type _List__TypeName__Builder struct { _List__TypeName__Assembler } -func (nb *_List__TypeName__Builder) Build() ipld.Node { +func (nb *_List__TypeName__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -6932,10 +6932,10 @@ func (na *_List__TypeName__Assembler) reset() { na.state = laState_initial na.va.reset() } -func (_List__TypeName__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_List__TypeName__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.ListAssembler{TypeName: "schemadmt.List__TypeName"}.BeginMap(0) } -func (na *_List__TypeName__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *_List__TypeName__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -6980,10 +6980,10 @@ func (_List__TypeName__Assembler) AssignString(string) error { func (_List__TypeName__Assembler) AssignBytes([]byte) error { return mixins.ListAssembler{TypeName: "schemadmt.List__TypeName"}.AssignBytes(nil) } -func (_List__TypeName__Assembler) AssignLink(ipld.Link) error { +func (_List__TypeName__Assembler) AssignLink(datamodel.Link) error { return mixins.ListAssembler{TypeName: "schemadmt.List__TypeName"}.AssignLink(nil) } -func (na *_List__TypeName__Assembler) AssignNode(v ipld.Node) error { +func (na *_List__TypeName__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -6998,8 +6998,8 @@ func (na *_List__TypeName__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_List { - return ipld.ErrWrongKind{TypeName: "schemadmt.List__TypeName", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_List { + return datamodel.ErrWrongKind{TypeName: "schemadmt.List__TypeName", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustList, ActualKind: v.Kind()} } itr := v.ListIterator() for !itr.Done() { @@ -7013,7 +7013,7 @@ func (na *_List__TypeName__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_List__TypeName__Assembler) Prototype() ipld.NodePrototype { +func (_List__TypeName__Assembler) Prototype() datamodel.NodePrototype { return _List__TypeName__Prototype{} } func (la *_List__TypeName__Assembler) valueFinishTidy() bool { @@ -7028,7 +7028,7 @@ func (la *_List__TypeName__Assembler) valueFinishTidy() bool { return false } } -func (la *_List__TypeName__Assembler) AssembleValue() ipld.NodeAssembler { +func (la *_List__TypeName__Assembler) AssembleValue() datamodel.NodeAssembler { switch la.state { case laState_initial: // carry on @@ -7061,59 +7061,59 @@ func (la *_List__TypeName__Assembler) Finish() error { *la.m = schema.Maybe_Value return nil } -func (la *_List__TypeName__Assembler) ValuePrototype(_ int64) ipld.NodePrototype { +func (la *_List__TypeName__Assembler) ValuePrototype(_ int64) datamodel.NodePrototype { return _TypeName__Prototype{} } func (List__TypeName) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n List__TypeName) Representation() ipld.Node { +func (n List__TypeName) Representation() datamodel.Node { return (*_List__TypeName__Repr)(n) } type _List__TypeName__Repr _List__TypeName -var _ ipld.Node = &_List__TypeName__Repr{} +var _ datamodel.Node = &_List__TypeName__Repr{} -func (_List__TypeName__Repr) Kind() ipld.Kind { - return ipld.Kind_List +func (_List__TypeName__Repr) Kind() datamodel.Kind { + return datamodel.Kind_List } -func (_List__TypeName__Repr) LookupByString(string) (ipld.Node, error) { +func (_List__TypeName__Repr) LookupByString(string) (datamodel.Node, error) { return mixins.List{TypeName: "schemadmt.List__TypeName.Repr"}.LookupByString("") } -func (nr *_List__TypeName__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_List__TypeName__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (List__TypeName)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (nr *_List__TypeName__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (nr *_List__TypeName__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { v, err := (List__TypeName)(nr).LookupByIndex(idx) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (n _List__TypeName__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _List__TypeName__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { i, err := seg.Index() if err != nil { - return nil, ipld.ErrInvalidSegmentForList{TypeName: "schemadmt.List__TypeName.Repr", TroubleSegment: seg, Reason: err} + return nil, datamodel.ErrInvalidSegmentForList{TypeName: "schemadmt.List__TypeName.Repr", TroubleSegment: seg, Reason: err} } return n.LookupByIndex(i) } -func (_List__TypeName__Repr) MapIterator() ipld.MapIterator { +func (_List__TypeName__Repr) MapIterator() datamodel.MapIterator { return nil } -func (nr *_List__TypeName__Repr) ListIterator() ipld.ListIterator { +func (nr *_List__TypeName__Repr) ListIterator() datamodel.ListIterator { return &_List__TypeName__ReprListItr{(List__TypeName)(nr), 0} } type _List__TypeName__ReprListItr _List__TypeName__ListItr -func (itr *_List__TypeName__ReprListItr) Next() (idx int64, v ipld.Node, err error) { +func (itr *_List__TypeName__ReprListItr) Next() (idx int64, v datamodel.Node, err error) { idx, v, err = (*_List__TypeName__ListItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return idx, v.(TypeName).Representation(), nil @@ -7146,16 +7146,16 @@ func (_List__TypeName__Repr) AsString() (string, error) { func (_List__TypeName__Repr) AsBytes() ([]byte, error) { return mixins.List{TypeName: "schemadmt.List__TypeName.Repr"}.AsBytes() } -func (_List__TypeName__Repr) AsLink() (ipld.Link, error) { +func (_List__TypeName__Repr) AsLink() (datamodel.Link, error) { return mixins.List{TypeName: "schemadmt.List__TypeName.Repr"}.AsLink() } -func (_List__TypeName__Repr) Prototype() ipld.NodePrototype { +func (_List__TypeName__Repr) Prototype() datamodel.NodePrototype { return _List__TypeName__ReprPrototype{} } type _List__TypeName__ReprPrototype struct{} -func (_List__TypeName__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_List__TypeName__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _List__TypeName__ReprBuilder nb.Reset() return &nb @@ -7165,7 +7165,7 @@ type _List__TypeName__ReprBuilder struct { _List__TypeName__ReprAssembler } -func (nb *_List__TypeName__ReprBuilder) Build() ipld.Node { +func (nb *_List__TypeName__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -7190,10 +7190,10 @@ func (na *_List__TypeName__ReprAssembler) reset() { na.state = laState_initial na.va.reset() } -func (_List__TypeName__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_List__TypeName__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.ListAssembler{TypeName: "schemadmt.List__TypeName.Repr"}.BeginMap(0) } -func (na *_List__TypeName__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *_List__TypeName__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -7238,10 +7238,10 @@ func (_List__TypeName__ReprAssembler) AssignString(string) error { func (_List__TypeName__ReprAssembler) AssignBytes([]byte) error { return mixins.ListAssembler{TypeName: "schemadmt.List__TypeName.Repr"}.AssignBytes(nil) } -func (_List__TypeName__ReprAssembler) AssignLink(ipld.Link) error { +func (_List__TypeName__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.ListAssembler{TypeName: "schemadmt.List__TypeName.Repr"}.AssignLink(nil) } -func (na *_List__TypeName__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_List__TypeName__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -7256,8 +7256,8 @@ func (na *_List__TypeName__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_List { - return ipld.ErrWrongKind{TypeName: "schemadmt.List__TypeName.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_List { + return datamodel.ErrWrongKind{TypeName: "schemadmt.List__TypeName.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustList, ActualKind: v.Kind()} } itr := v.ListIterator() for !itr.Done() { @@ -7271,7 +7271,7 @@ func (na *_List__TypeName__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_List__TypeName__ReprAssembler) Prototype() ipld.NodePrototype { +func (_List__TypeName__ReprAssembler) Prototype() datamodel.NodePrototype { return _List__TypeName__ReprPrototype{} } func (la *_List__TypeName__ReprAssembler) valueFinishTidy() bool { @@ -7286,7 +7286,7 @@ func (la *_List__TypeName__ReprAssembler) valueFinishTidy() bool { return false } } -func (la *_List__TypeName__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (la *_List__TypeName__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch la.state { case laState_initial: // carry on @@ -7319,7 +7319,7 @@ func (la *_List__TypeName__ReprAssembler) Finish() error { *la.m = schema.Maybe_Value return nil } -func (la *_List__TypeName__ReprAssembler) ValuePrototype(_ int64) ipld.NodePrototype { +func (la *_List__TypeName__ReprAssembler) ValuePrototype(_ int64) datamodel.NodePrototype { return _TypeName__ReprPrototype{} } @@ -7351,12 +7351,12 @@ func (m MaybeMapRepresentation) IsAbsent() bool { func (m MaybeMapRepresentation) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMapRepresentation) AsNode() ipld.Node { +func (m MaybeMapRepresentation) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -7375,47 +7375,47 @@ var ( memberName__MapRepresentation_MapRepresentation_Stringpairs = _String{"MapRepresentation_Stringpairs"} memberName__MapRepresentation_MapRepresentation_Listpairs = _String{"MapRepresentation_Listpairs"} ) -var _ ipld.Node = (MapRepresentation)(&_MapRepresentation{}) +var _ datamodel.Node = (MapRepresentation)(&_MapRepresentation{}) var _ schema.TypedNode = (MapRepresentation)(&_MapRepresentation{}) -func (MapRepresentation) Kind() ipld.Kind { - return ipld.Kind_Map +func (MapRepresentation) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n MapRepresentation) LookupByString(key string) (ipld.Node, error) { +func (n MapRepresentation) LookupByString(key string) (datamodel.Node, error) { switch key { case "MapRepresentation_Map": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "MapRepresentation_Stringpairs": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil case "MapRepresentation_Listpairs": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x3, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n MapRepresentation) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n MapRepresentation) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (MapRepresentation) LookupByIndex(idx int64) (ipld.Node, error) { +func (MapRepresentation) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation"}.LookupByIndex(0) } -func (n MapRepresentation) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n MapRepresentation) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n MapRepresentation) MapIterator() ipld.MapIterator { +func (n MapRepresentation) MapIterator() datamodel.MapIterator { return &_MapRepresentation__MapItr{n, false} } @@ -7424,9 +7424,9 @@ type _MapRepresentation__MapItr struct { done bool } -func (itr *_MapRepresentation__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_MapRepresentation__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -7445,7 +7445,7 @@ func (itr *_MapRepresentation__MapItr) Done() bool { return itr.done } -func (MapRepresentation) ListIterator() ipld.ListIterator { +func (MapRepresentation) ListIterator() datamodel.ListIterator { return nil } func (MapRepresentation) Length() int64 { @@ -7472,16 +7472,16 @@ func (MapRepresentation) AsString() (string, error) { func (MapRepresentation) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation"}.AsBytes() } -func (MapRepresentation) AsLink() (ipld.Link, error) { +func (MapRepresentation) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation"}.AsLink() } -func (MapRepresentation) Prototype() ipld.NodePrototype { +func (MapRepresentation) Prototype() datamodel.NodePrototype { return _MapRepresentation__Prototype{} } type _MapRepresentation__Prototype struct{} -func (_MapRepresentation__Prototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation__Builder nb.Reset() return &nb @@ -7491,7 +7491,7 @@ type _MapRepresentation__Builder struct { _MapRepresentation__Assembler } -func (nb *_MapRepresentation__Builder) Build() ipld.Node { +func (nb *_MapRepresentation__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -7536,7 +7536,7 @@ func (na *_MapRepresentation__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_MapRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -7549,7 +7549,7 @@ func (na *_MapRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, err } return na, nil } -func (_MapRepresentation__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation"}.BeginList(0) } func (na *_MapRepresentation__Assembler) AssignNull() error { @@ -7581,10 +7581,10 @@ func (_MapRepresentation__Assembler) AssignString(string) error { func (_MapRepresentation__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation"}.AssignBytes(nil) } -func (_MapRepresentation__Assembler) AssignLink(ipld.Link) error { +func (_MapRepresentation__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation"}.AssignLink(nil) } -func (na *_MapRepresentation__Assembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -7604,8 +7604,8 @@ func (na *_MapRepresentation__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -7622,7 +7622,7 @@ func (na *_MapRepresentation__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_MapRepresentation__Assembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation__Assembler) Prototype() datamodel.NodePrototype { return _MapRepresentation__Prototype{} } func (ma *_MapRepresentation__Assembler) valueFinishTidy() bool { @@ -7634,7 +7634,7 @@ func (ma *_MapRepresentation__Assembler) valueFinishTidy() bool { return false } } -func (ma *_MapRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -7675,9 +7675,9 @@ func (ma *_MapRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAssem ma.ca3.m = &ma.cm return &ma.ca3, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation", Key: &_String{k}} } -func (ma *_MapRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -7695,7 +7695,7 @@ func (ma *_MapRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_MapRepresentation__KeyAssembler)(ma) } -func (ma *_MapRepresentation__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -7748,10 +7748,10 @@ func (ma *_MapRepresentation__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "MapRepresentation_Map": return _MapRepresentation_Map__Prototype{} @@ -7766,10 +7766,10 @@ func (ma *_MapRepresentation__Assembler) ValuePrototype(k string) ipld.NodeProto type _MapRepresentation__KeyAssembler _MapRepresentation__Assembler -func (_MapRepresentation__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation__KeyAssembler) AssignNull() error { @@ -7808,28 +7808,28 @@ func (ka *_MapRepresentation__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_MapRepresentation__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation__KeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation__KeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (MapRepresentation) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n MapRepresentation) Representation() ipld.Node { +func (n MapRepresentation) Representation() datamodel.Node { return (*_MapRepresentation__Repr)(n) } @@ -7840,46 +7840,46 @@ var ( memberName__MapRepresentation_MapRepresentation_Stringpairs_serial = _String{"stringpairs"} memberName__MapRepresentation_MapRepresentation_Listpairs_serial = _String{"listpairs"} ) -var _ ipld.Node = &_MapRepresentation__Repr{} +var _ datamodel.Node = &_MapRepresentation__Repr{} -func (_MapRepresentation__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_MapRepresentation__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_MapRepresentation__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_MapRepresentation__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "map": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x1.Representation(), nil case "stringpairs": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x2.Representation(), nil case "listpairs": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x3.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_MapRepresentation__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_MapRepresentation__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_MapRepresentation__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_MapRepresentation__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation.Repr"}.LookupByIndex(0) } -func (n _MapRepresentation__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _MapRepresentation__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_MapRepresentation__Repr) MapIterator() ipld.MapIterator { +func (n *_MapRepresentation__Repr) MapIterator() datamodel.MapIterator { return &_MapRepresentation__ReprMapItr{n, false} } @@ -7888,9 +7888,9 @@ type _MapRepresentation__ReprMapItr struct { done bool } -func (itr *_MapRepresentation__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_MapRepresentation__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -7909,7 +7909,7 @@ func (itr *_MapRepresentation__ReprMapItr) Done() bool { return itr.done } -func (_MapRepresentation__Repr) ListIterator() ipld.ListIterator { +func (_MapRepresentation__Repr) ListIterator() datamodel.ListIterator { return nil } func (_MapRepresentation__Repr) Length() int64 { @@ -7936,16 +7936,16 @@ func (_MapRepresentation__Repr) AsString() (string, error) { func (_MapRepresentation__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation.Repr"}.AsBytes() } -func (_MapRepresentation__Repr) AsLink() (ipld.Link, error) { +func (_MapRepresentation__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation.Repr"}.AsLink() } -func (_MapRepresentation__Repr) Prototype() ipld.NodePrototype { +func (_MapRepresentation__Repr) Prototype() datamodel.NodePrototype { return _MapRepresentation__ReprPrototype{} } type _MapRepresentation__ReprPrototype struct{} -func (_MapRepresentation__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation__ReprBuilder nb.Reset() return &nb @@ -7955,7 +7955,7 @@ type _MapRepresentation__ReprBuilder struct { _MapRepresentation__ReprAssembler } -func (nb *_MapRepresentation__ReprBuilder) Build() ipld.Node { +func (nb *_MapRepresentation__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -8000,7 +8000,7 @@ func (na *_MapRepresentation__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_MapRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -8013,7 +8013,7 @@ func (na *_MapRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, } return na, nil } -func (_MapRepresentation__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation.Repr"}.BeginList(0) } func (na *_MapRepresentation__ReprAssembler) AssignNull() error { @@ -8045,10 +8045,10 @@ func (_MapRepresentation__ReprAssembler) AssignString(string) error { func (_MapRepresentation__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation.Repr"}.AssignBytes(nil) } -func (_MapRepresentation__ReprAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation.Repr"}.AssignLink(nil) } -func (na *_MapRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -8068,8 +8068,8 @@ func (na *_MapRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -8086,7 +8086,7 @@ func (na *_MapRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_MapRepresentation__ReprAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation__ReprAssembler) Prototype() datamodel.NodePrototype { return _MapRepresentation__ReprPrototype{} } func (ma *_MapRepresentation__ReprAssembler) valueFinishTidy() bool { @@ -8098,7 +8098,7 @@ func (ma *_MapRepresentation__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_MapRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -8139,9 +8139,9 @@ func (ma *_MapRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.NodeA ma.ca3.m = &ma.cm return &ma.ca3, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation.Repr", Key: &_String{k}} } -func (ma *_MapRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -8159,7 +8159,7 @@ func (ma *_MapRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_MapRepresentation__ReprKeyAssembler)(ma) } -func (ma *_MapRepresentation__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -8212,10 +8212,10 @@ func (ma *_MapRepresentation__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "MapRepresentation_Map": return _MapRepresentation_Map__ReprPrototype{} @@ -8230,10 +8230,10 @@ func (ma *_MapRepresentation__ReprAssembler) ValuePrototype(k string) ipld.NodeP type _MapRepresentation__ReprKeyAssembler _MapRepresentation__ReprAssembler -func (_MapRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.Repr.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.Repr.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation__ReprKeyAssembler) AssignNull() error { @@ -8272,22 +8272,22 @@ func (ka *_MapRepresentation__ReprKeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_MapRepresentation__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -8306,12 +8306,12 @@ func (m MaybeMapRepresentation_Listpairs) IsAbsent() bool { func (m MaybeMapRepresentation_Listpairs) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMapRepresentation_Listpairs) AsNode() ipld.Node { +func (m MaybeMapRepresentation_Listpairs) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -8326,32 +8326,32 @@ func (m MaybeMapRepresentation_Listpairs) Must() MapRepresentation_Listpairs { } var () -var _ ipld.Node = (MapRepresentation_Listpairs)(&_MapRepresentation_Listpairs{}) +var _ datamodel.Node = (MapRepresentation_Listpairs)(&_MapRepresentation_Listpairs{}) var _ schema.TypedNode = (MapRepresentation_Listpairs)(&_MapRepresentation_Listpairs{}) -func (MapRepresentation_Listpairs) Kind() ipld.Kind { - return ipld.Kind_Map +func (MapRepresentation_Listpairs) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n MapRepresentation_Listpairs) LookupByString(key string) (ipld.Node, error) { +func (n MapRepresentation_Listpairs) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n MapRepresentation_Listpairs) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n MapRepresentation_Listpairs) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (MapRepresentation_Listpairs) LookupByIndex(idx int64) (ipld.Node, error) { +func (MapRepresentation_Listpairs) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Listpairs"}.LookupByIndex(0) } -func (n MapRepresentation_Listpairs) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n MapRepresentation_Listpairs) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n MapRepresentation_Listpairs) MapIterator() ipld.MapIterator { +func (n MapRepresentation_Listpairs) MapIterator() datamodel.MapIterator { return &_MapRepresentation_Listpairs__MapItr{n, 0} } @@ -8360,15 +8360,15 @@ type _MapRepresentation_Listpairs__MapItr struct { idx int } -func (itr *_MapRepresentation_Listpairs__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_MapRepresentation_Listpairs__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_MapRepresentation_Listpairs__MapItr) Done() bool { return itr.idx >= 0 } -func (MapRepresentation_Listpairs) ListIterator() ipld.ListIterator { +func (MapRepresentation_Listpairs) ListIterator() datamodel.ListIterator { return nil } func (MapRepresentation_Listpairs) Length() int64 { @@ -8395,16 +8395,16 @@ func (MapRepresentation_Listpairs) AsString() (string, error) { func (MapRepresentation_Listpairs) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Listpairs"}.AsBytes() } -func (MapRepresentation_Listpairs) AsLink() (ipld.Link, error) { +func (MapRepresentation_Listpairs) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Listpairs"}.AsLink() } -func (MapRepresentation_Listpairs) Prototype() ipld.NodePrototype { +func (MapRepresentation_Listpairs) Prototype() datamodel.NodePrototype { return _MapRepresentation_Listpairs__Prototype{} } type _MapRepresentation_Listpairs__Prototype struct{} -func (_MapRepresentation_Listpairs__Prototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation_Listpairs__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation_Listpairs__Builder nb.Reset() return &nb @@ -8414,7 +8414,7 @@ type _MapRepresentation_Listpairs__Builder struct { _MapRepresentation_Listpairs__Assembler } -func (nb *_MapRepresentation_Listpairs__Builder) Build() ipld.Node { +func (nb *_MapRepresentation_Listpairs__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -8445,7 +8445,7 @@ var ( fieldBits__MapRepresentation_Listpairs_sufficient = 0 ) -func (na *_MapRepresentation_Listpairs__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation_Listpairs__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -8458,7 +8458,7 @@ func (na *_MapRepresentation_Listpairs__Assembler) BeginMap(int64) (ipld.MapAsse } return na, nil } -func (_MapRepresentation_Listpairs__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Listpairs__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs"}.BeginList(0) } func (na *_MapRepresentation_Listpairs__Assembler) AssignNull() error { @@ -8490,10 +8490,10 @@ func (_MapRepresentation_Listpairs__Assembler) AssignString(string) error { func (_MapRepresentation_Listpairs__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs"}.AssignBytes(nil) } -func (_MapRepresentation_Listpairs__Assembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Listpairs__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs"}.AssignLink(nil) } -func (na *_MapRepresentation_Listpairs__Assembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation_Listpairs__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -8513,8 +8513,8 @@ func (na *_MapRepresentation_Listpairs__Assembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Listpairs", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Listpairs", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -8531,7 +8531,7 @@ func (na *_MapRepresentation_Listpairs__Assembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_MapRepresentation_Listpairs__Assembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Listpairs__Assembler) Prototype() datamodel.NodePrototype { return _MapRepresentation_Listpairs__Prototype{} } func (ma *_MapRepresentation_Listpairs__Assembler) valueFinishTidy() bool { @@ -8540,7 +8540,7 @@ func (ma *_MapRepresentation_Listpairs__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_MapRepresentation_Listpairs__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation_Listpairs__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -8555,9 +8555,9 @@ func (ma *_MapRepresentation_Listpairs__Assembler) AssembleEntry(k string) (ipld case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs", Key: &_String{k}} } -func (ma *_MapRepresentation_Listpairs__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation_Listpairs__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -8575,7 +8575,7 @@ func (ma *_MapRepresentation_Listpairs__Assembler) AssembleKey() ipld.NodeAssemb ma.state = maState_midKey return (*_MapRepresentation_Listpairs__KeyAssembler)(ma) } -func (ma *_MapRepresentation_Listpairs__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation_Listpairs__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -8610,26 +8610,26 @@ func (ma *_MapRepresentation_Listpairs__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__MapRepresentation_Listpairs_sufficient != fieldBits__MapRepresentation_Listpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation_Listpairs__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation_Listpairs__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation_Listpairs__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation_Listpairs__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _MapRepresentation_Listpairs__KeyAssembler _MapRepresentation_Listpairs__Assembler -func (_MapRepresentation_Listpairs__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation_Listpairs__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation_Listpairs__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Listpairs__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation_Listpairs__KeyAssembler) AssignNull() error { @@ -8650,60 +8650,60 @@ func (ka *_MapRepresentation_Listpairs__KeyAssembler) AssignString(k string) err } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs", Key: &_String{k}} } } func (_MapRepresentation_Listpairs__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation_Listpairs__KeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Listpairs__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation_Listpairs__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation_Listpairs__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation_Listpairs__KeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Listpairs__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (MapRepresentation_Listpairs) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n MapRepresentation_Listpairs) Representation() ipld.Node { +func (n MapRepresentation_Listpairs) Representation() datamodel.Node { return (*_MapRepresentation_Listpairs__Repr)(n) } type _MapRepresentation_Listpairs__Repr _MapRepresentation_Listpairs var () -var _ ipld.Node = &_MapRepresentation_Listpairs__Repr{} +var _ datamodel.Node = &_MapRepresentation_Listpairs__Repr{} -func (_MapRepresentation_Listpairs__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_MapRepresentation_Listpairs__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_MapRepresentation_Listpairs__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_MapRepresentation_Listpairs__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_MapRepresentation_Listpairs__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_MapRepresentation_Listpairs__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_MapRepresentation_Listpairs__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_MapRepresentation_Listpairs__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr"}.LookupByIndex(0) } -func (n _MapRepresentation_Listpairs__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _MapRepresentation_Listpairs__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_MapRepresentation_Listpairs__Repr) MapIterator() ipld.MapIterator { +func (n *_MapRepresentation_Listpairs__Repr) MapIterator() datamodel.MapIterator { return &_MapRepresentation_Listpairs__ReprMapItr{n, 0} } @@ -8712,14 +8712,14 @@ type _MapRepresentation_Listpairs__ReprMapItr struct { idx int } -func (itr *_MapRepresentation_Listpairs__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_MapRepresentation_Listpairs__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_MapRepresentation_Listpairs__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_MapRepresentation_Listpairs__Repr) ListIterator() ipld.ListIterator { +func (_MapRepresentation_Listpairs__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_MapRepresentation_Listpairs__Repr) Length() int64 { @@ -8747,16 +8747,16 @@ func (_MapRepresentation_Listpairs__Repr) AsString() (string, error) { func (_MapRepresentation_Listpairs__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr"}.AsBytes() } -func (_MapRepresentation_Listpairs__Repr) AsLink() (ipld.Link, error) { +func (_MapRepresentation_Listpairs__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr"}.AsLink() } -func (_MapRepresentation_Listpairs__Repr) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Listpairs__Repr) Prototype() datamodel.NodePrototype { return _MapRepresentation_Listpairs__ReprPrototype{} } type _MapRepresentation_Listpairs__ReprPrototype struct{} -func (_MapRepresentation_Listpairs__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation_Listpairs__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation_Listpairs__ReprBuilder nb.Reset() return &nb @@ -8766,7 +8766,7 @@ type _MapRepresentation_Listpairs__ReprBuilder struct { _MapRepresentation_Listpairs__ReprAssembler } -func (nb *_MapRepresentation_Listpairs__ReprBuilder) Build() ipld.Node { +func (nb *_MapRepresentation_Listpairs__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -8792,7 +8792,7 @@ func (na *_MapRepresentation_Listpairs__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_MapRepresentation_Listpairs__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation_Listpairs__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -8805,7 +8805,7 @@ func (na *_MapRepresentation_Listpairs__ReprAssembler) BeginMap(int64) (ipld.Map } return na, nil } -func (_MapRepresentation_Listpairs__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Listpairs__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr"}.BeginList(0) } func (na *_MapRepresentation_Listpairs__ReprAssembler) AssignNull() error { @@ -8837,10 +8837,10 @@ func (_MapRepresentation_Listpairs__ReprAssembler) AssignString(string) error { func (_MapRepresentation_Listpairs__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr"}.AssignBytes(nil) } -func (_MapRepresentation_Listpairs__ReprAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Listpairs__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr"}.AssignLink(nil) } -func (na *_MapRepresentation_Listpairs__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation_Listpairs__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -8860,8 +8860,8 @@ func (na *_MapRepresentation_Listpairs__ReprAssembler) AssignNode(v ipld.Node) e *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -8878,7 +8878,7 @@ func (na *_MapRepresentation_Listpairs__ReprAssembler) AssignNode(v ipld.Node) e } return na.Finish() } -func (_MapRepresentation_Listpairs__ReprAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Listpairs__ReprAssembler) Prototype() datamodel.NodePrototype { return _MapRepresentation_Listpairs__ReprPrototype{} } func (ma *_MapRepresentation_Listpairs__ReprAssembler) valueFinishTidy() bool { @@ -8887,7 +8887,7 @@ func (ma *_MapRepresentation_Listpairs__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -8902,9 +8902,9 @@ func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleEntry(k string) ( case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr", Key: &_String{k}} } -func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -8922,7 +8922,7 @@ func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleKey() ipld.NodeAs ma.state = maState_midKey return (*_MapRepresentation_Listpairs__ReprKeyAssembler)(ma) } -func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation_Listpairs__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -8957,26 +8957,26 @@ func (ma *_MapRepresentation_Listpairs__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__MapRepresentation_Listpairs_sufficient != fieldBits__MapRepresentation_Listpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation_Listpairs__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation_Listpairs__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation_Listpairs__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation_Listpairs__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _MapRepresentation_Listpairs__ReprKeyAssembler _MapRepresentation_Listpairs__ReprAssembler -func (_MapRepresentation_Listpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation_Listpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation_Listpairs__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Listpairs__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation_Listpairs__ReprKeyAssembler) AssignNull() error { @@ -8995,22 +8995,22 @@ func (ka *_MapRepresentation_Listpairs__ReprKeyAssembler) AssignString(k string) if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr", Key: &_String{k}} } func (_MapRepresentation_Listpairs__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation_Listpairs__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Listpairs__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Listpairs.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation_Listpairs__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation_Listpairs__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation_Listpairs__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Listpairs__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -9029,12 +9029,12 @@ func (m MaybeMapRepresentation_Map) IsAbsent() bool { func (m MaybeMapRepresentation_Map) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMapRepresentation_Map) AsNode() ipld.Node { +func (m MaybeMapRepresentation_Map) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -9049,32 +9049,32 @@ func (m MaybeMapRepresentation_Map) Must() MapRepresentation_Map { } var () -var _ ipld.Node = (MapRepresentation_Map)(&_MapRepresentation_Map{}) +var _ datamodel.Node = (MapRepresentation_Map)(&_MapRepresentation_Map{}) var _ schema.TypedNode = (MapRepresentation_Map)(&_MapRepresentation_Map{}) -func (MapRepresentation_Map) Kind() ipld.Kind { - return ipld.Kind_Map +func (MapRepresentation_Map) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n MapRepresentation_Map) LookupByString(key string) (ipld.Node, error) { +func (n MapRepresentation_Map) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n MapRepresentation_Map) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n MapRepresentation_Map) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (MapRepresentation_Map) LookupByIndex(idx int64) (ipld.Node, error) { +func (MapRepresentation_Map) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Map"}.LookupByIndex(0) } -func (n MapRepresentation_Map) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n MapRepresentation_Map) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n MapRepresentation_Map) MapIterator() ipld.MapIterator { +func (n MapRepresentation_Map) MapIterator() datamodel.MapIterator { return &_MapRepresentation_Map__MapItr{n, 0} } @@ -9083,15 +9083,15 @@ type _MapRepresentation_Map__MapItr struct { idx int } -func (itr *_MapRepresentation_Map__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_MapRepresentation_Map__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_MapRepresentation_Map__MapItr) Done() bool { return itr.idx >= 0 } -func (MapRepresentation_Map) ListIterator() ipld.ListIterator { +func (MapRepresentation_Map) ListIterator() datamodel.ListIterator { return nil } func (MapRepresentation_Map) Length() int64 { @@ -9118,16 +9118,16 @@ func (MapRepresentation_Map) AsString() (string, error) { func (MapRepresentation_Map) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Map"}.AsBytes() } -func (MapRepresentation_Map) AsLink() (ipld.Link, error) { +func (MapRepresentation_Map) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Map"}.AsLink() } -func (MapRepresentation_Map) Prototype() ipld.NodePrototype { +func (MapRepresentation_Map) Prototype() datamodel.NodePrototype { return _MapRepresentation_Map__Prototype{} } type _MapRepresentation_Map__Prototype struct{} -func (_MapRepresentation_Map__Prototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation_Map__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation_Map__Builder nb.Reset() return &nb @@ -9137,7 +9137,7 @@ type _MapRepresentation_Map__Builder struct { _MapRepresentation_Map__Assembler } -func (nb *_MapRepresentation_Map__Builder) Build() ipld.Node { +func (nb *_MapRepresentation_Map__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -9168,7 +9168,7 @@ var ( fieldBits__MapRepresentation_Map_sufficient = 0 ) -func (na *_MapRepresentation_Map__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation_Map__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -9181,7 +9181,7 @@ func (na *_MapRepresentation_Map__Assembler) BeginMap(int64) (ipld.MapAssembler, } return na, nil } -func (_MapRepresentation_Map__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Map__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Map"}.BeginList(0) } func (na *_MapRepresentation_Map__Assembler) AssignNull() error { @@ -9213,10 +9213,10 @@ func (_MapRepresentation_Map__Assembler) AssignString(string) error { func (_MapRepresentation_Map__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Map"}.AssignBytes(nil) } -func (_MapRepresentation_Map__Assembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Map__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Map"}.AssignLink(nil) } -func (na *_MapRepresentation_Map__Assembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation_Map__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -9236,8 +9236,8 @@ func (na *_MapRepresentation_Map__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Map", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Map", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -9254,7 +9254,7 @@ func (na *_MapRepresentation_Map__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_MapRepresentation_Map__Assembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Map__Assembler) Prototype() datamodel.NodePrototype { return _MapRepresentation_Map__Prototype{} } func (ma *_MapRepresentation_Map__Assembler) valueFinishTidy() bool { @@ -9263,7 +9263,7 @@ func (ma *_MapRepresentation_Map__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_MapRepresentation_Map__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation_Map__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -9278,9 +9278,9 @@ func (ma *_MapRepresentation_Map__Assembler) AssembleEntry(k string) (ipld.NodeA case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map", Key: &_String{k}} } -func (ma *_MapRepresentation_Map__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation_Map__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -9298,7 +9298,7 @@ func (ma *_MapRepresentation_Map__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_MapRepresentation_Map__KeyAssembler)(ma) } -func (ma *_MapRepresentation_Map__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation_Map__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -9333,26 +9333,26 @@ func (ma *_MapRepresentation_Map__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__MapRepresentation_Map_sufficient != fieldBits__MapRepresentation_Map_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation_Map__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation_Map__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation_Map__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation_Map__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _MapRepresentation_Map__KeyAssembler _MapRepresentation_Map__Assembler -func (_MapRepresentation_Map__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation_Map__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation_Map__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Map__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation_Map__KeyAssembler) AssignNull() error { @@ -9373,60 +9373,60 @@ func (ka *_MapRepresentation_Map__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map", Key: &_String{k}} } } func (_MapRepresentation_Map__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation_Map__KeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Map__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation_Map__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation_Map__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation_Map__KeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Map__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (MapRepresentation_Map) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n MapRepresentation_Map) Representation() ipld.Node { +func (n MapRepresentation_Map) Representation() datamodel.Node { return (*_MapRepresentation_Map__Repr)(n) } type _MapRepresentation_Map__Repr _MapRepresentation_Map var () -var _ ipld.Node = &_MapRepresentation_Map__Repr{} +var _ datamodel.Node = &_MapRepresentation_Map__Repr{} -func (_MapRepresentation_Map__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_MapRepresentation_Map__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_MapRepresentation_Map__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_MapRepresentation_Map__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_MapRepresentation_Map__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_MapRepresentation_Map__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_MapRepresentation_Map__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_MapRepresentation_Map__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Map.Repr"}.LookupByIndex(0) } -func (n _MapRepresentation_Map__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _MapRepresentation_Map__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_MapRepresentation_Map__Repr) MapIterator() ipld.MapIterator { +func (n *_MapRepresentation_Map__Repr) MapIterator() datamodel.MapIterator { return &_MapRepresentation_Map__ReprMapItr{n, 0} } @@ -9435,14 +9435,14 @@ type _MapRepresentation_Map__ReprMapItr struct { idx int } -func (itr *_MapRepresentation_Map__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_MapRepresentation_Map__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_MapRepresentation_Map__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_MapRepresentation_Map__Repr) ListIterator() ipld.ListIterator { +func (_MapRepresentation_Map__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_MapRepresentation_Map__Repr) Length() int64 { @@ -9470,16 +9470,16 @@ func (_MapRepresentation_Map__Repr) AsString() (string, error) { func (_MapRepresentation_Map__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Map.Repr"}.AsBytes() } -func (_MapRepresentation_Map__Repr) AsLink() (ipld.Link, error) { +func (_MapRepresentation_Map__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Map.Repr"}.AsLink() } -func (_MapRepresentation_Map__Repr) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Map__Repr) Prototype() datamodel.NodePrototype { return _MapRepresentation_Map__ReprPrototype{} } type _MapRepresentation_Map__ReprPrototype struct{} -func (_MapRepresentation_Map__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation_Map__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation_Map__ReprBuilder nb.Reset() return &nb @@ -9489,7 +9489,7 @@ type _MapRepresentation_Map__ReprBuilder struct { _MapRepresentation_Map__ReprAssembler } -func (nb *_MapRepresentation_Map__ReprBuilder) Build() ipld.Node { +func (nb *_MapRepresentation_Map__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -9515,7 +9515,7 @@ func (na *_MapRepresentation_Map__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_MapRepresentation_Map__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation_Map__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -9528,7 +9528,7 @@ func (na *_MapRepresentation_Map__ReprAssembler) BeginMap(int64) (ipld.MapAssemb } return na, nil } -func (_MapRepresentation_Map__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Map__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr"}.BeginList(0) } func (na *_MapRepresentation_Map__ReprAssembler) AssignNull() error { @@ -9560,10 +9560,10 @@ func (_MapRepresentation_Map__ReprAssembler) AssignString(string) error { func (_MapRepresentation_Map__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr"}.AssignBytes(nil) } -func (_MapRepresentation_Map__ReprAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Map__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr"}.AssignLink(nil) } -func (na *_MapRepresentation_Map__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation_Map__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -9583,8 +9583,8 @@ func (na *_MapRepresentation_Map__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Map.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Map.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -9601,7 +9601,7 @@ func (na *_MapRepresentation_Map__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_MapRepresentation_Map__ReprAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Map__ReprAssembler) Prototype() datamodel.NodePrototype { return _MapRepresentation_Map__ReprPrototype{} } func (ma *_MapRepresentation_Map__ReprAssembler) valueFinishTidy() bool { @@ -9610,7 +9610,7 @@ func (ma *_MapRepresentation_Map__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_MapRepresentation_Map__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation_Map__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -9625,9 +9625,9 @@ func (ma *_MapRepresentation_Map__ReprAssembler) AssembleEntry(k string) (ipld.N case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map.Repr", Key: &_String{k}} } -func (ma *_MapRepresentation_Map__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation_Map__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -9645,7 +9645,7 @@ func (ma *_MapRepresentation_Map__ReprAssembler) AssembleKey() ipld.NodeAssemble ma.state = maState_midKey return (*_MapRepresentation_Map__ReprKeyAssembler)(ma) } -func (ma *_MapRepresentation_Map__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation_Map__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -9680,26 +9680,26 @@ func (ma *_MapRepresentation_Map__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__MapRepresentation_Map_sufficient != fieldBits__MapRepresentation_Map_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation_Map__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation_Map__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation_Map__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation_Map__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _MapRepresentation_Map__ReprKeyAssembler _MapRepresentation_Map__ReprAssembler -func (_MapRepresentation_Map__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation_Map__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation_Map__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Map__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation_Map__ReprKeyAssembler) AssignNull() error { @@ -9718,22 +9718,22 @@ func (ka *_MapRepresentation_Map__ReprKeyAssembler) AssignString(k string) error if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Map.Repr", Key: &_String{k}} } func (_MapRepresentation_Map__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation_Map__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Map__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Map.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation_Map__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation_Map__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation_Map__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Map__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -9759,12 +9759,12 @@ func (m MaybeMapRepresentation_Stringpairs) IsAbsent() bool { func (m MaybeMapRepresentation_Stringpairs) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMapRepresentation_Stringpairs) AsNode() ipld.Node { +func (m MaybeMapRepresentation_Stringpairs) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -9782,36 +9782,36 @@ var ( fieldName__MapRepresentation_Stringpairs_InnerDelim = _String{"innerDelim"} fieldName__MapRepresentation_Stringpairs_EntryDelim = _String{"entryDelim"} ) -var _ ipld.Node = (MapRepresentation_Stringpairs)(&_MapRepresentation_Stringpairs{}) +var _ datamodel.Node = (MapRepresentation_Stringpairs)(&_MapRepresentation_Stringpairs{}) var _ schema.TypedNode = (MapRepresentation_Stringpairs)(&_MapRepresentation_Stringpairs{}) -func (MapRepresentation_Stringpairs) Kind() ipld.Kind { - return ipld.Kind_Map +func (MapRepresentation_Stringpairs) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n MapRepresentation_Stringpairs) LookupByString(key string) (ipld.Node, error) { +func (n MapRepresentation_Stringpairs) LookupByString(key string) (datamodel.Node, error) { switch key { case "innerDelim": return &n.innerDelim, nil case "entryDelim": return &n.entryDelim, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n MapRepresentation_Stringpairs) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n MapRepresentation_Stringpairs) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (MapRepresentation_Stringpairs) LookupByIndex(idx int64) (ipld.Node, error) { +func (MapRepresentation_Stringpairs) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Stringpairs"}.LookupByIndex(0) } -func (n MapRepresentation_Stringpairs) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n MapRepresentation_Stringpairs) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n MapRepresentation_Stringpairs) MapIterator() ipld.MapIterator { +func (n MapRepresentation_Stringpairs) MapIterator() datamodel.MapIterator { return &_MapRepresentation_Stringpairs__MapItr{n, 0} } @@ -9820,9 +9820,9 @@ type _MapRepresentation_Stringpairs__MapItr struct { idx int } -func (itr *_MapRepresentation_Stringpairs__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_MapRepresentation_Stringpairs__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -9841,7 +9841,7 @@ func (itr *_MapRepresentation_Stringpairs__MapItr) Done() bool { return itr.idx >= 2 } -func (MapRepresentation_Stringpairs) ListIterator() ipld.ListIterator { +func (MapRepresentation_Stringpairs) ListIterator() datamodel.ListIterator { return nil } func (MapRepresentation_Stringpairs) Length() int64 { @@ -9868,16 +9868,16 @@ func (MapRepresentation_Stringpairs) AsString() (string, error) { func (MapRepresentation_Stringpairs) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Stringpairs"}.AsBytes() } -func (MapRepresentation_Stringpairs) AsLink() (ipld.Link, error) { +func (MapRepresentation_Stringpairs) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Stringpairs"}.AsLink() } -func (MapRepresentation_Stringpairs) Prototype() ipld.NodePrototype { +func (MapRepresentation_Stringpairs) Prototype() datamodel.NodePrototype { return _MapRepresentation_Stringpairs__Prototype{} } type _MapRepresentation_Stringpairs__Prototype struct{} -func (_MapRepresentation_Stringpairs__Prototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation_Stringpairs__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation_Stringpairs__Builder nb.Reset() return &nb @@ -9887,7 +9887,7 @@ type _MapRepresentation_Stringpairs__Builder struct { _MapRepresentation_Stringpairs__Assembler } -func (nb *_MapRepresentation_Stringpairs__Builder) Build() ipld.Node { +func (nb *_MapRepresentation_Stringpairs__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -9924,7 +9924,7 @@ var ( fieldBits__MapRepresentation_Stringpairs_sufficient = 0 + 1<<0 + 1<<1 ) -func (na *_MapRepresentation_Stringpairs__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation_Stringpairs__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -9937,7 +9937,7 @@ func (na *_MapRepresentation_Stringpairs__Assembler) BeginMap(int64) (ipld.MapAs } return na, nil } -func (_MapRepresentation_Stringpairs__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Stringpairs__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs"}.BeginList(0) } func (na *_MapRepresentation_Stringpairs__Assembler) AssignNull() error { @@ -9969,10 +9969,10 @@ func (_MapRepresentation_Stringpairs__Assembler) AssignString(string) error { func (_MapRepresentation_Stringpairs__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs"}.AssignBytes(nil) } -func (_MapRepresentation_Stringpairs__Assembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Stringpairs__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs"}.AssignLink(nil) } -func (na *_MapRepresentation_Stringpairs__Assembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation_Stringpairs__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -9992,8 +9992,8 @@ func (na *_MapRepresentation_Stringpairs__Assembler) AssignNode(v ipld.Node) err *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Stringpairs", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Stringpairs", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -10010,7 +10010,7 @@ func (na *_MapRepresentation_Stringpairs__Assembler) AssignNode(v ipld.Node) err } return na.Finish() } -func (_MapRepresentation_Stringpairs__Assembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Stringpairs__Assembler) Prototype() datamodel.NodePrototype { return _MapRepresentation_Stringpairs__Prototype{} } func (ma *_MapRepresentation_Stringpairs__Assembler) valueFinishTidy() bool { @@ -10039,7 +10039,7 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -10057,7 +10057,7 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (ip switch k { case "innerDelim": if ma.s&fieldBit__MapRepresentation_Stringpairs_InnerDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim} } ma.s += fieldBit__MapRepresentation_Stringpairs_InnerDelim ma.state = maState_midValue @@ -10067,7 +10067,7 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (ip return &ma.ca_innerDelim, nil case "entryDelim": if ma.s&fieldBit__MapRepresentation_Stringpairs_EntryDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim} } ma.s += fieldBit__MapRepresentation_Stringpairs_EntryDelim ma.state = maState_midValue @@ -10076,9 +10076,9 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (ip ma.ca_entryDelim.m = &ma.cm return &ma.ca_entryDelim, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs", Key: &_String{k}} } -func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -10096,7 +10096,7 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleKey() ipld.NodeAsse ma.state = maState_midKey return (*_MapRepresentation_Stringpairs__KeyAssembler)(ma) } -func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation_Stringpairs__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -10139,7 +10139,7 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__MapRepresentation_Stringpairs_sufficient != fieldBits__MapRepresentation_Stringpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__MapRepresentation_Stringpairs_InnerDelim == 0 { err.Missing = append(err.Missing, "innerDelim") } @@ -10152,19 +10152,19 @@ func (ma *_MapRepresentation_Stringpairs__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation_Stringpairs__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation_Stringpairs__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation_Stringpairs__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation_Stringpairs__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _MapRepresentation_Stringpairs__KeyAssembler _MapRepresentation_Stringpairs__Assembler -func (_MapRepresentation_Stringpairs__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation_Stringpairs__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation_Stringpairs__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Stringpairs__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation_Stringpairs__KeyAssembler) AssignNull() error { @@ -10186,7 +10186,7 @@ func (ka *_MapRepresentation_Stringpairs__KeyAssembler) AssignString(k string) e switch k { case "innerDelim": if ka.s&fieldBit__MapRepresentation_Stringpairs_InnerDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim} } ka.s += fieldBit__MapRepresentation_Stringpairs_InnerDelim ka.state = maState_expectValue @@ -10194,36 +10194,36 @@ func (ka *_MapRepresentation_Stringpairs__KeyAssembler) AssignString(k string) e return nil case "entryDelim": if ka.s&fieldBit__MapRepresentation_Stringpairs_EntryDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim} } ka.s += fieldBit__MapRepresentation_Stringpairs_EntryDelim ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs", Key: &_String{k}} } } func (_MapRepresentation_Stringpairs__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation_Stringpairs__KeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Stringpairs__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation_Stringpairs__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation_Stringpairs__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation_Stringpairs__KeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Stringpairs__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (MapRepresentation_Stringpairs) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n MapRepresentation_Stringpairs) Representation() ipld.Node { +func (n MapRepresentation_Stringpairs) Representation() datamodel.Node { return (*_MapRepresentation_Stringpairs__Repr)(n) } @@ -10233,35 +10233,35 @@ var ( fieldName__MapRepresentation_Stringpairs_InnerDelim_serial = _String{"innerDelim"} fieldName__MapRepresentation_Stringpairs_EntryDelim_serial = _String{"entryDelim"} ) -var _ ipld.Node = &_MapRepresentation_Stringpairs__Repr{} +var _ datamodel.Node = &_MapRepresentation_Stringpairs__Repr{} -func (_MapRepresentation_Stringpairs__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_MapRepresentation_Stringpairs__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_MapRepresentation_Stringpairs__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_MapRepresentation_Stringpairs__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "innerDelim": return n.innerDelim.Representation(), nil case "entryDelim": return n.entryDelim.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_MapRepresentation_Stringpairs__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_MapRepresentation_Stringpairs__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_MapRepresentation_Stringpairs__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_MapRepresentation_Stringpairs__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr"}.LookupByIndex(0) } -func (n _MapRepresentation_Stringpairs__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _MapRepresentation_Stringpairs__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_MapRepresentation_Stringpairs__Repr) MapIterator() ipld.MapIterator { +func (n *_MapRepresentation_Stringpairs__Repr) MapIterator() datamodel.MapIterator { return &_MapRepresentation_Stringpairs__ReprMapItr{n, 0} } @@ -10270,9 +10270,9 @@ type _MapRepresentation_Stringpairs__ReprMapItr struct { idx int } -func (itr *_MapRepresentation_Stringpairs__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_MapRepresentation_Stringpairs__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -10290,7 +10290,7 @@ func (itr *_MapRepresentation_Stringpairs__ReprMapItr) Next() (k ipld.Node, v ip func (itr *_MapRepresentation_Stringpairs__ReprMapItr) Done() bool { return itr.idx >= 2 } -func (_MapRepresentation_Stringpairs__Repr) ListIterator() ipld.ListIterator { +func (_MapRepresentation_Stringpairs__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_MapRepresentation_Stringpairs__Repr) Length() int64 { @@ -10318,16 +10318,16 @@ func (_MapRepresentation_Stringpairs__Repr) AsString() (string, error) { func (_MapRepresentation_Stringpairs__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr"}.AsBytes() } -func (_MapRepresentation_Stringpairs__Repr) AsLink() (ipld.Link, error) { +func (_MapRepresentation_Stringpairs__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr"}.AsLink() } -func (_MapRepresentation_Stringpairs__Repr) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Stringpairs__Repr) Prototype() datamodel.NodePrototype { return _MapRepresentation_Stringpairs__ReprPrototype{} } type _MapRepresentation_Stringpairs__ReprPrototype struct{} -func (_MapRepresentation_Stringpairs__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_MapRepresentation_Stringpairs__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _MapRepresentation_Stringpairs__ReprBuilder nb.Reset() return &nb @@ -10337,7 +10337,7 @@ type _MapRepresentation_Stringpairs__ReprBuilder struct { _MapRepresentation_Stringpairs__ReprAssembler } -func (nb *_MapRepresentation_Stringpairs__ReprBuilder) Build() ipld.Node { +func (nb *_MapRepresentation_Stringpairs__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -10367,7 +10367,7 @@ func (na *_MapRepresentation_Stringpairs__ReprAssembler) reset() { na.ca_innerDelim.reset() na.ca_entryDelim.reset() } -func (na *_MapRepresentation_Stringpairs__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_MapRepresentation_Stringpairs__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -10380,7 +10380,7 @@ func (na *_MapRepresentation_Stringpairs__ReprAssembler) BeginMap(int64) (ipld.M } return na, nil } -func (_MapRepresentation_Stringpairs__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Stringpairs__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr"}.BeginList(0) } func (na *_MapRepresentation_Stringpairs__ReprAssembler) AssignNull() error { @@ -10412,10 +10412,10 @@ func (_MapRepresentation_Stringpairs__ReprAssembler) AssignString(string) error func (_MapRepresentation_Stringpairs__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr"}.AssignBytes(nil) } -func (_MapRepresentation_Stringpairs__ReprAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Stringpairs__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr"}.AssignLink(nil) } -func (na *_MapRepresentation_Stringpairs__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_MapRepresentation_Stringpairs__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -10435,8 +10435,8 @@ func (na *_MapRepresentation_Stringpairs__ReprAssembler) AssignNode(v ipld.Node) *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -10453,7 +10453,7 @@ func (na *_MapRepresentation_Stringpairs__ReprAssembler) AssignNode(v ipld.Node) } return na.Finish() } -func (_MapRepresentation_Stringpairs__ReprAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Stringpairs__ReprAssembler) Prototype() datamodel.NodePrototype { return _MapRepresentation_Stringpairs__ReprPrototype{} } func (ma *_MapRepresentation_Stringpairs__ReprAssembler) valueFinishTidy() bool { @@ -10480,7 +10480,7 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) valueFinishTidy() bool panic("unreachable") } } -func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -10498,7 +10498,7 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) switch k { case "innerDelim": if ma.s&fieldBit__MapRepresentation_Stringpairs_InnerDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim_serial} } ma.s += fieldBit__MapRepresentation_Stringpairs_InnerDelim ma.state = maState_midValue @@ -10508,7 +10508,7 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) return &ma.ca_innerDelim, nil case "entryDelim": if ma.s&fieldBit__MapRepresentation_Stringpairs_EntryDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim_serial} } ma.s += fieldBit__MapRepresentation_Stringpairs_EntryDelim ma.state = maState_midValue @@ -10518,9 +10518,9 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) return &ma.ca_entryDelim, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr", Key: &_String{k}} } -func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -10538,7 +10538,7 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleKey() ipld.Node ma.state = maState_midKey return (*_MapRepresentation_Stringpairs__ReprKeyAssembler)(ma) } -func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_MapRepresentation_Stringpairs__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -10581,7 +10581,7 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__MapRepresentation_Stringpairs_sufficient != fieldBits__MapRepresentation_Stringpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__MapRepresentation_Stringpairs_InnerDelim == 0 { err.Missing = append(err.Missing, "innerDelim") } @@ -10594,19 +10594,19 @@ func (ma *_MapRepresentation_Stringpairs__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_MapRepresentation_Stringpairs__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_MapRepresentation_Stringpairs__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_MapRepresentation_Stringpairs__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_MapRepresentation_Stringpairs__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _MapRepresentation_Stringpairs__ReprKeyAssembler _MapRepresentation_Stringpairs__ReprAssembler -func (_MapRepresentation_Stringpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_MapRepresentation_Stringpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr.KeyAssembler"}.BeginMap(0) } -func (_MapRepresentation_Stringpairs__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_MapRepresentation_Stringpairs__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr.KeyAssembler"}.BeginList(0) } func (na *_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignNull() error { @@ -10628,7 +10628,7 @@ func (ka *_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignString(k strin switch k { case "innerDelim": if ka.s&fieldBit__MapRepresentation_Stringpairs_InnerDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_InnerDelim_serial} } ka.s += fieldBit__MapRepresentation_Stringpairs_InnerDelim ka.state = maState_expectValue @@ -10636,29 +10636,29 @@ func (ka *_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignString(k strin return nil case "entryDelim": if ka.s&fieldBit__MapRepresentation_Stringpairs_EntryDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__MapRepresentation_Stringpairs_EntryDelim_serial} } ka.s += fieldBit__MapRepresentation_Stringpairs_EntryDelim ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr", Key: &_String{k}} } func (_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.MapRepresentation_Stringpairs.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_MapRepresentation_Stringpairs__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_MapRepresentation_Stringpairs__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_MapRepresentation_Stringpairs__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -10720,12 +10720,12 @@ func (m MaybeMap__EnumValue__Unit) IsAbsent() bool { func (m MaybeMap__EnumValue__Unit) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMap__EnumValue__Unit) AsNode() ipld.Node { +func (m MaybeMap__EnumValue__Unit) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -10739,42 +10739,42 @@ func (m MaybeMap__EnumValue__Unit) Must() Map__EnumValue__Unit { return &m.v } -var _ ipld.Node = (Map__EnumValue__Unit)(&_Map__EnumValue__Unit{}) +var _ datamodel.Node = (Map__EnumValue__Unit)(&_Map__EnumValue__Unit{}) var _ schema.TypedNode = (Map__EnumValue__Unit)(&_Map__EnumValue__Unit{}) -func (Map__EnumValue__Unit) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map__EnumValue__Unit) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Map__EnumValue__Unit) LookupByString(k string) (ipld.Node, error) { +func (n Map__EnumValue__Unit) LookupByString(k string) (datamodel.Node, error) { var k2 _EnumValue if err := (_EnumValue__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n Map__EnumValue__Unit) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n Map__EnumValue__Unit) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(EnumValue) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.Map__EnumValue__Unit", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.Map__EnumValue__Unit", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (Map__EnumValue__Unit) LookupByIndex(idx int64) (ipld.Node, error) { +func (Map__EnumValue__Unit) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__EnumValue__Unit"}.LookupByIndex(0) } -func (n Map__EnumValue__Unit) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Map__EnumValue__Unit) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Map__EnumValue__Unit) MapIterator() ipld.MapIterator { +func (n Map__EnumValue__Unit) MapIterator() datamodel.MapIterator { return &_Map__EnumValue__Unit__MapItr{n, 0} } @@ -10783,9 +10783,9 @@ type _Map__EnumValue__Unit__MapItr struct { idx int } -func (itr *_Map__EnumValue__Unit__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Map__EnumValue__Unit__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -10797,7 +10797,7 @@ func (itr *_Map__EnumValue__Unit__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (Map__EnumValue__Unit) ListIterator() ipld.ListIterator { +func (Map__EnumValue__Unit) ListIterator() datamodel.ListIterator { return nil } func (n Map__EnumValue__Unit) Length() int64 { @@ -10824,16 +10824,16 @@ func (Map__EnumValue__Unit) AsString() (string, error) { func (Map__EnumValue__Unit) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__EnumValue__Unit"}.AsBytes() } -func (Map__EnumValue__Unit) AsLink() (ipld.Link, error) { +func (Map__EnumValue__Unit) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__EnumValue__Unit"}.AsLink() } -func (Map__EnumValue__Unit) Prototype() ipld.NodePrototype { +func (Map__EnumValue__Unit) Prototype() datamodel.NodePrototype { return _Map__EnumValue__Unit__Prototype{} } type _Map__EnumValue__Unit__Prototype struct{} -func (_Map__EnumValue__Unit__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Map__EnumValue__Unit__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__EnumValue__Unit__Builder nb.Reset() return &nb @@ -10843,7 +10843,7 @@ type _Map__EnumValue__Unit__Builder struct { _Map__EnumValue__Unit__Assembler } -func (nb *_Map__EnumValue__Unit__Builder) Build() ipld.Node { +func (nb *_Map__EnumValue__Unit__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -10870,7 +10870,7 @@ func (na *_Map__EnumValue__Unit__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__EnumValue__Unit__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__EnumValue__Unit__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -10885,7 +10885,7 @@ func (na *_Map__EnumValue__Unit__Assembler) BeginMap(sizeHint int64) (ipld.MapAs na.w.t = make([]_Map__EnumValue__Unit__entry, 0, sizeHint) return na, nil } -func (_Map__EnumValue__Unit__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__EnumValue__Unit__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__EnumValue__Unit"}.BeginList(0) } func (na *_Map__EnumValue__Unit__Assembler) AssignNull() error { @@ -10917,10 +10917,10 @@ func (_Map__EnumValue__Unit__Assembler) AssignString(string) error { func (_Map__EnumValue__Unit__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__EnumValue__Unit"}.AssignBytes(nil) } -func (_Map__EnumValue__Unit__Assembler) AssignLink(ipld.Link) error { +func (_Map__EnumValue__Unit__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__EnumValue__Unit"}.AssignLink(nil) } -func (na *_Map__EnumValue__Unit__Assembler) AssignNode(v ipld.Node) error { +func (na *_Map__EnumValue__Unit__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -10935,8 +10935,8 @@ func (na *_Map__EnumValue__Unit__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__EnumValue__Unit", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__EnumValue__Unit", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -10953,7 +10953,7 @@ func (na *_Map__EnumValue__Unit__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__EnumValue__Unit__Assembler) Prototype() ipld.NodePrototype { +func (_Map__EnumValue__Unit__Assembler) Prototype() datamodel.NodePrototype { return _Map__EnumValue__Unit__Prototype{} } func (ma *_Map__EnumValue__Unit__Assembler) keyFinishTidy() bool { @@ -10984,7 +10984,7 @@ func (ma *_Map__EnumValue__Unit__Assembler) valueFinishTidy() bool { return false } } -func (ma *_Map__EnumValue__Unit__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__EnumValue__Unit__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -11005,7 +11005,7 @@ func (ma *_Map__EnumValue__Unit__Assembler) AssembleEntry(k string) (ipld.NodeAs return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__EnumValue__Unit__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -11016,7 +11016,7 @@ func (ma *_Map__EnumValue__Unit__Assembler) AssembleEntry(k string) (ipld.NodeAs ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__EnumValue__Unit__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__EnumValue__Unit__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -11037,7 +11037,7 @@ func (ma *_Map__EnumValue__Unit__Assembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__EnumValue__Unit__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__EnumValue__Unit__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -11074,55 +11074,55 @@ func (ma *_Map__EnumValue__Unit__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__EnumValue__Unit__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__EnumValue__Unit__Assembler) KeyPrototype() datamodel.NodePrototype { return _EnumValue__Prototype{} } -func (ma *_Map__EnumValue__Unit__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__EnumValue__Unit__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Unit__Prototype{} } func (Map__EnumValue__Unit) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Map__EnumValue__Unit) Representation() ipld.Node { +func (n Map__EnumValue__Unit) Representation() datamodel.Node { return (*_Map__EnumValue__Unit__Repr)(n) } type _Map__EnumValue__Unit__Repr _Map__EnumValue__Unit -var _ ipld.Node = &_Map__EnumValue__Unit__Repr{} +var _ datamodel.Node = &_Map__EnumValue__Unit__Repr{} -func (_Map__EnumValue__Unit__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Map__EnumValue__Unit__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_Map__EnumValue__Unit__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_Map__EnumValue__Unit__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (Map__EnumValue__Unit)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Unit).Representation(), nil } -func (nr *_Map__EnumValue__Unit__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_Map__EnumValue__Unit__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (Map__EnumValue__Unit)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Unit).Representation(), nil } -func (_Map__EnumValue__Unit__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Map__EnumValue__Unit__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__EnumValue__Unit.Repr"}.LookupByIndex(0) } -func (n _Map__EnumValue__Unit__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Map__EnumValue__Unit__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_Map__EnumValue__Unit__Repr) MapIterator() ipld.MapIterator { +func (nr *_Map__EnumValue__Unit__Repr) MapIterator() datamodel.MapIterator { return &_Map__EnumValue__Unit__ReprMapItr{(Map__EnumValue__Unit)(nr), 0} } type _Map__EnumValue__Unit__ReprMapItr _Map__EnumValue__Unit__MapItr -func (itr *_Map__EnumValue__Unit__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_Map__EnumValue__Unit__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_Map__EnumValue__Unit__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(Unit).Representation(), nil @@ -11131,7 +11131,7 @@ func (itr *_Map__EnumValue__Unit__ReprMapItr) Done() bool { return (*_Map__EnumValue__Unit__MapItr)(itr).Done() } -func (_Map__EnumValue__Unit__Repr) ListIterator() ipld.ListIterator { +func (_Map__EnumValue__Unit__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Map__EnumValue__Unit__Repr) Length() int64 { @@ -11158,16 +11158,16 @@ func (_Map__EnumValue__Unit__Repr) AsString() (string, error) { func (_Map__EnumValue__Unit__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__EnumValue__Unit.Repr"}.AsBytes() } -func (_Map__EnumValue__Unit__Repr) AsLink() (ipld.Link, error) { +func (_Map__EnumValue__Unit__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__EnumValue__Unit.Repr"}.AsLink() } -func (_Map__EnumValue__Unit__Repr) Prototype() ipld.NodePrototype { +func (_Map__EnumValue__Unit__Repr) Prototype() datamodel.NodePrototype { return _Map__EnumValue__Unit__ReprPrototype{} } type _Map__EnumValue__Unit__ReprPrototype struct{} -func (_Map__EnumValue__Unit__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Map__EnumValue__Unit__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__EnumValue__Unit__ReprBuilder nb.Reset() return &nb @@ -11177,7 +11177,7 @@ type _Map__EnumValue__Unit__ReprBuilder struct { _Map__EnumValue__Unit__ReprAssembler } -func (nb *_Map__EnumValue__Unit__ReprBuilder) Build() ipld.Node { +func (nb *_Map__EnumValue__Unit__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -11204,7 +11204,7 @@ func (na *_Map__EnumValue__Unit__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__EnumValue__Unit__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__EnumValue__Unit__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -11219,7 +11219,7 @@ func (na *_Map__EnumValue__Unit__ReprAssembler) BeginMap(sizeHint int64) (ipld.M na.w.t = make([]_Map__EnumValue__Unit__entry, 0, sizeHint) return na, nil } -func (_Map__EnumValue__Unit__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__EnumValue__Unit__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__EnumValue__Unit.Repr"}.BeginList(0) } func (na *_Map__EnumValue__Unit__ReprAssembler) AssignNull() error { @@ -11251,10 +11251,10 @@ func (_Map__EnumValue__Unit__ReprAssembler) AssignString(string) error { func (_Map__EnumValue__Unit__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__EnumValue__Unit.Repr"}.AssignBytes(nil) } -func (_Map__EnumValue__Unit__ReprAssembler) AssignLink(ipld.Link) error { +func (_Map__EnumValue__Unit__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__EnumValue__Unit.Repr"}.AssignLink(nil) } -func (na *_Map__EnumValue__Unit__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Map__EnumValue__Unit__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -11269,8 +11269,8 @@ func (na *_Map__EnumValue__Unit__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__EnumValue__Unit.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__EnumValue__Unit.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -11287,7 +11287,7 @@ func (na *_Map__EnumValue__Unit__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__EnumValue__Unit__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Map__EnumValue__Unit__ReprAssembler) Prototype() datamodel.NodePrototype { return _Map__EnumValue__Unit__ReprPrototype{} } func (ma *_Map__EnumValue__Unit__ReprAssembler) keyFinishTidy() bool { @@ -11318,7 +11318,7 @@ func (ma *_Map__EnumValue__Unit__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -11339,7 +11339,7 @@ func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleEntry(k string) (ipld.No return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__EnumValue__Unit__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -11350,7 +11350,7 @@ func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleEntry(k string) (ipld.No ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -11371,7 +11371,7 @@ func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleKey() ipld.NodeAssembler ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__EnumValue__Unit__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -11408,10 +11408,10 @@ func (ma *_Map__EnumValue__Unit__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__EnumValue__Unit__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__EnumValue__Unit__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _EnumValue__ReprPrototype{} } -func (ma *_Map__EnumValue__Unit__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__EnumValue__Unit__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Unit__ReprPrototype{} } @@ -11473,12 +11473,12 @@ func (m MaybeMap__FieldName__StructField) IsAbsent() bool { func (m MaybeMap__FieldName__StructField) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMap__FieldName__StructField) AsNode() ipld.Node { +func (m MaybeMap__FieldName__StructField) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -11492,42 +11492,42 @@ func (m MaybeMap__FieldName__StructField) Must() Map__FieldName__StructField { return &m.v } -var _ ipld.Node = (Map__FieldName__StructField)(&_Map__FieldName__StructField{}) +var _ datamodel.Node = (Map__FieldName__StructField)(&_Map__FieldName__StructField{}) var _ schema.TypedNode = (Map__FieldName__StructField)(&_Map__FieldName__StructField{}) -func (Map__FieldName__StructField) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map__FieldName__StructField) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Map__FieldName__StructField) LookupByString(k string) (ipld.Node, error) { +func (n Map__FieldName__StructField) LookupByString(k string) (datamodel.Node, error) { var k2 _FieldName if err := (_FieldName__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n Map__FieldName__StructField) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n Map__FieldName__StructField) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(FieldName) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.Map__FieldName__StructField", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.Map__FieldName__StructField", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (Map__FieldName__StructField) LookupByIndex(idx int64) (ipld.Node, error) { +func (Map__FieldName__StructField) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructField"}.LookupByIndex(0) } -func (n Map__FieldName__StructField) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Map__FieldName__StructField) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Map__FieldName__StructField) MapIterator() ipld.MapIterator { +func (n Map__FieldName__StructField) MapIterator() datamodel.MapIterator { return &_Map__FieldName__StructField__MapItr{n, 0} } @@ -11536,9 +11536,9 @@ type _Map__FieldName__StructField__MapItr struct { idx int } -func (itr *_Map__FieldName__StructField__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Map__FieldName__StructField__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -11550,7 +11550,7 @@ func (itr *_Map__FieldName__StructField__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (Map__FieldName__StructField) ListIterator() ipld.ListIterator { +func (Map__FieldName__StructField) ListIterator() datamodel.ListIterator { return nil } func (n Map__FieldName__StructField) Length() int64 { @@ -11577,16 +11577,16 @@ func (Map__FieldName__StructField) AsString() (string, error) { func (Map__FieldName__StructField) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructField"}.AsBytes() } -func (Map__FieldName__StructField) AsLink() (ipld.Link, error) { +func (Map__FieldName__StructField) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructField"}.AsLink() } -func (Map__FieldName__StructField) Prototype() ipld.NodePrototype { +func (Map__FieldName__StructField) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructField__Prototype{} } type _Map__FieldName__StructField__Prototype struct{} -func (_Map__FieldName__StructField__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Map__FieldName__StructField__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__FieldName__StructField__Builder nb.Reset() return &nb @@ -11596,7 +11596,7 @@ type _Map__FieldName__StructField__Builder struct { _Map__FieldName__StructField__Assembler } -func (nb *_Map__FieldName__StructField__Builder) Build() ipld.Node { +func (nb *_Map__FieldName__StructField__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -11623,7 +11623,7 @@ func (na *_Map__FieldName__StructField__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__FieldName__StructField__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__FieldName__StructField__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -11638,7 +11638,7 @@ func (na *_Map__FieldName__StructField__Assembler) BeginMap(sizeHint int64) (ipl na.w.t = make([]_Map__FieldName__StructField__entry, 0, sizeHint) return na, nil } -func (_Map__FieldName__StructField__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__FieldName__StructField__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructField"}.BeginList(0) } func (na *_Map__FieldName__StructField__Assembler) AssignNull() error { @@ -11670,10 +11670,10 @@ func (_Map__FieldName__StructField__Assembler) AssignString(string) error { func (_Map__FieldName__StructField__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructField"}.AssignBytes(nil) } -func (_Map__FieldName__StructField__Assembler) AssignLink(ipld.Link) error { +func (_Map__FieldName__StructField__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructField"}.AssignLink(nil) } -func (na *_Map__FieldName__StructField__Assembler) AssignNode(v ipld.Node) error { +func (na *_Map__FieldName__StructField__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -11688,8 +11688,8 @@ func (na *_Map__FieldName__StructField__Assembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructField", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructField", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -11706,7 +11706,7 @@ func (na *_Map__FieldName__StructField__Assembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_Map__FieldName__StructField__Assembler) Prototype() ipld.NodePrototype { +func (_Map__FieldName__StructField__Assembler) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructField__Prototype{} } func (ma *_Map__FieldName__StructField__Assembler) keyFinishTidy() bool { @@ -11737,7 +11737,7 @@ func (ma *_Map__FieldName__StructField__Assembler) valueFinishTidy() bool { return false } } -func (ma *_Map__FieldName__StructField__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__FieldName__StructField__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -11758,7 +11758,7 @@ func (ma *_Map__FieldName__StructField__Assembler) AssembleEntry(k string) (ipld return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__FieldName__StructField__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -11769,7 +11769,7 @@ func (ma *_Map__FieldName__StructField__Assembler) AssembleEntry(k string) (ipld ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__FieldName__StructField__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructField__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -11790,7 +11790,7 @@ func (ma *_Map__FieldName__StructField__Assembler) AssembleKey() ipld.NodeAssemb ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__FieldName__StructField__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructField__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -11827,55 +11827,55 @@ func (ma *_Map__FieldName__StructField__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__FieldName__StructField__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__FieldName__StructField__Assembler) KeyPrototype() datamodel.NodePrototype { return _FieldName__Prototype{} } -func (ma *_Map__FieldName__StructField__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__FieldName__StructField__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _StructField__Prototype{} } func (Map__FieldName__StructField) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Map__FieldName__StructField) Representation() ipld.Node { +func (n Map__FieldName__StructField) Representation() datamodel.Node { return (*_Map__FieldName__StructField__Repr)(n) } type _Map__FieldName__StructField__Repr _Map__FieldName__StructField -var _ ipld.Node = &_Map__FieldName__StructField__Repr{} +var _ datamodel.Node = &_Map__FieldName__StructField__Repr{} -func (_Map__FieldName__StructField__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Map__FieldName__StructField__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_Map__FieldName__StructField__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_Map__FieldName__StructField__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (Map__FieldName__StructField)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(StructField).Representation(), nil } -func (nr *_Map__FieldName__StructField__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_Map__FieldName__StructField__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (Map__FieldName__StructField)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(StructField).Representation(), nil } -func (_Map__FieldName__StructField__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Map__FieldName__StructField__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructField.Repr"}.LookupByIndex(0) } -func (n _Map__FieldName__StructField__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Map__FieldName__StructField__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_Map__FieldName__StructField__Repr) MapIterator() ipld.MapIterator { +func (nr *_Map__FieldName__StructField__Repr) MapIterator() datamodel.MapIterator { return &_Map__FieldName__StructField__ReprMapItr{(Map__FieldName__StructField)(nr), 0} } type _Map__FieldName__StructField__ReprMapItr _Map__FieldName__StructField__MapItr -func (itr *_Map__FieldName__StructField__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_Map__FieldName__StructField__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_Map__FieldName__StructField__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(StructField).Representation(), nil @@ -11884,7 +11884,7 @@ func (itr *_Map__FieldName__StructField__ReprMapItr) Done() bool { return (*_Map__FieldName__StructField__MapItr)(itr).Done() } -func (_Map__FieldName__StructField__Repr) ListIterator() ipld.ListIterator { +func (_Map__FieldName__StructField__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Map__FieldName__StructField__Repr) Length() int64 { @@ -11911,16 +11911,16 @@ func (_Map__FieldName__StructField__Repr) AsString() (string, error) { func (_Map__FieldName__StructField__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructField.Repr"}.AsBytes() } -func (_Map__FieldName__StructField__Repr) AsLink() (ipld.Link, error) { +func (_Map__FieldName__StructField__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructField.Repr"}.AsLink() } -func (_Map__FieldName__StructField__Repr) Prototype() ipld.NodePrototype { +func (_Map__FieldName__StructField__Repr) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructField__ReprPrototype{} } type _Map__FieldName__StructField__ReprPrototype struct{} -func (_Map__FieldName__StructField__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Map__FieldName__StructField__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__FieldName__StructField__ReprBuilder nb.Reset() return &nb @@ -11930,7 +11930,7 @@ type _Map__FieldName__StructField__ReprBuilder struct { _Map__FieldName__StructField__ReprAssembler } -func (nb *_Map__FieldName__StructField__ReprBuilder) Build() ipld.Node { +func (nb *_Map__FieldName__StructField__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -11957,7 +11957,7 @@ func (na *_Map__FieldName__StructField__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__FieldName__StructField__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__FieldName__StructField__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -11972,7 +11972,7 @@ func (na *_Map__FieldName__StructField__ReprAssembler) BeginMap(sizeHint int64) na.w.t = make([]_Map__FieldName__StructField__entry, 0, sizeHint) return na, nil } -func (_Map__FieldName__StructField__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__FieldName__StructField__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructField.Repr"}.BeginList(0) } func (na *_Map__FieldName__StructField__ReprAssembler) AssignNull() error { @@ -12004,10 +12004,10 @@ func (_Map__FieldName__StructField__ReprAssembler) AssignString(string) error { func (_Map__FieldName__StructField__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructField.Repr"}.AssignBytes(nil) } -func (_Map__FieldName__StructField__ReprAssembler) AssignLink(ipld.Link) error { +func (_Map__FieldName__StructField__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructField.Repr"}.AssignLink(nil) } -func (na *_Map__FieldName__StructField__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Map__FieldName__StructField__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -12022,8 +12022,8 @@ func (na *_Map__FieldName__StructField__ReprAssembler) AssignNode(v ipld.Node) e *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructField.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructField.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -12040,7 +12040,7 @@ func (na *_Map__FieldName__StructField__ReprAssembler) AssignNode(v ipld.Node) e } return na.Finish() } -func (_Map__FieldName__StructField__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Map__FieldName__StructField__ReprAssembler) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructField__ReprPrototype{} } func (ma *_Map__FieldName__StructField__ReprAssembler) keyFinishTidy() bool { @@ -12071,7 +12071,7 @@ func (ma *_Map__FieldName__StructField__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -12092,7 +12092,7 @@ func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleEntry(k string) ( return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__FieldName__StructField__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -12103,7 +12103,7 @@ func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleEntry(k string) ( ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -12124,7 +12124,7 @@ func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleKey() ipld.NodeAs ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructField__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -12161,10 +12161,10 @@ func (ma *_Map__FieldName__StructField__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__FieldName__StructField__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__FieldName__StructField__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _FieldName__ReprPrototype{} } -func (ma *_Map__FieldName__StructField__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__FieldName__StructField__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _StructField__ReprPrototype{} } @@ -12226,12 +12226,12 @@ func (m MaybeMap__FieldName__StructRepresentation_Map_FieldDetails) IsAbsent() b func (m MaybeMap__FieldName__StructRepresentation_Map_FieldDetails) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMap__FieldName__StructRepresentation_Map_FieldDetails) AsNode() ipld.Node { +func (m MaybeMap__FieldName__StructRepresentation_Map_FieldDetails) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -12245,42 +12245,42 @@ func (m MaybeMap__FieldName__StructRepresentation_Map_FieldDetails) Must() Map__ return &m.v } -var _ ipld.Node = (Map__FieldName__StructRepresentation_Map_FieldDetails)(&_Map__FieldName__StructRepresentation_Map_FieldDetails{}) +var _ datamodel.Node = (Map__FieldName__StructRepresentation_Map_FieldDetails)(&_Map__FieldName__StructRepresentation_Map_FieldDetails{}) var _ schema.TypedNode = (Map__FieldName__StructRepresentation_Map_FieldDetails)(&_Map__FieldName__StructRepresentation_Map_FieldDetails{}) -func (Map__FieldName__StructRepresentation_Map_FieldDetails) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map__FieldName__StructRepresentation_Map_FieldDetails) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Map__FieldName__StructRepresentation_Map_FieldDetails) LookupByString(k string) (ipld.Node, error) { +func (n Map__FieldName__StructRepresentation_Map_FieldDetails) LookupByString(k string) (datamodel.Node, error) { var k2 _FieldName if err := (_FieldName__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n Map__FieldName__StructRepresentation_Map_FieldDetails) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n Map__FieldName__StructRepresentation_Map_FieldDetails) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(FieldName) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (Map__FieldName__StructRepresentation_Map_FieldDetails) LookupByIndex(idx int64) (ipld.Node, error) { +func (Map__FieldName__StructRepresentation_Map_FieldDetails) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails"}.LookupByIndex(0) } -func (n Map__FieldName__StructRepresentation_Map_FieldDetails) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Map__FieldName__StructRepresentation_Map_FieldDetails) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Map__FieldName__StructRepresentation_Map_FieldDetails) MapIterator() ipld.MapIterator { +func (n Map__FieldName__StructRepresentation_Map_FieldDetails) MapIterator() datamodel.MapIterator { return &_Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr{n, 0} } @@ -12289,9 +12289,9 @@ type _Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr struct { idx int } -func (itr *_Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -12303,7 +12303,7 @@ func (itr *_Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr) Done( return itr.idx >= len(itr.n.t) } -func (Map__FieldName__StructRepresentation_Map_FieldDetails) ListIterator() ipld.ListIterator { +func (Map__FieldName__StructRepresentation_Map_FieldDetails) ListIterator() datamodel.ListIterator { return nil } func (n Map__FieldName__StructRepresentation_Map_FieldDetails) Length() int64 { @@ -12330,16 +12330,16 @@ func (Map__FieldName__StructRepresentation_Map_FieldDetails) AsString() (string, func (Map__FieldName__StructRepresentation_Map_FieldDetails) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails"}.AsBytes() } -func (Map__FieldName__StructRepresentation_Map_FieldDetails) AsLink() (ipld.Link, error) { +func (Map__FieldName__StructRepresentation_Map_FieldDetails) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails"}.AsLink() } -func (Map__FieldName__StructRepresentation_Map_FieldDetails) Prototype() ipld.NodePrototype { +func (Map__FieldName__StructRepresentation_Map_FieldDetails) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructRepresentation_Map_FieldDetails__Prototype{} } type _Map__FieldName__StructRepresentation_Map_FieldDetails__Prototype struct{} -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__FieldName__StructRepresentation_Map_FieldDetails__Builder nb.Reset() return &nb @@ -12349,7 +12349,7 @@ type _Map__FieldName__StructRepresentation_Map_FieldDetails__Builder struct { _Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler } -func (nb *_Map__FieldName__StructRepresentation_Map_FieldDetails__Builder) Build() ipld.Node { +func (nb *_Map__FieldName__StructRepresentation_Map_FieldDetails__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -12376,7 +12376,7 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) res na.ka.reset() na.va.reset() } -func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -12391,7 +12391,7 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Beg na.w.t = make([]_Map__FieldName__StructRepresentation_Map_FieldDetails__entry, 0, sizeHint) return na, nil } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails"}.BeginList(0) } func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignNull() error { @@ -12423,10 +12423,10 @@ func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignS func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails"}.AssignBytes(nil) } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignLink(ipld.Link) error { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails"}.AssignLink(nil) } -func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignNode(v ipld.Node) error { +func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -12441,8 +12441,8 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Ass *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -12459,7 +12459,7 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Ass } return na.Finish() } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Prototype() ipld.NodePrototype { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructRepresentation_Map_FieldDetails__Prototype{} } func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) keyFinishTidy() bool { @@ -12490,7 +12490,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) val return false } } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -12511,7 +12511,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Ass return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__FieldName__StructRepresentation_Map_FieldDetails__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -12522,7 +12522,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Ass ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -12543,7 +12543,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Ass ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -12580,55 +12580,55 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) Fin *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) KeyPrototype() datamodel.NodePrototype { return _FieldName__Prototype{} } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _StructRepresentation_Map_FieldDetails__Prototype{} } func (Map__FieldName__StructRepresentation_Map_FieldDetails) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Map__FieldName__StructRepresentation_Map_FieldDetails) Representation() ipld.Node { +func (n Map__FieldName__StructRepresentation_Map_FieldDetails) Representation() datamodel.Node { return (*_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr)(n) } type _Map__FieldName__StructRepresentation_Map_FieldDetails__Repr _Map__FieldName__StructRepresentation_Map_FieldDetails -var _ ipld.Node = &_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr{} +var _ datamodel.Node = &_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr{} -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (Map__FieldName__StructRepresentation_Map_FieldDetails)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(StructRepresentation_Map_FieldDetails).Representation(), nil } -func (nr *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (Map__FieldName__StructRepresentation_Map_FieldDetails)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(StructRepresentation_Map_FieldDetails).Representation(), nil } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr"}.LookupByIndex(0) } -func (n _Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) MapIterator() ipld.MapIterator { +func (nr *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) MapIterator() datamodel.MapIterator { return &_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprMapItr{(Map__FieldName__StructRepresentation_Map_FieldDetails)(nr), 0} } type _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprMapItr _Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr -func (itr *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(StructRepresentation_Map_FieldDetails).Representation(), nil @@ -12637,7 +12637,7 @@ func (itr *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprMapItr) D return (*_Map__FieldName__StructRepresentation_Map_FieldDetails__MapItr)(itr).Done() } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) ListIterator() ipld.ListIterator { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) Length() int64 { @@ -12664,16 +12664,16 @@ func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) AsString() ( func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr"}.AsBytes() } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) AsLink() (ipld.Link, error) { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr"}.AsLink() } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) Prototype() ipld.NodePrototype { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__Repr) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprPrototype{} } type _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprPrototype struct{} -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprBuilder nb.Reset() return &nb @@ -12683,7 +12683,7 @@ type _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprBuilder struct _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler } -func (nb *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprBuilder) Build() ipld.Node { +func (nb *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -12710,7 +12710,7 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) na.ka.reset() na.va.reset() } -func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -12725,7 +12725,7 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) na.w.t = make([]_Map__FieldName__StructRepresentation_Map_FieldDetails__entry, 0, sizeHint) return na, nil } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr"}.BeginList(0) } func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNull() error { @@ -12757,10 +12757,10 @@ func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) Ass func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr"}.AssignBytes(nil) } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssignLink(ipld.Link) error { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr"}.AssignLink(nil) } -func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -12775,8 +12775,8 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__FieldName__StructRepresentation_Map_FieldDetails.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -12793,7 +12793,7 @@ func (na *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) } return na.Finish() } -func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) Prototype() datamodel.NodePrototype { return _Map__FieldName__StructRepresentation_Map_FieldDetails__ReprPrototype{} } func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) keyFinishTidy() bool { @@ -12824,7 +12824,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) return false } } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -12845,7 +12845,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__FieldName__StructRepresentation_Map_FieldDetails__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -12856,7 +12856,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -12877,7 +12877,7 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -12914,10 +12914,10 @@ func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _FieldName__ReprPrototype{} } -func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__FieldName__StructRepresentation_Map_FieldDetails__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _StructRepresentation_Map_FieldDetails__ReprPrototype{} } @@ -12979,12 +12979,12 @@ func (m MaybeMap__String__TypeName) IsAbsent() bool { func (m MaybeMap__String__TypeName) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMap__String__TypeName) AsNode() ipld.Node { +func (m MaybeMap__String__TypeName) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -12998,42 +12998,42 @@ func (m MaybeMap__String__TypeName) Must() Map__String__TypeName { return &m.v } -var _ ipld.Node = (Map__String__TypeName)(&_Map__String__TypeName{}) +var _ datamodel.Node = (Map__String__TypeName)(&_Map__String__TypeName{}) var _ schema.TypedNode = (Map__String__TypeName)(&_Map__String__TypeName{}) -func (Map__String__TypeName) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map__String__TypeName) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Map__String__TypeName) LookupByString(k string) (ipld.Node, error) { +func (n Map__String__TypeName) LookupByString(k string) (datamodel.Node, error) { var k2 _String if err := (_String__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n Map__String__TypeName) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n Map__String__TypeName) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(String) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.Map__String__TypeName", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.Map__String__TypeName", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (Map__String__TypeName) LookupByIndex(idx int64) (ipld.Node, error) { +func (Map__String__TypeName) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__String__TypeName"}.LookupByIndex(0) } -func (n Map__String__TypeName) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Map__String__TypeName) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Map__String__TypeName) MapIterator() ipld.MapIterator { +func (n Map__String__TypeName) MapIterator() datamodel.MapIterator { return &_Map__String__TypeName__MapItr{n, 0} } @@ -13042,9 +13042,9 @@ type _Map__String__TypeName__MapItr struct { idx int } -func (itr *_Map__String__TypeName__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Map__String__TypeName__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -13056,7 +13056,7 @@ func (itr *_Map__String__TypeName__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (Map__String__TypeName) ListIterator() ipld.ListIterator { +func (Map__String__TypeName) ListIterator() datamodel.ListIterator { return nil } func (n Map__String__TypeName) Length() int64 { @@ -13083,16 +13083,16 @@ func (Map__String__TypeName) AsString() (string, error) { func (Map__String__TypeName) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__String__TypeName"}.AsBytes() } -func (Map__String__TypeName) AsLink() (ipld.Link, error) { +func (Map__String__TypeName) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__String__TypeName"}.AsLink() } -func (Map__String__TypeName) Prototype() ipld.NodePrototype { +func (Map__String__TypeName) Prototype() datamodel.NodePrototype { return _Map__String__TypeName__Prototype{} } type _Map__String__TypeName__Prototype struct{} -func (_Map__String__TypeName__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Map__String__TypeName__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__String__TypeName__Builder nb.Reset() return &nb @@ -13102,7 +13102,7 @@ type _Map__String__TypeName__Builder struct { _Map__String__TypeName__Assembler } -func (nb *_Map__String__TypeName__Builder) Build() ipld.Node { +func (nb *_Map__String__TypeName__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -13129,7 +13129,7 @@ func (na *_Map__String__TypeName__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__String__TypeName__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__String__TypeName__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -13144,7 +13144,7 @@ func (na *_Map__String__TypeName__Assembler) BeginMap(sizeHint int64) (ipld.MapA na.w.t = make([]_Map__String__TypeName__entry, 0, sizeHint) return na, nil } -func (_Map__String__TypeName__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__String__TypeName__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__String__TypeName"}.BeginList(0) } func (na *_Map__String__TypeName__Assembler) AssignNull() error { @@ -13176,10 +13176,10 @@ func (_Map__String__TypeName__Assembler) AssignString(string) error { func (_Map__String__TypeName__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__String__TypeName"}.AssignBytes(nil) } -func (_Map__String__TypeName__Assembler) AssignLink(ipld.Link) error { +func (_Map__String__TypeName__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__String__TypeName"}.AssignLink(nil) } -func (na *_Map__String__TypeName__Assembler) AssignNode(v ipld.Node) error { +func (na *_Map__String__TypeName__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -13194,8 +13194,8 @@ func (na *_Map__String__TypeName__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__String__TypeName", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__String__TypeName", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -13212,7 +13212,7 @@ func (na *_Map__String__TypeName__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__String__TypeName__Assembler) Prototype() ipld.NodePrototype { +func (_Map__String__TypeName__Assembler) Prototype() datamodel.NodePrototype { return _Map__String__TypeName__Prototype{} } func (ma *_Map__String__TypeName__Assembler) keyFinishTidy() bool { @@ -13243,7 +13243,7 @@ func (ma *_Map__String__TypeName__Assembler) valueFinishTidy() bool { return false } } -func (ma *_Map__String__TypeName__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__String__TypeName__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -13264,7 +13264,7 @@ func (ma *_Map__String__TypeName__Assembler) AssembleEntry(k string) (ipld.NodeA return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__String__TypeName__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -13275,7 +13275,7 @@ func (ma *_Map__String__TypeName__Assembler) AssembleEntry(k string) (ipld.NodeA ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__String__TypeName__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__String__TypeName__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -13296,7 +13296,7 @@ func (ma *_Map__String__TypeName__Assembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__String__TypeName__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__String__TypeName__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -13333,55 +13333,55 @@ func (ma *_Map__String__TypeName__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__String__TypeName__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__String__TypeName__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Map__String__TypeName__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__String__TypeName__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeName__Prototype{} } func (Map__String__TypeName) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Map__String__TypeName) Representation() ipld.Node { +func (n Map__String__TypeName) Representation() datamodel.Node { return (*_Map__String__TypeName__Repr)(n) } type _Map__String__TypeName__Repr _Map__String__TypeName -var _ ipld.Node = &_Map__String__TypeName__Repr{} +var _ datamodel.Node = &_Map__String__TypeName__Repr{} -func (_Map__String__TypeName__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Map__String__TypeName__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_Map__String__TypeName__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_Map__String__TypeName__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (Map__String__TypeName)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (nr *_Map__String__TypeName__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_Map__String__TypeName__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (Map__String__TypeName)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (_Map__String__TypeName__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Map__String__TypeName__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__String__TypeName.Repr"}.LookupByIndex(0) } -func (n _Map__String__TypeName__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Map__String__TypeName__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_Map__String__TypeName__Repr) MapIterator() ipld.MapIterator { +func (nr *_Map__String__TypeName__Repr) MapIterator() datamodel.MapIterator { return &_Map__String__TypeName__ReprMapItr{(Map__String__TypeName)(nr), 0} } type _Map__String__TypeName__ReprMapItr _Map__String__TypeName__MapItr -func (itr *_Map__String__TypeName__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_Map__String__TypeName__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_Map__String__TypeName__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(TypeName).Representation(), nil @@ -13390,7 +13390,7 @@ func (itr *_Map__String__TypeName__ReprMapItr) Done() bool { return (*_Map__String__TypeName__MapItr)(itr).Done() } -func (_Map__String__TypeName__Repr) ListIterator() ipld.ListIterator { +func (_Map__String__TypeName__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Map__String__TypeName__Repr) Length() int64 { @@ -13417,16 +13417,16 @@ func (_Map__String__TypeName__Repr) AsString() (string, error) { func (_Map__String__TypeName__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__String__TypeName.Repr"}.AsBytes() } -func (_Map__String__TypeName__Repr) AsLink() (ipld.Link, error) { +func (_Map__String__TypeName__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__String__TypeName.Repr"}.AsLink() } -func (_Map__String__TypeName__Repr) Prototype() ipld.NodePrototype { +func (_Map__String__TypeName__Repr) Prototype() datamodel.NodePrototype { return _Map__String__TypeName__ReprPrototype{} } type _Map__String__TypeName__ReprPrototype struct{} -func (_Map__String__TypeName__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Map__String__TypeName__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__String__TypeName__ReprBuilder nb.Reset() return &nb @@ -13436,7 +13436,7 @@ type _Map__String__TypeName__ReprBuilder struct { _Map__String__TypeName__ReprAssembler } -func (nb *_Map__String__TypeName__ReprBuilder) Build() ipld.Node { +func (nb *_Map__String__TypeName__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -13463,7 +13463,7 @@ func (na *_Map__String__TypeName__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__String__TypeName__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__String__TypeName__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -13478,7 +13478,7 @@ func (na *_Map__String__TypeName__ReprAssembler) BeginMap(sizeHint int64) (ipld. na.w.t = make([]_Map__String__TypeName__entry, 0, sizeHint) return na, nil } -func (_Map__String__TypeName__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__String__TypeName__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__String__TypeName.Repr"}.BeginList(0) } func (na *_Map__String__TypeName__ReprAssembler) AssignNull() error { @@ -13510,10 +13510,10 @@ func (_Map__String__TypeName__ReprAssembler) AssignString(string) error { func (_Map__String__TypeName__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__String__TypeName.Repr"}.AssignBytes(nil) } -func (_Map__String__TypeName__ReprAssembler) AssignLink(ipld.Link) error { +func (_Map__String__TypeName__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__String__TypeName.Repr"}.AssignLink(nil) } -func (na *_Map__String__TypeName__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Map__String__TypeName__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -13528,8 +13528,8 @@ func (na *_Map__String__TypeName__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__String__TypeName.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__String__TypeName.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -13546,7 +13546,7 @@ func (na *_Map__String__TypeName__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__String__TypeName__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Map__String__TypeName__ReprAssembler) Prototype() datamodel.NodePrototype { return _Map__String__TypeName__ReprPrototype{} } func (ma *_Map__String__TypeName__ReprAssembler) keyFinishTidy() bool { @@ -13577,7 +13577,7 @@ func (ma *_Map__String__TypeName__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_Map__String__TypeName__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__String__TypeName__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -13598,7 +13598,7 @@ func (ma *_Map__String__TypeName__ReprAssembler) AssembleEntry(k string) (ipld.N return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__String__TypeName__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -13609,7 +13609,7 @@ func (ma *_Map__String__TypeName__ReprAssembler) AssembleEntry(k string) (ipld.N ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__String__TypeName__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__String__TypeName__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -13630,7 +13630,7 @@ func (ma *_Map__String__TypeName__ReprAssembler) AssembleKey() ipld.NodeAssemble ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__String__TypeName__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__String__TypeName__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -13667,10 +13667,10 @@ func (ma *_Map__String__TypeName__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__String__TypeName__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__String__TypeName__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__ReprPrototype{} } -func (ma *_Map__String__TypeName__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__String__TypeName__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeName__ReprPrototype{} } @@ -13732,12 +13732,12 @@ func (m MaybeMap__TypeName__Int) IsAbsent() bool { func (m MaybeMap__TypeName__Int) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeMap__TypeName__Int) AsNode() ipld.Node { +func (m MaybeMap__TypeName__Int) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -13751,42 +13751,42 @@ func (m MaybeMap__TypeName__Int) Must() Map__TypeName__Int { return &m.v } -var _ ipld.Node = (Map__TypeName__Int)(&_Map__TypeName__Int{}) +var _ datamodel.Node = (Map__TypeName__Int)(&_Map__TypeName__Int{}) var _ schema.TypedNode = (Map__TypeName__Int)(&_Map__TypeName__Int{}) -func (Map__TypeName__Int) Kind() ipld.Kind { - return ipld.Kind_Map +func (Map__TypeName__Int) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Map__TypeName__Int) LookupByString(k string) (ipld.Node, error) { +func (n Map__TypeName__Int) LookupByString(k string) (datamodel.Node, error) { var k2 _String if err := (_String__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n Map__TypeName__Int) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n Map__TypeName__Int) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(String) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.Map__TypeName__Int", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.Map__TypeName__Int", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (Map__TypeName__Int) LookupByIndex(idx int64) (ipld.Node, error) { +func (Map__TypeName__Int) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__TypeName__Int"}.LookupByIndex(0) } -func (n Map__TypeName__Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Map__TypeName__Int) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Map__TypeName__Int) MapIterator() ipld.MapIterator { +func (n Map__TypeName__Int) MapIterator() datamodel.MapIterator { return &_Map__TypeName__Int__MapItr{n, 0} } @@ -13795,9 +13795,9 @@ type _Map__TypeName__Int__MapItr struct { idx int } -func (itr *_Map__TypeName__Int__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Map__TypeName__Int__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -13809,7 +13809,7 @@ func (itr *_Map__TypeName__Int__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (Map__TypeName__Int) ListIterator() ipld.ListIterator { +func (Map__TypeName__Int) ListIterator() datamodel.ListIterator { return nil } func (n Map__TypeName__Int) Length() int64 { @@ -13836,16 +13836,16 @@ func (Map__TypeName__Int) AsString() (string, error) { func (Map__TypeName__Int) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__TypeName__Int"}.AsBytes() } -func (Map__TypeName__Int) AsLink() (ipld.Link, error) { +func (Map__TypeName__Int) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__TypeName__Int"}.AsLink() } -func (Map__TypeName__Int) Prototype() ipld.NodePrototype { +func (Map__TypeName__Int) Prototype() datamodel.NodePrototype { return _Map__TypeName__Int__Prototype{} } type _Map__TypeName__Int__Prototype struct{} -func (_Map__TypeName__Int__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Map__TypeName__Int__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__TypeName__Int__Builder nb.Reset() return &nb @@ -13855,7 +13855,7 @@ type _Map__TypeName__Int__Builder struct { _Map__TypeName__Int__Assembler } -func (nb *_Map__TypeName__Int__Builder) Build() ipld.Node { +func (nb *_Map__TypeName__Int__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -13882,7 +13882,7 @@ func (na *_Map__TypeName__Int__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__TypeName__Int__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__TypeName__Int__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -13897,7 +13897,7 @@ func (na *_Map__TypeName__Int__Assembler) BeginMap(sizeHint int64) (ipld.MapAsse na.w.t = make([]_Map__TypeName__Int__entry, 0, sizeHint) return na, nil } -func (_Map__TypeName__Int__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__TypeName__Int__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__TypeName__Int"}.BeginList(0) } func (na *_Map__TypeName__Int__Assembler) AssignNull() error { @@ -13929,10 +13929,10 @@ func (_Map__TypeName__Int__Assembler) AssignString(string) error { func (_Map__TypeName__Int__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__TypeName__Int"}.AssignBytes(nil) } -func (_Map__TypeName__Int__Assembler) AssignLink(ipld.Link) error { +func (_Map__TypeName__Int__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__TypeName__Int"}.AssignLink(nil) } -func (na *_Map__TypeName__Int__Assembler) AssignNode(v ipld.Node) error { +func (na *_Map__TypeName__Int__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -13947,8 +13947,8 @@ func (na *_Map__TypeName__Int__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__TypeName__Int", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__TypeName__Int", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -13965,7 +13965,7 @@ func (na *_Map__TypeName__Int__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__TypeName__Int__Assembler) Prototype() ipld.NodePrototype { +func (_Map__TypeName__Int__Assembler) Prototype() datamodel.NodePrototype { return _Map__TypeName__Int__Prototype{} } func (ma *_Map__TypeName__Int__Assembler) keyFinishTidy() bool { @@ -13996,7 +13996,7 @@ func (ma *_Map__TypeName__Int__Assembler) valueFinishTidy() bool { return false } } -func (ma *_Map__TypeName__Int__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__TypeName__Int__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -14017,7 +14017,7 @@ func (ma *_Map__TypeName__Int__Assembler) AssembleEntry(k string) (ipld.NodeAsse return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__TypeName__Int__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -14028,7 +14028,7 @@ func (ma *_Map__TypeName__Int__Assembler) AssembleEntry(k string) (ipld.NodeAsse ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__TypeName__Int__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__TypeName__Int__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -14049,7 +14049,7 @@ func (ma *_Map__TypeName__Int__Assembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__TypeName__Int__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__TypeName__Int__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -14086,55 +14086,55 @@ func (ma *_Map__TypeName__Int__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__TypeName__Int__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__TypeName__Int__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Map__TypeName__Int__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__TypeName__Int__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Int__Prototype{} } func (Map__TypeName__Int) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Map__TypeName__Int) Representation() ipld.Node { +func (n Map__TypeName__Int) Representation() datamodel.Node { return (*_Map__TypeName__Int__Repr)(n) } type _Map__TypeName__Int__Repr _Map__TypeName__Int -var _ ipld.Node = &_Map__TypeName__Int__Repr{} +var _ datamodel.Node = &_Map__TypeName__Int__Repr{} -func (_Map__TypeName__Int__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Map__TypeName__Int__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_Map__TypeName__Int__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_Map__TypeName__Int__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (Map__TypeName__Int)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Int).Representation(), nil } -func (nr *_Map__TypeName__Int__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_Map__TypeName__Int__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (Map__TypeName__Int)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(Int).Representation(), nil } -func (_Map__TypeName__Int__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Map__TypeName__Int__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Map__TypeName__Int.Repr"}.LookupByIndex(0) } -func (n _Map__TypeName__Int__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Map__TypeName__Int__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_Map__TypeName__Int__Repr) MapIterator() ipld.MapIterator { +func (nr *_Map__TypeName__Int__Repr) MapIterator() datamodel.MapIterator { return &_Map__TypeName__Int__ReprMapItr{(Map__TypeName__Int)(nr), 0} } type _Map__TypeName__Int__ReprMapItr _Map__TypeName__Int__MapItr -func (itr *_Map__TypeName__Int__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_Map__TypeName__Int__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_Map__TypeName__Int__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(Int).Representation(), nil @@ -14143,7 +14143,7 @@ func (itr *_Map__TypeName__Int__ReprMapItr) Done() bool { return (*_Map__TypeName__Int__MapItr)(itr).Done() } -func (_Map__TypeName__Int__Repr) ListIterator() ipld.ListIterator { +func (_Map__TypeName__Int__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Map__TypeName__Int__Repr) Length() int64 { @@ -14170,16 +14170,16 @@ func (_Map__TypeName__Int__Repr) AsString() (string, error) { func (_Map__TypeName__Int__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Map__TypeName__Int.Repr"}.AsBytes() } -func (_Map__TypeName__Int__Repr) AsLink() (ipld.Link, error) { +func (_Map__TypeName__Int__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Map__TypeName__Int.Repr"}.AsLink() } -func (_Map__TypeName__Int__Repr) Prototype() ipld.NodePrototype { +func (_Map__TypeName__Int__Repr) Prototype() datamodel.NodePrototype { return _Map__TypeName__Int__ReprPrototype{} } type _Map__TypeName__Int__ReprPrototype struct{} -func (_Map__TypeName__Int__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Map__TypeName__Int__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Map__TypeName__Int__ReprBuilder nb.Reset() return &nb @@ -14189,7 +14189,7 @@ type _Map__TypeName__Int__ReprBuilder struct { _Map__TypeName__Int__ReprAssembler } -func (nb *_Map__TypeName__Int__ReprBuilder) Build() ipld.Node { +func (nb *_Map__TypeName__Int__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -14216,7 +14216,7 @@ func (na *_Map__TypeName__Int__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_Map__TypeName__Int__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_Map__TypeName__Int__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -14231,7 +14231,7 @@ func (na *_Map__TypeName__Int__ReprAssembler) BeginMap(sizeHint int64) (ipld.Map na.w.t = make([]_Map__TypeName__Int__entry, 0, sizeHint) return na, nil } -func (_Map__TypeName__Int__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Map__TypeName__Int__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Map__TypeName__Int.Repr"}.BeginList(0) } func (na *_Map__TypeName__Int__ReprAssembler) AssignNull() error { @@ -14263,10 +14263,10 @@ func (_Map__TypeName__Int__ReprAssembler) AssignString(string) error { func (_Map__TypeName__Int__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__TypeName__Int.Repr"}.AssignBytes(nil) } -func (_Map__TypeName__Int__ReprAssembler) AssignLink(ipld.Link) error { +func (_Map__TypeName__Int__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Map__TypeName__Int.Repr"}.AssignLink(nil) } -func (na *_Map__TypeName__Int__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Map__TypeName__Int__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -14281,8 +14281,8 @@ func (na *_Map__TypeName__Int__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Map__TypeName__Int.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Map__TypeName__Int.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -14299,7 +14299,7 @@ func (na *_Map__TypeName__Int__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Map__TypeName__Int__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Map__TypeName__Int__ReprAssembler) Prototype() datamodel.NodePrototype { return _Map__TypeName__Int__ReprPrototype{} } func (ma *_Map__TypeName__Int__ReprAssembler) keyFinishTidy() bool { @@ -14330,7 +14330,7 @@ func (ma *_Map__TypeName__Int__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_Map__TypeName__Int__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Map__TypeName__Int__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -14351,7 +14351,7 @@ func (ma *_Map__TypeName__Int__ReprAssembler) AssembleEntry(k string) (ipld.Node return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _Map__TypeName__Int__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -14362,7 +14362,7 @@ func (ma *_Map__TypeName__Int__ReprAssembler) AssembleEntry(k string) (ipld.Node ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_Map__TypeName__Int__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Map__TypeName__Int__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -14383,7 +14383,7 @@ func (ma *_Map__TypeName__Int__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_Map__TypeName__Int__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Map__TypeName__Int__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -14420,10 +14420,10 @@ func (ma *_Map__TypeName__Int__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Map__TypeName__Int__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Map__TypeName__Int__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__ReprPrototype{} } -func (ma *_Map__TypeName__Int__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_Map__TypeName__Int__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _Int__ReprPrototype{} } @@ -14454,12 +14454,12 @@ func (m MaybeRepresentationKind) IsAbsent() bool { func (m MaybeRepresentationKind) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeRepresentationKind) AsNode() ipld.Node { +func (m MaybeRepresentationKind) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -14473,28 +14473,28 @@ func (m MaybeRepresentationKind) Must() RepresentationKind { return &m.v } -var _ ipld.Node = (RepresentationKind)(&_RepresentationKind{}) +var _ datamodel.Node = (RepresentationKind)(&_RepresentationKind{}) var _ schema.TypedNode = (RepresentationKind)(&_RepresentationKind{}) -func (RepresentationKind) Kind() ipld.Kind { - return ipld.Kind_String +func (RepresentationKind) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (RepresentationKind) LookupByString(string) (ipld.Node, error) { +func (RepresentationKind) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.RepresentationKind"}.LookupByString("") } -func (RepresentationKind) LookupByNode(ipld.Node) (ipld.Node, error) { +func (RepresentationKind) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.RepresentationKind"}.LookupByNode(nil) } -func (RepresentationKind) LookupByIndex(idx int64) (ipld.Node, error) { +func (RepresentationKind) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.RepresentationKind"}.LookupByIndex(0) } -func (RepresentationKind) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (RepresentationKind) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.RepresentationKind"}.LookupBySegment(seg) } -func (RepresentationKind) MapIterator() ipld.MapIterator { +func (RepresentationKind) MapIterator() datamodel.MapIterator { return nil } -func (RepresentationKind) ListIterator() ipld.ListIterator { +func (RepresentationKind) ListIterator() datamodel.ListIterator { return nil } func (RepresentationKind) Length() int64 { @@ -14521,16 +14521,16 @@ func (n RepresentationKind) AsString() (string, error) { func (RepresentationKind) AsBytes() ([]byte, error) { return mixins.String{TypeName: "schemadmt.RepresentationKind"}.AsBytes() } -func (RepresentationKind) AsLink() (ipld.Link, error) { +func (RepresentationKind) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "schemadmt.RepresentationKind"}.AsLink() } -func (RepresentationKind) Prototype() ipld.NodePrototype { +func (RepresentationKind) Prototype() datamodel.NodePrototype { return _RepresentationKind__Prototype{} } type _RepresentationKind__Prototype struct{} -func (_RepresentationKind__Prototype) NewBuilder() ipld.NodeBuilder { +func (_RepresentationKind__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _RepresentationKind__Builder nb.Reset() return &nb @@ -14540,7 +14540,7 @@ type _RepresentationKind__Builder struct { _RepresentationKind__Assembler } -func (nb *_RepresentationKind__Builder) Build() ipld.Node { +func (nb *_RepresentationKind__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -14558,10 +14558,10 @@ type _RepresentationKind__Assembler struct { } func (na *_RepresentationKind__Assembler) reset() {} -func (_RepresentationKind__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_RepresentationKind__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.RepresentationKind"}.BeginMap(0) } -func (_RepresentationKind__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_RepresentationKind__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.RepresentationKind"}.BeginList(0) } func (na *_RepresentationKind__Assembler) AssignNull() error { @@ -14597,10 +14597,10 @@ func (na *_RepresentationKind__Assembler) AssignString(v string) error { func (_RepresentationKind__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.RepresentationKind"}.AssignBytes(nil) } -func (_RepresentationKind__Assembler) AssignLink(ipld.Link) error { +func (_RepresentationKind__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.RepresentationKind"}.AssignLink(nil) } -func (na *_RepresentationKind__Assembler) AssignNode(v ipld.Node) error { +func (na *_RepresentationKind__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -14619,19 +14619,19 @@ func (na *_RepresentationKind__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_RepresentationKind__Assembler) Prototype() ipld.NodePrototype { +func (_RepresentationKind__Assembler) Prototype() datamodel.NodePrototype { return _RepresentationKind__Prototype{} } func (RepresentationKind) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n RepresentationKind) Representation() ipld.Node { +func (n RepresentationKind) Representation() datamodel.Node { return (*_RepresentationKind__Repr)(n) } type _RepresentationKind__Repr = _RepresentationKind -var _ ipld.Node = &_RepresentationKind__Repr{} +var _ datamodel.Node = &_RepresentationKind__Repr{} type _RepresentationKind__ReprPrototype = _RepresentationKind__Prototype type _RepresentationKind__ReprAssembler = _RepresentationKind__Assembler @@ -14655,12 +14655,12 @@ func (m MaybeSchema) IsAbsent() bool { func (m MaybeSchema) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeSchema) AsNode() ipld.Node { +func (m MaybeSchema) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -14677,34 +14677,34 @@ func (m MaybeSchema) Must() Schema { var ( fieldName__Schema_Types = _String{"types"} ) -var _ ipld.Node = (Schema)(&_Schema{}) +var _ datamodel.Node = (Schema)(&_Schema{}) var _ schema.TypedNode = (Schema)(&_Schema{}) -func (Schema) Kind() ipld.Kind { - return ipld.Kind_Map +func (Schema) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Schema) LookupByString(key string) (ipld.Node, error) { +func (n Schema) LookupByString(key string) (datamodel.Node, error) { switch key { case "types": return &n.types, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n Schema) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n Schema) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (Schema) LookupByIndex(idx int64) (ipld.Node, error) { +func (Schema) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Schema"}.LookupByIndex(0) } -func (n Schema) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Schema) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Schema) MapIterator() ipld.MapIterator { +func (n Schema) MapIterator() datamodel.MapIterator { return &_Schema__MapItr{n, 0} } @@ -14713,9 +14713,9 @@ type _Schema__MapItr struct { idx int } -func (itr *_Schema__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Schema__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -14731,7 +14731,7 @@ func (itr *_Schema__MapItr) Done() bool { return itr.idx >= 1 } -func (Schema) ListIterator() ipld.ListIterator { +func (Schema) ListIterator() datamodel.ListIterator { return nil } func (Schema) Length() int64 { @@ -14758,16 +14758,16 @@ func (Schema) AsString() (string, error) { func (Schema) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Schema"}.AsBytes() } -func (Schema) AsLink() (ipld.Link, error) { +func (Schema) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Schema"}.AsLink() } -func (Schema) Prototype() ipld.NodePrototype { +func (Schema) Prototype() datamodel.NodePrototype { return _Schema__Prototype{} } type _Schema__Prototype struct{} -func (_Schema__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Schema__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Schema__Builder nb.Reset() return &nb @@ -14777,7 +14777,7 @@ type _Schema__Builder struct { _Schema__Assembler } -func (nb *_Schema__Builder) Build() ipld.Node { +func (nb *_Schema__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -14811,7 +14811,7 @@ var ( fieldBits__Schema_sufficient = 0 + 1<<0 ) -func (na *_Schema__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_Schema__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -14824,7 +14824,7 @@ func (na *_Schema__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_Schema__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Schema__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Schema"}.BeginList(0) } func (na *_Schema__Assembler) AssignNull() error { @@ -14856,10 +14856,10 @@ func (_Schema__Assembler) AssignString(string) error { func (_Schema__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Schema"}.AssignBytes(nil) } -func (_Schema__Assembler) AssignLink(ipld.Link) error { +func (_Schema__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Schema"}.AssignLink(nil) } -func (na *_Schema__Assembler) AssignNode(v ipld.Node) error { +func (na *_Schema__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -14879,8 +14879,8 @@ func (na *_Schema__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Schema", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Schema", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -14897,7 +14897,7 @@ func (na *_Schema__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Schema__Assembler) Prototype() ipld.NodePrototype { +func (_Schema__Assembler) Prototype() datamodel.NodePrototype { return _Schema__Prototype{} } func (ma *_Schema__Assembler) valueFinishTidy() bool { @@ -14916,7 +14916,7 @@ func (ma *_Schema__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_Schema__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Schema__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -14934,7 +14934,7 @@ func (ma *_Schema__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error switch k { case "types": if ma.s&fieldBit__Schema_Types != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Schema_Types} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Schema_Types} } ma.s += fieldBit__Schema_Types ma.state = maState_midValue @@ -14943,9 +14943,9 @@ func (ma *_Schema__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error ma.ca_types.m = &ma.cm return &ma.ca_types, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.Schema", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.Schema", Key: &_String{k}} } -func (ma *_Schema__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Schema__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -14963,7 +14963,7 @@ func (ma *_Schema__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_Schema__KeyAssembler)(ma) } -func (ma *_Schema__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Schema__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -15002,7 +15002,7 @@ func (ma *_Schema__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__Schema_sufficient != fieldBits__Schema_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__Schema_Types == 0 { err.Missing = append(err.Missing, "types") } @@ -15012,19 +15012,19 @@ func (ma *_Schema__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Schema__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Schema__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Schema__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_Schema__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _Schema__KeyAssembler _Schema__Assembler -func (_Schema__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Schema__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Schema.KeyAssembler"}.BeginMap(0) } -func (_Schema__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Schema__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Schema.KeyAssembler"}.BeginList(0) } func (na *_Schema__KeyAssembler) AssignNull() error { @@ -15046,36 +15046,36 @@ func (ka *_Schema__KeyAssembler) AssignString(k string) error { switch k { case "types": if ka.s&fieldBit__Schema_Types != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Schema_Types} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Schema_Types} } ka.s += fieldBit__Schema_Types ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.Schema", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.Schema", Key: &_String{k}} } } func (_Schema__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.Schema.KeyAssembler"}.AssignBytes(nil) } -func (_Schema__KeyAssembler) AssignLink(ipld.Link) error { +func (_Schema__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.Schema.KeyAssembler"}.AssignLink(nil) } -func (ka *_Schema__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_Schema__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_Schema__KeyAssembler) Prototype() ipld.NodePrototype { +func (_Schema__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (Schema) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Schema) Representation() ipld.Node { +func (n Schema) Representation() datamodel.Node { return (*_Schema__Repr)(n) } @@ -15084,33 +15084,33 @@ type _Schema__Repr _Schema var ( fieldName__Schema_Types_serial = _String{"types"} ) -var _ ipld.Node = &_Schema__Repr{} +var _ datamodel.Node = &_Schema__Repr{} -func (_Schema__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Schema__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_Schema__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_Schema__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "types": return n.types.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_Schema__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_Schema__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_Schema__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Schema__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Schema.Repr"}.LookupByIndex(0) } -func (n _Schema__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Schema__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_Schema__Repr) MapIterator() ipld.MapIterator { +func (n *_Schema__Repr) MapIterator() datamodel.MapIterator { return &_Schema__ReprMapItr{n, 0} } @@ -15119,9 +15119,9 @@ type _Schema__ReprMapItr struct { idx int } -func (itr *_Schema__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_Schema__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -15136,7 +15136,7 @@ func (itr *_Schema__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_Schema__ReprMapItr) Done() bool { return itr.idx >= 1 } -func (_Schema__Repr) ListIterator() ipld.ListIterator { +func (_Schema__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Schema__Repr) Length() int64 { @@ -15164,16 +15164,16 @@ func (_Schema__Repr) AsString() (string, error) { func (_Schema__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Schema.Repr"}.AsBytes() } -func (_Schema__Repr) AsLink() (ipld.Link, error) { +func (_Schema__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Schema.Repr"}.AsLink() } -func (_Schema__Repr) Prototype() ipld.NodePrototype { +func (_Schema__Repr) Prototype() datamodel.NodePrototype { return _Schema__ReprPrototype{} } type _Schema__ReprPrototype struct{} -func (_Schema__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Schema__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Schema__ReprBuilder nb.Reset() return &nb @@ -15183,7 +15183,7 @@ type _Schema__ReprBuilder struct { _Schema__ReprAssembler } -func (nb *_Schema__ReprBuilder) Build() ipld.Node { +func (nb *_Schema__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -15211,7 +15211,7 @@ func (na *_Schema__ReprAssembler) reset() { na.s = 0 na.ca_types.reset() } -func (na *_Schema__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_Schema__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -15224,7 +15224,7 @@ func (na *_Schema__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_Schema__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Schema__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Schema.Repr"}.BeginList(0) } func (na *_Schema__ReprAssembler) AssignNull() error { @@ -15256,10 +15256,10 @@ func (_Schema__ReprAssembler) AssignString(string) error { func (_Schema__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Schema.Repr"}.AssignBytes(nil) } -func (_Schema__ReprAssembler) AssignLink(ipld.Link) error { +func (_Schema__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Schema.Repr"}.AssignLink(nil) } -func (na *_Schema__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Schema__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -15279,8 +15279,8 @@ func (na *_Schema__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Schema.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Schema.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -15297,7 +15297,7 @@ func (na *_Schema__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Schema__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Schema__ReprAssembler) Prototype() datamodel.NodePrototype { return _Schema__ReprPrototype{} } func (ma *_Schema__ReprAssembler) valueFinishTidy() bool { @@ -15315,7 +15315,7 @@ func (ma *_Schema__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_Schema__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Schema__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -15333,7 +15333,7 @@ func (ma *_Schema__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e switch k { case "types": if ma.s&fieldBit__Schema_Types != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Schema_Types_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__Schema_Types_serial} } ma.s += fieldBit__Schema_Types ma.state = maState_midValue @@ -15343,9 +15343,9 @@ func (ma *_Schema__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e return &ma.ca_types, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.Schema.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.Schema.Repr", Key: &_String{k}} } -func (ma *_Schema__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Schema__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -15363,7 +15363,7 @@ func (ma *_Schema__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_Schema__ReprKeyAssembler)(ma) } -func (ma *_Schema__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Schema__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -15402,7 +15402,7 @@ func (ma *_Schema__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__Schema_sufficient != fieldBits__Schema_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__Schema_Types == 0 { err.Missing = append(err.Missing, "types") } @@ -15412,19 +15412,19 @@ func (ma *_Schema__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_Schema__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Schema__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Schema__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_Schema__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _Schema__ReprKeyAssembler _Schema__ReprAssembler -func (_Schema__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Schema__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Schema.Repr.KeyAssembler"}.BeginMap(0) } -func (_Schema__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Schema__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Schema.Repr.KeyAssembler"}.BeginList(0) } func (na *_Schema__ReprKeyAssembler) AssignNull() error { @@ -15446,29 +15446,29 @@ func (ka *_Schema__ReprKeyAssembler) AssignString(k string) error { switch k { case "types": if ka.s&fieldBit__Schema_Types != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__Schema_Types_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__Schema_Types_serial} } ka.s += fieldBit__Schema_Types ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.Schema.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.Schema.Repr", Key: &_String{k}} } func (_Schema__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.Schema.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_Schema__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_Schema__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.Schema.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_Schema__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_Schema__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_Schema__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_Schema__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -15530,12 +15530,12 @@ func (m MaybeSchemaMap) IsAbsent() bool { func (m MaybeSchemaMap) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeSchemaMap) AsNode() ipld.Node { +func (m MaybeSchemaMap) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -15549,42 +15549,42 @@ func (m MaybeSchemaMap) Must() SchemaMap { return &m.v } -var _ ipld.Node = (SchemaMap)(&_SchemaMap{}) +var _ datamodel.Node = (SchemaMap)(&_SchemaMap{}) var _ schema.TypedNode = (SchemaMap)(&_SchemaMap{}) -func (SchemaMap) Kind() ipld.Kind { - return ipld.Kind_Map +func (SchemaMap) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n SchemaMap) LookupByString(k string) (ipld.Node, error) { +func (n SchemaMap) LookupByString(k string) (datamodel.Node, error) { var k2 _TypeName if err := (_TypeName__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n SchemaMap) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n SchemaMap) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(TypeName) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.SchemaMap", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.SchemaMap", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (SchemaMap) LookupByIndex(idx int64) (ipld.Node, error) { +func (SchemaMap) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.SchemaMap"}.LookupByIndex(0) } -func (n SchemaMap) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n SchemaMap) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n SchemaMap) MapIterator() ipld.MapIterator { +func (n SchemaMap) MapIterator() datamodel.MapIterator { return &_SchemaMap__MapItr{n, 0} } @@ -15593,9 +15593,9 @@ type _SchemaMap__MapItr struct { idx int } -func (itr *_SchemaMap__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_SchemaMap__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -15607,7 +15607,7 @@ func (itr *_SchemaMap__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (SchemaMap) ListIterator() ipld.ListIterator { +func (SchemaMap) ListIterator() datamodel.ListIterator { return nil } func (n SchemaMap) Length() int64 { @@ -15634,16 +15634,16 @@ func (SchemaMap) AsString() (string, error) { func (SchemaMap) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.SchemaMap"}.AsBytes() } -func (SchemaMap) AsLink() (ipld.Link, error) { +func (SchemaMap) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.SchemaMap"}.AsLink() } -func (SchemaMap) Prototype() ipld.NodePrototype { +func (SchemaMap) Prototype() datamodel.NodePrototype { return _SchemaMap__Prototype{} } type _SchemaMap__Prototype struct{} -func (_SchemaMap__Prototype) NewBuilder() ipld.NodeBuilder { +func (_SchemaMap__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _SchemaMap__Builder nb.Reset() return &nb @@ -15653,7 +15653,7 @@ type _SchemaMap__Builder struct { _SchemaMap__Assembler } -func (nb *_SchemaMap__Builder) Build() ipld.Node { +func (nb *_SchemaMap__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -15680,7 +15680,7 @@ func (na *_SchemaMap__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_SchemaMap__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_SchemaMap__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -15695,7 +15695,7 @@ func (na *_SchemaMap__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, er na.w.t = make([]_SchemaMap__entry, 0, sizeHint) return na, nil } -func (_SchemaMap__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_SchemaMap__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.SchemaMap"}.BeginList(0) } func (na *_SchemaMap__Assembler) AssignNull() error { @@ -15727,10 +15727,10 @@ func (_SchemaMap__Assembler) AssignString(string) error { func (_SchemaMap__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.SchemaMap"}.AssignBytes(nil) } -func (_SchemaMap__Assembler) AssignLink(ipld.Link) error { +func (_SchemaMap__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.SchemaMap"}.AssignLink(nil) } -func (na *_SchemaMap__Assembler) AssignNode(v ipld.Node) error { +func (na *_SchemaMap__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -15745,8 +15745,8 @@ func (na *_SchemaMap__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.SchemaMap", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.SchemaMap", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -15763,7 +15763,7 @@ func (na *_SchemaMap__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_SchemaMap__Assembler) Prototype() ipld.NodePrototype { +func (_SchemaMap__Assembler) Prototype() datamodel.NodePrototype { return _SchemaMap__Prototype{} } func (ma *_SchemaMap__Assembler) keyFinishTidy() bool { @@ -15794,7 +15794,7 @@ func (ma *_SchemaMap__Assembler) valueFinishTidy() bool { return false } } -func (ma *_SchemaMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_SchemaMap__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -15815,7 +15815,7 @@ func (ma *_SchemaMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _SchemaMap__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -15826,7 +15826,7 @@ func (ma *_SchemaMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_SchemaMap__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_SchemaMap__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -15847,7 +15847,7 @@ func (ma *_SchemaMap__Assembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_SchemaMap__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_SchemaMap__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -15884,55 +15884,55 @@ func (ma *_SchemaMap__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_SchemaMap__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_SchemaMap__Assembler) KeyPrototype() datamodel.NodePrototype { return _TypeName__Prototype{} } -func (ma *_SchemaMap__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_SchemaMap__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeDefn__Prototype{} } func (SchemaMap) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n SchemaMap) Representation() ipld.Node { +func (n SchemaMap) Representation() datamodel.Node { return (*_SchemaMap__Repr)(n) } type _SchemaMap__Repr _SchemaMap -var _ ipld.Node = &_SchemaMap__Repr{} +var _ datamodel.Node = &_SchemaMap__Repr{} -func (_SchemaMap__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_SchemaMap__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_SchemaMap__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_SchemaMap__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (SchemaMap)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeDefn).Representation(), nil } -func (nr *_SchemaMap__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_SchemaMap__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (SchemaMap)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeDefn).Representation(), nil } -func (_SchemaMap__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_SchemaMap__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.SchemaMap.Repr"}.LookupByIndex(0) } -func (n _SchemaMap__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _SchemaMap__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_SchemaMap__Repr) MapIterator() ipld.MapIterator { +func (nr *_SchemaMap__Repr) MapIterator() datamodel.MapIterator { return &_SchemaMap__ReprMapItr{(SchemaMap)(nr), 0} } type _SchemaMap__ReprMapItr _SchemaMap__MapItr -func (itr *_SchemaMap__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_SchemaMap__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_SchemaMap__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(TypeDefn).Representation(), nil @@ -15941,7 +15941,7 @@ func (itr *_SchemaMap__ReprMapItr) Done() bool { return (*_SchemaMap__MapItr)(itr).Done() } -func (_SchemaMap__Repr) ListIterator() ipld.ListIterator { +func (_SchemaMap__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_SchemaMap__Repr) Length() int64 { @@ -15968,16 +15968,16 @@ func (_SchemaMap__Repr) AsString() (string, error) { func (_SchemaMap__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.SchemaMap.Repr"}.AsBytes() } -func (_SchemaMap__Repr) AsLink() (ipld.Link, error) { +func (_SchemaMap__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.SchemaMap.Repr"}.AsLink() } -func (_SchemaMap__Repr) Prototype() ipld.NodePrototype { +func (_SchemaMap__Repr) Prototype() datamodel.NodePrototype { return _SchemaMap__ReprPrototype{} } type _SchemaMap__ReprPrototype struct{} -func (_SchemaMap__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_SchemaMap__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _SchemaMap__ReprBuilder nb.Reset() return &nb @@ -15987,7 +15987,7 @@ type _SchemaMap__ReprBuilder struct { _SchemaMap__ReprAssembler } -func (nb *_SchemaMap__ReprBuilder) Build() ipld.Node { +func (nb *_SchemaMap__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -16014,7 +16014,7 @@ func (na *_SchemaMap__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_SchemaMap__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_SchemaMap__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -16029,7 +16029,7 @@ func (na *_SchemaMap__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler na.w.t = make([]_SchemaMap__entry, 0, sizeHint) return na, nil } -func (_SchemaMap__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_SchemaMap__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.SchemaMap.Repr"}.BeginList(0) } func (na *_SchemaMap__ReprAssembler) AssignNull() error { @@ -16061,10 +16061,10 @@ func (_SchemaMap__ReprAssembler) AssignString(string) error { func (_SchemaMap__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.SchemaMap.Repr"}.AssignBytes(nil) } -func (_SchemaMap__ReprAssembler) AssignLink(ipld.Link) error { +func (_SchemaMap__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.SchemaMap.Repr"}.AssignLink(nil) } -func (na *_SchemaMap__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_SchemaMap__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -16079,8 +16079,8 @@ func (na *_SchemaMap__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.SchemaMap.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.SchemaMap.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -16097,7 +16097,7 @@ func (na *_SchemaMap__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_SchemaMap__ReprAssembler) Prototype() ipld.NodePrototype { +func (_SchemaMap__ReprAssembler) Prototype() datamodel.NodePrototype { return _SchemaMap__ReprPrototype{} } func (ma *_SchemaMap__ReprAssembler) keyFinishTidy() bool { @@ -16128,7 +16128,7 @@ func (ma *_SchemaMap__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_SchemaMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_SchemaMap__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -16149,7 +16149,7 @@ func (ma *_SchemaMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _SchemaMap__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -16160,7 +16160,7 @@ func (ma *_SchemaMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_SchemaMap__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_SchemaMap__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -16181,7 +16181,7 @@ func (ma *_SchemaMap__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_SchemaMap__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_SchemaMap__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -16218,10 +16218,10 @@ func (ma *_SchemaMap__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_SchemaMap__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_SchemaMap__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _TypeName__ReprPrototype{} } -func (ma *_SchemaMap__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_SchemaMap__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeDefn__ReprPrototype{} } @@ -16252,12 +16252,12 @@ func (m MaybeString) IsAbsent() bool { func (m MaybeString) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeString) AsNode() ipld.Node { +func (m MaybeString) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -16271,28 +16271,28 @@ func (m MaybeString) Must() String { return &m.v } -var _ ipld.Node = (String)(&_String{}) +var _ datamodel.Node = (String)(&_String{}) var _ schema.TypedNode = (String)(&_String{}) -func (String) Kind() ipld.Kind { - return ipld.Kind_String +func (String) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (String) LookupByString(string) (ipld.Node, error) { +func (String) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.String"}.LookupByString("") } -func (String) LookupByNode(ipld.Node) (ipld.Node, error) { +func (String) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.String"}.LookupByNode(nil) } -func (String) LookupByIndex(idx int64) (ipld.Node, error) { +func (String) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.String"}.LookupByIndex(0) } -func (String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (String) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.String"}.LookupBySegment(seg) } -func (String) MapIterator() ipld.MapIterator { +func (String) MapIterator() datamodel.MapIterator { return nil } -func (String) ListIterator() ipld.ListIterator { +func (String) ListIterator() datamodel.ListIterator { return nil } func (String) Length() int64 { @@ -16319,16 +16319,16 @@ func (n String) AsString() (string, error) { func (String) AsBytes() ([]byte, error) { return mixins.String{TypeName: "schemadmt.String"}.AsBytes() } -func (String) AsLink() (ipld.Link, error) { +func (String) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "schemadmt.String"}.AsLink() } -func (String) Prototype() ipld.NodePrototype { +func (String) Prototype() datamodel.NodePrototype { return _String__Prototype{} } type _String__Prototype struct{} -func (_String__Prototype) NewBuilder() ipld.NodeBuilder { +func (_String__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _String__Builder nb.Reset() return &nb @@ -16338,7 +16338,7 @@ type _String__Builder struct { _String__Assembler } -func (nb *_String__Builder) Build() ipld.Node { +func (nb *_String__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -16356,10 +16356,10 @@ type _String__Assembler struct { } func (na *_String__Assembler) reset() {} -func (_String__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_String__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.String"}.BeginMap(0) } -func (_String__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_String__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.String"}.BeginList(0) } func (na *_String__Assembler) AssignNull() error { @@ -16395,10 +16395,10 @@ func (na *_String__Assembler) AssignString(v string) error { func (_String__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.String"}.AssignBytes(nil) } -func (_String__Assembler) AssignLink(ipld.Link) error { +func (_String__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.String"}.AssignLink(nil) } -func (na *_String__Assembler) AssignNode(v ipld.Node) error { +func (na *_String__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -16417,19 +16417,19 @@ func (na *_String__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_String__Assembler) Prototype() ipld.NodePrototype { +func (_String__Assembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (String) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n String) Representation() ipld.Node { +func (n String) Representation() datamodel.Node { return (*_String__Repr)(n) } type _String__Repr = _String -var _ ipld.Node = &_String__Repr{} +var _ datamodel.Node = &_String__Repr{} type _String__ReprPrototype = _String__Prototype type _String__ReprAssembler = _String__Assembler @@ -16459,12 +16459,12 @@ func (m MaybeStructField) IsAbsent() bool { func (m MaybeStructField) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructField) AsNode() ipld.Node { +func (m MaybeStructField) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -16483,13 +16483,13 @@ var ( fieldName__StructField_Optional = _String{"optional"} fieldName__StructField_Nullable = _String{"nullable"} ) -var _ ipld.Node = (StructField)(&_StructField{}) +var _ datamodel.Node = (StructField)(&_StructField{}) var _ schema.TypedNode = (StructField)(&_StructField{}) -func (StructField) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructField) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructField) LookupByString(key string) (ipld.Node, error) { +func (n StructField) LookupByString(key string) (datamodel.Node, error) { switch key { case "type": return &n.typ, nil @@ -16498,23 +16498,23 @@ func (n StructField) LookupByString(key string) (ipld.Node, error) { case "nullable": return &n.nullable, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructField) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructField) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructField) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructField) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructField"}.LookupByIndex(0) } -func (n StructField) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructField) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructField) MapIterator() ipld.MapIterator { +func (n StructField) MapIterator() datamodel.MapIterator { return &_StructField__MapItr{n, 0} } @@ -16523,9 +16523,9 @@ type _StructField__MapItr struct { idx int } -func (itr *_StructField__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructField__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -16547,7 +16547,7 @@ func (itr *_StructField__MapItr) Done() bool { return itr.idx >= 3 } -func (StructField) ListIterator() ipld.ListIterator { +func (StructField) ListIterator() datamodel.ListIterator { return nil } func (StructField) Length() int64 { @@ -16574,16 +16574,16 @@ func (StructField) AsString() (string, error) { func (StructField) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructField"}.AsBytes() } -func (StructField) AsLink() (ipld.Link, error) { +func (StructField) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructField"}.AsLink() } -func (StructField) Prototype() ipld.NodePrototype { +func (StructField) Prototype() datamodel.NodePrototype { return _StructField__Prototype{} } type _StructField__Prototype struct{} -func (_StructField__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructField__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructField__Builder nb.Reset() return &nb @@ -16593,7 +16593,7 @@ type _StructField__Builder struct { _StructField__Assembler } -func (nb *_StructField__Builder) Build() ipld.Node { +func (nb *_StructField__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -16633,7 +16633,7 @@ var ( fieldBits__StructField_sufficient = 0 + 1<<0 + 1<<1 + 1<<2 ) -func (na *_StructField__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructField__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -16646,7 +16646,7 @@ func (na *_StructField__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_StructField__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructField__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructField"}.BeginList(0) } func (na *_StructField__Assembler) AssignNull() error { @@ -16678,10 +16678,10 @@ func (_StructField__Assembler) AssignString(string) error { func (_StructField__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructField"}.AssignBytes(nil) } -func (_StructField__Assembler) AssignLink(ipld.Link) error { +func (_StructField__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructField"}.AssignLink(nil) } -func (na *_StructField__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructField__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -16701,8 +16701,8 @@ func (na *_StructField__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructField", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructField", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -16719,7 +16719,7 @@ func (na *_StructField__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_StructField__Assembler) Prototype() ipld.NodePrototype { +func (_StructField__Assembler) Prototype() datamodel.NodePrototype { return _StructField__Prototype{} } func (ma *_StructField__Assembler) valueFinishTidy() bool { @@ -16758,7 +16758,7 @@ func (ma *_StructField__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructField__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructField__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -16776,7 +16776,7 @@ func (ma *_StructField__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, switch k { case "type": if ma.s&fieldBit__StructField_Type != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Type} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Type} } ma.s += fieldBit__StructField_Type ma.state = maState_midValue @@ -16786,7 +16786,7 @@ func (ma *_StructField__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_typ, nil case "optional": if ma.s&fieldBit__StructField_Optional != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional} } ma.s += fieldBit__StructField_Optional ma.state = maState_midValue @@ -16796,7 +16796,7 @@ func (ma *_StructField__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_optional, nil case "nullable": if ma.s&fieldBit__StructField_Nullable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable} } ma.s += fieldBit__StructField_Nullable ma.state = maState_midValue @@ -16805,9 +16805,9 @@ func (ma *_StructField__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, ma.ca_nullable.m = &ma.cm return &ma.ca_nullable, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructField", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructField", Key: &_String{k}} } -func (ma *_StructField__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructField__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -16825,7 +16825,7 @@ func (ma *_StructField__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_StructField__KeyAssembler)(ma) } -func (ma *_StructField__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructField__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -16872,7 +16872,7 @@ func (ma *_StructField__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructField_sufficient != fieldBits__StructField_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__StructField_Type == 0 { err.Missing = append(err.Missing, "type") } @@ -16888,19 +16888,19 @@ func (ma *_StructField__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructField__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructField__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructField__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructField__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructField__KeyAssembler _StructField__Assembler -func (_StructField__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructField__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructField.KeyAssembler"}.BeginMap(0) } -func (_StructField__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructField__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructField.KeyAssembler"}.BeginList(0) } func (na *_StructField__KeyAssembler) AssignNull() error { @@ -16922,7 +16922,7 @@ func (ka *_StructField__KeyAssembler) AssignString(k string) error { switch k { case "type": if ka.s&fieldBit__StructField_Type != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Type} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Type} } ka.s += fieldBit__StructField_Type ka.state = maState_expectValue @@ -16930,7 +16930,7 @@ func (ka *_StructField__KeyAssembler) AssignString(k string) error { return nil case "optional": if ka.s&fieldBit__StructField_Optional != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional} } ka.s += fieldBit__StructField_Optional ka.state = maState_expectValue @@ -16938,36 +16938,36 @@ func (ka *_StructField__KeyAssembler) AssignString(k string) error { return nil case "nullable": if ka.s&fieldBit__StructField_Nullable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable} } ka.s += fieldBit__StructField_Nullable ka.state = maState_expectValue ka.f = 2 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructField", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructField", Key: &_String{k}} } } func (_StructField__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructField.KeyAssembler"}.AssignBytes(nil) } -func (_StructField__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructField__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructField.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructField__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructField__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructField__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructField__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructField) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructField) Representation() ipld.Node { +func (n StructField) Representation() datamodel.Node { return (*_StructField__Repr)(n) } @@ -16978,12 +16978,12 @@ var ( fieldName__StructField_Optional_serial = _String{"optional"} fieldName__StructField_Nullable_serial = _String{"nullable"} ) -var _ ipld.Node = &_StructField__Repr{} +var _ datamodel.Node = &_StructField__Repr{} -func (_StructField__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructField__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructField__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructField__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "type": return n.typ.Representation(), nil @@ -16992,23 +16992,23 @@ func (n *_StructField__Repr) LookupByString(key string) (ipld.Node, error) { case "nullable": return n.nullable.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructField__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructField__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructField__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructField__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructField.Repr"}.LookupByIndex(0) } -func (n _StructField__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructField__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructField__Repr) MapIterator() ipld.MapIterator { +func (n *_StructField__Repr) MapIterator() datamodel.MapIterator { return &_StructField__ReprMapItr{n, 0} } @@ -17017,9 +17017,9 @@ type _StructField__ReprMapItr struct { idx int } -func (itr *_StructField__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructField__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -17040,7 +17040,7 @@ func (itr *_StructField__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) func (itr *_StructField__ReprMapItr) Done() bool { return itr.idx >= 3 } -func (_StructField__Repr) ListIterator() ipld.ListIterator { +func (_StructField__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructField__Repr) Length() int64 { @@ -17068,16 +17068,16 @@ func (_StructField__Repr) AsString() (string, error) { func (_StructField__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructField.Repr"}.AsBytes() } -func (_StructField__Repr) AsLink() (ipld.Link, error) { +func (_StructField__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructField.Repr"}.AsLink() } -func (_StructField__Repr) Prototype() ipld.NodePrototype { +func (_StructField__Repr) Prototype() datamodel.NodePrototype { return _StructField__ReprPrototype{} } type _StructField__ReprPrototype struct{} -func (_StructField__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructField__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructField__ReprBuilder nb.Reset() return &nb @@ -17087,7 +17087,7 @@ type _StructField__ReprBuilder struct { _StructField__ReprAssembler } -func (nb *_StructField__ReprBuilder) Build() ipld.Node { +func (nb *_StructField__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -17119,7 +17119,7 @@ func (na *_StructField__ReprAssembler) reset() { na.ca_optional.reset() na.ca_nullable.reset() } -func (na *_StructField__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructField__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -17132,7 +17132,7 @@ func (na *_StructField__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error } return na, nil } -func (_StructField__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructField__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructField.Repr"}.BeginList(0) } func (na *_StructField__ReprAssembler) AssignNull() error { @@ -17164,10 +17164,10 @@ func (_StructField__ReprAssembler) AssignString(string) error { func (_StructField__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructField.Repr"}.AssignBytes(nil) } -func (_StructField__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructField__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructField.Repr"}.AssignLink(nil) } -func (na *_StructField__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructField__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -17187,8 +17187,8 @@ func (na *_StructField__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructField.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructField.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -17205,7 +17205,7 @@ func (na *_StructField__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_StructField__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructField__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructField__ReprPrototype{} } func (ma *_StructField__ReprAssembler) valueFinishTidy() bool { @@ -17241,7 +17241,7 @@ func (ma *_StructField__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructField__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructField__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -17259,7 +17259,7 @@ func (ma *_StructField__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembl switch k { case "type": if ma.s&fieldBit__StructField_Type != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Type_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Type_serial} } ma.s += fieldBit__StructField_Type ma.state = maState_midValue @@ -17269,7 +17269,7 @@ func (ma *_StructField__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembl return &ma.ca_typ, nil case "optional": if ma.s&fieldBit__StructField_Optional != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional_serial} } ma.s += fieldBit__StructField_Optional ma.state = maState_midValue @@ -17279,7 +17279,7 @@ func (ma *_StructField__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembl return &ma.ca_optional, nil case "nullable": if ma.s&fieldBit__StructField_Nullable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable_serial} } ma.s += fieldBit__StructField_Nullable ma.state = maState_midValue @@ -17289,9 +17289,9 @@ func (ma *_StructField__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembl return &ma.ca_nullable, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructField.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructField.Repr", Key: &_String{k}} } -func (ma *_StructField__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructField__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -17309,7 +17309,7 @@ func (ma *_StructField__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_StructField__ReprKeyAssembler)(ma) } -func (ma *_StructField__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructField__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -17356,7 +17356,7 @@ func (ma *_StructField__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructField_sufficient != fieldBits__StructField_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__StructField_Type == 0 { err.Missing = append(err.Missing, "type") } @@ -17372,19 +17372,19 @@ func (ma *_StructField__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructField__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructField__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructField__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructField__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructField__ReprKeyAssembler _StructField__ReprAssembler -func (_StructField__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructField__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructField.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructField__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructField__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructField.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructField__ReprKeyAssembler) AssignNull() error { @@ -17406,7 +17406,7 @@ func (ka *_StructField__ReprKeyAssembler) AssignString(k string) error { switch k { case "type": if ka.s&fieldBit__StructField_Type != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Type_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Type_serial} } ka.s += fieldBit__StructField_Type ka.state = maState_expectValue @@ -17414,7 +17414,7 @@ func (ka *_StructField__ReprKeyAssembler) AssignString(k string) error { return nil case "optional": if ka.s&fieldBit__StructField_Optional != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Optional_serial} } ka.s += fieldBit__StructField_Optional ka.state = maState_expectValue @@ -17422,29 +17422,29 @@ func (ka *_StructField__ReprKeyAssembler) AssignString(k string) error { return nil case "nullable": if ka.s&fieldBit__StructField_Nullable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructField_Nullable_serial} } ka.s += fieldBit__StructField_Nullable ka.state = maState_expectValue ka.f = 2 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructField.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructField.Repr", Key: &_String{k}} } func (_StructField__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructField.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructField__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructField__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructField.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructField__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructField__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructField__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructField__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -17480,12 +17480,12 @@ func (m MaybeStructRepresentation) IsAbsent() bool { func (m MaybeStructRepresentation) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation) AsNode() ipld.Node { +func (m MaybeStructRepresentation) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -17506,57 +17506,57 @@ var ( memberName__StructRepresentation_StructRepresentation_Stringjoin = _String{"StructRepresentation_Stringjoin"} memberName__StructRepresentation_StructRepresentation_Listpairs = _String{"StructRepresentation_Listpairs"} ) -var _ ipld.Node = (StructRepresentation)(&_StructRepresentation{}) +var _ datamodel.Node = (StructRepresentation)(&_StructRepresentation{}) var _ schema.TypedNode = (StructRepresentation)(&_StructRepresentation{}) -func (StructRepresentation) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation) LookupByString(key string) (datamodel.Node, error) { switch key { case "StructRepresentation_Map": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "StructRepresentation_Tuple": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil case "StructRepresentation_Stringpairs": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x3, nil case "StructRepresentation_Stringjoin": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x4, nil case "StructRepresentation_Listpairs": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x5, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation"}.LookupByIndex(0) } -func (n StructRepresentation) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation) MapIterator() ipld.MapIterator { +func (n StructRepresentation) MapIterator() datamodel.MapIterator { return &_StructRepresentation__MapItr{n, false} } @@ -17565,9 +17565,9 @@ type _StructRepresentation__MapItr struct { done bool } -func (itr *_StructRepresentation__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -17590,7 +17590,7 @@ func (itr *_StructRepresentation__MapItr) Done() bool { return itr.done } -func (StructRepresentation) ListIterator() ipld.ListIterator { +func (StructRepresentation) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation) Length() int64 { @@ -17617,16 +17617,16 @@ func (StructRepresentation) AsString() (string, error) { func (StructRepresentation) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation"}.AsBytes() } -func (StructRepresentation) AsLink() (ipld.Link, error) { +func (StructRepresentation) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation"}.AsLink() } -func (StructRepresentation) Prototype() ipld.NodePrototype { +func (StructRepresentation) Prototype() datamodel.NodePrototype { return _StructRepresentation__Prototype{} } type _StructRepresentation__Prototype struct{} -func (_StructRepresentation__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation__Builder nb.Reset() return &nb @@ -17636,7 +17636,7 @@ type _StructRepresentation__Builder struct { _StructRepresentation__Assembler } -func (nb *_StructRepresentation__Builder) Build() ipld.Node { +func (nb *_StructRepresentation__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -17691,7 +17691,7 @@ func (na *_StructRepresentation__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_StructRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -17704,7 +17704,7 @@ func (na *_StructRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, } return na, nil } -func (_StructRepresentation__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation"}.BeginList(0) } func (na *_StructRepresentation__Assembler) AssignNull() error { @@ -17736,10 +17736,10 @@ func (_StructRepresentation__Assembler) AssignString(string) error { func (_StructRepresentation__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation"}.AssignBytes(nil) } -func (_StructRepresentation__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation"}.AssignLink(nil) } -func (na *_StructRepresentation__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -17759,8 +17759,8 @@ func (na *_StructRepresentation__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -17777,7 +17777,7 @@ func (na *_StructRepresentation__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_StructRepresentation__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation__Prototype{} } func (ma *_StructRepresentation__Assembler) valueFinishTidy() bool { @@ -17789,7 +17789,7 @@ func (ma *_StructRepresentation__Assembler) valueFinishTidy() bool { return false } } -func (ma *_StructRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -17844,9 +17844,9 @@ func (ma *_StructRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAs ma.ca5.m = &ma.cm return &ma.ca5, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation", Key: &_String{k}} } -func (ma *_StructRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -17864,7 +17864,7 @@ func (ma *_StructRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_StructRepresentation__KeyAssembler)(ma) } -func (ma *_StructRepresentation__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -17925,10 +17925,10 @@ func (ma *_StructRepresentation__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "StructRepresentation_Map": return _StructRepresentation_Map__Prototype{} @@ -17947,10 +17947,10 @@ func (ma *_StructRepresentation__Assembler) ValuePrototype(k string) ipld.NodePr type _StructRepresentation__KeyAssembler _StructRepresentation__Assembler -func (_StructRepresentation__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation__KeyAssembler) AssignNull() error { @@ -17999,28 +17999,28 @@ func (ka *_StructRepresentation__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_StructRepresentation__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation) Representation() ipld.Node { +func (n StructRepresentation) Representation() datamodel.Node { return (*_StructRepresentation__Repr)(n) } @@ -18033,56 +18033,56 @@ var ( memberName__StructRepresentation_StructRepresentation_Stringjoin_serial = _String{"stringjoin"} memberName__StructRepresentation_StructRepresentation_Listpairs_serial = _String{"listpairs"} ) -var _ ipld.Node = &_StructRepresentation__Repr{} +var _ datamodel.Node = &_StructRepresentation__Repr{} -func (_StructRepresentation__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "map": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x1.Representation(), nil case "tuple": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x2.Representation(), nil case "stringpairs": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x3.Representation(), nil case "stringjoin": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x4.Representation(), nil case "listpairs": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x5.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation__Repr) MapIterator() datamodel.MapIterator { return &_StructRepresentation__ReprMapItr{n, false} } @@ -18091,9 +18091,9 @@ type _StructRepresentation__ReprMapItr struct { done bool } -func (itr *_StructRepresentation__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -18116,7 +18116,7 @@ func (itr *_StructRepresentation__ReprMapItr) Done() bool { return itr.done } -func (_StructRepresentation__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation__Repr) ListIterator() datamodel.ListIterator { return nil } func (_StructRepresentation__Repr) Length() int64 { @@ -18143,16 +18143,16 @@ func (_StructRepresentation__Repr) AsString() (string, error) { func (_StructRepresentation__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation.Repr"}.AsBytes() } -func (_StructRepresentation__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation.Repr"}.AsLink() } -func (_StructRepresentation__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation__ReprPrototype{} } type _StructRepresentation__ReprPrototype struct{} -func (_StructRepresentation__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation__ReprBuilder nb.Reset() return &nb @@ -18162,7 +18162,7 @@ type _StructRepresentation__ReprBuilder struct { _StructRepresentation__ReprAssembler } -func (nb *_StructRepresentation__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -18217,7 +18217,7 @@ func (na *_StructRepresentation__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_StructRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -18230,7 +18230,7 @@ func (na *_StructRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembl } return na, nil } -func (_StructRepresentation__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation.Repr"}.BeginList(0) } func (na *_StructRepresentation__ReprAssembler) AssignNull() error { @@ -18262,10 +18262,10 @@ func (_StructRepresentation__ReprAssembler) AssignString(string) error { func (_StructRepresentation__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation.Repr"}.AssignBytes(nil) } -func (_StructRepresentation__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -18285,8 +18285,8 @@ func (na *_StructRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -18303,7 +18303,7 @@ func (na *_StructRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_StructRepresentation__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation__ReprPrototype{} } func (ma *_StructRepresentation__ReprAssembler) valueFinishTidy() bool { @@ -18315,7 +18315,7 @@ func (ma *_StructRepresentation__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_StructRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -18370,9 +18370,9 @@ func (ma *_StructRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.No ma.ca5.m = &ma.cm return &ma.ca5, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -18390,7 +18390,7 @@ func (ma *_StructRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler ma.state = maState_midKey return (*_StructRepresentation__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -18451,10 +18451,10 @@ func (ma *_StructRepresentation__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "StructRepresentation_Map": return _StructRepresentation_Map__ReprPrototype{} @@ -18473,10 +18473,10 @@ func (ma *_StructRepresentation__ReprAssembler) ValuePrototype(k string) ipld.No type _StructRepresentation__ReprKeyAssembler _StructRepresentation__ReprAssembler -func (_StructRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation__ReprKeyAssembler) AssignNull() error { @@ -18525,22 +18525,22 @@ func (ka *_StructRepresentation__ReprKeyAssembler) AssignString(k string) error ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_StructRepresentation__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -18559,12 +18559,12 @@ func (m MaybeStructRepresentation_Listpairs) IsAbsent() bool { func (m MaybeStructRepresentation_Listpairs) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation_Listpairs) AsNode() ipld.Node { +func (m MaybeStructRepresentation_Listpairs) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -18579,32 +18579,32 @@ func (m MaybeStructRepresentation_Listpairs) Must() StructRepresentation_Listpai } var () -var _ ipld.Node = (StructRepresentation_Listpairs)(&_StructRepresentation_Listpairs{}) +var _ datamodel.Node = (StructRepresentation_Listpairs)(&_StructRepresentation_Listpairs{}) var _ schema.TypedNode = (StructRepresentation_Listpairs)(&_StructRepresentation_Listpairs{}) -func (StructRepresentation_Listpairs) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation_Listpairs) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation_Listpairs) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation_Listpairs) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation_Listpairs) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation_Listpairs) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation_Listpairs) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation_Listpairs) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Listpairs"}.LookupByIndex(0) } -func (n StructRepresentation_Listpairs) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation_Listpairs) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation_Listpairs) MapIterator() ipld.MapIterator { +func (n StructRepresentation_Listpairs) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Listpairs__MapItr{n, 0} } @@ -18613,15 +18613,15 @@ type _StructRepresentation_Listpairs__MapItr struct { idx int } -func (itr *_StructRepresentation_Listpairs__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_StructRepresentation_Listpairs__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_StructRepresentation_Listpairs__MapItr) Done() bool { return itr.idx >= 0 } -func (StructRepresentation_Listpairs) ListIterator() ipld.ListIterator { +func (StructRepresentation_Listpairs) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation_Listpairs) Length() int64 { @@ -18648,16 +18648,16 @@ func (StructRepresentation_Listpairs) AsString() (string, error) { func (StructRepresentation_Listpairs) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Listpairs"}.AsBytes() } -func (StructRepresentation_Listpairs) AsLink() (ipld.Link, error) { +func (StructRepresentation_Listpairs) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Listpairs"}.AsLink() } -func (StructRepresentation_Listpairs) Prototype() ipld.NodePrototype { +func (StructRepresentation_Listpairs) Prototype() datamodel.NodePrototype { return _StructRepresentation_Listpairs__Prototype{} } type _StructRepresentation_Listpairs__Prototype struct{} -func (_StructRepresentation_Listpairs__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Listpairs__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Listpairs__Builder nb.Reset() return &nb @@ -18667,7 +18667,7 @@ type _StructRepresentation_Listpairs__Builder struct { _StructRepresentation_Listpairs__Assembler } -func (nb *_StructRepresentation_Listpairs__Builder) Build() ipld.Node { +func (nb *_StructRepresentation_Listpairs__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -18698,7 +18698,7 @@ var ( fieldBits__StructRepresentation_Listpairs_sufficient = 0 ) -func (na *_StructRepresentation_Listpairs__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Listpairs__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -18711,7 +18711,7 @@ func (na *_StructRepresentation_Listpairs__Assembler) BeginMap(int64) (ipld.MapA } return na, nil } -func (_StructRepresentation_Listpairs__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Listpairs__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs"}.BeginList(0) } func (na *_StructRepresentation_Listpairs__Assembler) AssignNull() error { @@ -18743,10 +18743,10 @@ func (_StructRepresentation_Listpairs__Assembler) AssignString(string) error { func (_StructRepresentation_Listpairs__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs"}.AssignBytes(nil) } -func (_StructRepresentation_Listpairs__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Listpairs__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs"}.AssignLink(nil) } -func (na *_StructRepresentation_Listpairs__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Listpairs__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -18766,8 +18766,8 @@ func (na *_StructRepresentation_Listpairs__Assembler) AssignNode(v ipld.Node) er *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Listpairs", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Listpairs", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -18784,7 +18784,7 @@ func (na *_StructRepresentation_Listpairs__Assembler) AssignNode(v ipld.Node) er } return na.Finish() } -func (_StructRepresentation_Listpairs__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Listpairs__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Listpairs__Prototype{} } func (ma *_StructRepresentation_Listpairs__Assembler) valueFinishTidy() bool { @@ -18793,7 +18793,7 @@ func (ma *_StructRepresentation_Listpairs__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Listpairs__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Listpairs__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -18808,9 +18808,9 @@ func (ma *_StructRepresentation_Listpairs__Assembler) AssembleEntry(k string) (i case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs", Key: &_String{k}} } -func (ma *_StructRepresentation_Listpairs__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Listpairs__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -18828,7 +18828,7 @@ func (ma *_StructRepresentation_Listpairs__Assembler) AssembleKey() ipld.NodeAss ma.state = maState_midKey return (*_StructRepresentation_Listpairs__KeyAssembler)(ma) } -func (ma *_StructRepresentation_Listpairs__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Listpairs__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -18863,26 +18863,26 @@ func (ma *_StructRepresentation_Listpairs__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Listpairs_sufficient != fieldBits__StructRepresentation_Listpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Listpairs__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Listpairs__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Listpairs__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Listpairs__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructRepresentation_Listpairs__KeyAssembler _StructRepresentation_Listpairs__Assembler -func (_StructRepresentation_Listpairs__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Listpairs__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Listpairs__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Listpairs__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Listpairs__KeyAssembler) AssignNull() error { @@ -18903,60 +18903,60 @@ func (ka *_StructRepresentation_Listpairs__KeyAssembler) AssignString(k string) } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs", Key: &_String{k}} } } func (_StructRepresentation_Listpairs__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Listpairs__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Listpairs__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Listpairs__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Listpairs__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Listpairs__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Listpairs__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation_Listpairs) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation_Listpairs) Representation() ipld.Node { +func (n StructRepresentation_Listpairs) Representation() datamodel.Node { return (*_StructRepresentation_Listpairs__Repr)(n) } type _StructRepresentation_Listpairs__Repr _StructRepresentation_Listpairs var () -var _ ipld.Node = &_StructRepresentation_Listpairs__Repr{} +var _ datamodel.Node = &_StructRepresentation_Listpairs__Repr{} -func (_StructRepresentation_Listpairs__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation_Listpairs__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation_Listpairs__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation_Listpairs__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation_Listpairs__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation_Listpairs__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation_Listpairs__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation_Listpairs__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation_Listpairs__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation_Listpairs__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation_Listpairs__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation_Listpairs__Repr) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Listpairs__ReprMapItr{n, 0} } @@ -18965,14 +18965,14 @@ type _StructRepresentation_Listpairs__ReprMapItr struct { idx int } -func (itr *_StructRepresentation_Listpairs__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_StructRepresentation_Listpairs__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_StructRepresentation_Listpairs__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_StructRepresentation_Listpairs__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation_Listpairs__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructRepresentation_Listpairs__Repr) Length() int64 { @@ -19000,16 +19000,16 @@ func (_StructRepresentation_Listpairs__Repr) AsString() (string, error) { func (_StructRepresentation_Listpairs__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr"}.AsBytes() } -func (_StructRepresentation_Listpairs__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation_Listpairs__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr"}.AsLink() } -func (_StructRepresentation_Listpairs__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Listpairs__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation_Listpairs__ReprPrototype{} } type _StructRepresentation_Listpairs__ReprPrototype struct{} -func (_StructRepresentation_Listpairs__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Listpairs__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Listpairs__ReprBuilder nb.Reset() return &nb @@ -19019,7 +19019,7 @@ type _StructRepresentation_Listpairs__ReprBuilder struct { _StructRepresentation_Listpairs__ReprAssembler } -func (nb *_StructRepresentation_Listpairs__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation_Listpairs__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -19045,7 +19045,7 @@ func (na *_StructRepresentation_Listpairs__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_StructRepresentation_Listpairs__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Listpairs__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -19058,7 +19058,7 @@ func (na *_StructRepresentation_Listpairs__ReprAssembler) BeginMap(int64) (ipld. } return na, nil } -func (_StructRepresentation_Listpairs__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Listpairs__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr"}.BeginList(0) } func (na *_StructRepresentation_Listpairs__ReprAssembler) AssignNull() error { @@ -19090,10 +19090,10 @@ func (_StructRepresentation_Listpairs__ReprAssembler) AssignString(string) error func (_StructRepresentation_Listpairs__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr"}.AssignBytes(nil) } -func (_StructRepresentation_Listpairs__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Listpairs__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation_Listpairs__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Listpairs__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -19113,8 +19113,8 @@ func (na *_StructRepresentation_Listpairs__ReprAssembler) AssignNode(v ipld.Node *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -19131,7 +19131,7 @@ func (na *_StructRepresentation_Listpairs__ReprAssembler) AssignNode(v ipld.Node } return na.Finish() } -func (_StructRepresentation_Listpairs__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Listpairs__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Listpairs__ReprPrototype{} } func (ma *_StructRepresentation_Listpairs__ReprAssembler) valueFinishTidy() bool { @@ -19140,7 +19140,7 @@ func (ma *_StructRepresentation_Listpairs__ReprAssembler) valueFinishTidy() bool panic("unreachable") } } -func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -19155,9 +19155,9 @@ func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleEntry(k string case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -19175,7 +19175,7 @@ func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleKey() ipld.Nod ma.state = maState_midKey return (*_StructRepresentation_Listpairs__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Listpairs__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -19210,26 +19210,26 @@ func (ma *_StructRepresentation_Listpairs__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Listpairs_sufficient != fieldBits__StructRepresentation_Listpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Listpairs__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Listpairs__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Listpairs__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Listpairs__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructRepresentation_Listpairs__ReprKeyAssembler _StructRepresentation_Listpairs__ReprAssembler -func (_StructRepresentation_Listpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Listpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Listpairs__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Listpairs__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Listpairs__ReprKeyAssembler) AssignNull() error { @@ -19248,22 +19248,22 @@ func (ka *_StructRepresentation_Listpairs__ReprKeyAssembler) AssignString(k stri if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr", Key: &_String{k}} } func (_StructRepresentation_Listpairs__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Listpairs__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Listpairs__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Listpairs.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Listpairs__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Listpairs__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Listpairs__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Listpairs__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -19286,12 +19286,12 @@ func (m MaybeStructRepresentation_Map) IsAbsent() bool { func (m MaybeStructRepresentation_Map) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation_Map) AsNode() ipld.Node { +func (m MaybeStructRepresentation_Map) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -19308,37 +19308,37 @@ func (m MaybeStructRepresentation_Map) Must() StructRepresentation_Map { var ( fieldName__StructRepresentation_Map_Fields = _String{"fields"} ) -var _ ipld.Node = (StructRepresentation_Map)(&_StructRepresentation_Map{}) +var _ datamodel.Node = (StructRepresentation_Map)(&_StructRepresentation_Map{}) var _ schema.TypedNode = (StructRepresentation_Map)(&_StructRepresentation_Map{}) -func (StructRepresentation_Map) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation_Map) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation_Map) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation_Map) LookupByString(key string) (datamodel.Node, error) { switch key { case "fields": if n.fields.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } return &n.fields.v, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation_Map) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation_Map) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation_Map) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation_Map) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map"}.LookupByIndex(0) } -func (n StructRepresentation_Map) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation_Map) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation_Map) MapIterator() ipld.MapIterator { +func (n StructRepresentation_Map) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Map__MapItr{n, 0} } @@ -19347,15 +19347,15 @@ type _StructRepresentation_Map__MapItr struct { idx int } -func (itr *_StructRepresentation_Map__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Map__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: k = &fieldName__StructRepresentation_Map_Fields if itr.n.fields.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } v = &itr.n.fields.v @@ -19369,7 +19369,7 @@ func (itr *_StructRepresentation_Map__MapItr) Done() bool { return itr.idx >= 1 } -func (StructRepresentation_Map) ListIterator() ipld.ListIterator { +func (StructRepresentation_Map) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation_Map) Length() int64 { @@ -19396,16 +19396,16 @@ func (StructRepresentation_Map) AsString() (string, error) { func (StructRepresentation_Map) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map"}.AsBytes() } -func (StructRepresentation_Map) AsLink() (ipld.Link, error) { +func (StructRepresentation_Map) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map"}.AsLink() } -func (StructRepresentation_Map) Prototype() ipld.NodePrototype { +func (StructRepresentation_Map) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map__Prototype{} } type _StructRepresentation_Map__Prototype struct{} -func (_StructRepresentation_Map__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Map__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Map__Builder nb.Reset() return &nb @@ -19415,7 +19415,7 @@ type _StructRepresentation_Map__Builder struct { _StructRepresentation_Map__Assembler } -func (nb *_StructRepresentation_Map__Builder) Build() ipld.Node { +func (nb *_StructRepresentation_Map__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -19449,7 +19449,7 @@ var ( fieldBits__StructRepresentation_Map_sufficient = 0 ) -func (na *_StructRepresentation_Map__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Map__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -19462,7 +19462,7 @@ func (na *_StructRepresentation_Map__Assembler) BeginMap(int64) (ipld.MapAssembl } return na, nil } -func (_StructRepresentation_Map__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map"}.BeginList(0) } func (na *_StructRepresentation_Map__Assembler) AssignNull() error { @@ -19494,10 +19494,10 @@ func (_StructRepresentation_Map__Assembler) AssignString(string) error { func (_StructRepresentation_Map__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map"}.AssignBytes(nil) } -func (_StructRepresentation_Map__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map"}.AssignLink(nil) } -func (na *_StructRepresentation_Map__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Map__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -19517,8 +19517,8 @@ func (na *_StructRepresentation_Map__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -19535,7 +19535,7 @@ func (na *_StructRepresentation_Map__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_StructRepresentation_Map__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map__Prototype{} } func (ma *_StructRepresentation_Map__Assembler) valueFinishTidy() bool { @@ -19552,7 +19552,7 @@ func (ma *_StructRepresentation_Map__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Map__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Map__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -19570,7 +19570,7 @@ func (ma *_StructRepresentation_Map__Assembler) AssembleEntry(k string) (ipld.No switch k { case "fields": if ma.s&fieldBit__StructRepresentation_Map_Fields != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields} } ma.s += fieldBit__StructRepresentation_Map_Fields ma.state = maState_midValue @@ -19579,9 +19579,9 @@ func (ma *_StructRepresentation_Map__Assembler) AssembleEntry(k string) (ipld.No ma.ca_fields.m = &ma.w.fields.m return &ma.ca_fields, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map", Key: &_String{k}} } -func (ma *_StructRepresentation_Map__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -19599,7 +19599,7 @@ func (ma *_StructRepresentation_Map__Assembler) AssembleKey() ipld.NodeAssembler ma.state = maState_midKey return (*_StructRepresentation_Map__KeyAssembler)(ma) } -func (ma *_StructRepresentation_Map__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -19638,26 +19638,26 @@ func (ma *_StructRepresentation_Map__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Map_sufficient != fieldBits__StructRepresentation_Map_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Map__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Map__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Map__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Map__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructRepresentation_Map__KeyAssembler _StructRepresentation_Map__Assembler -func (_StructRepresentation_Map__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Map__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Map__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Map__KeyAssembler) AssignNull() error { @@ -19679,36 +19679,36 @@ func (ka *_StructRepresentation_Map__KeyAssembler) AssignString(k string) error switch k { case "fields": if ka.s&fieldBit__StructRepresentation_Map_Fields != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields} } ka.s += fieldBit__StructRepresentation_Map_Fields ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map", Key: &_String{k}} } } func (_StructRepresentation_Map__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Map__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Map__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Map__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Map__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation_Map) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation_Map) Representation() ipld.Node { +func (n StructRepresentation_Map) Representation() datamodel.Node { return (*_StructRepresentation_Map__Repr)(n) } @@ -19717,36 +19717,36 @@ type _StructRepresentation_Map__Repr _StructRepresentation_Map var ( fieldName__StructRepresentation_Map_Fields_serial = _String{"fields"} ) -var _ ipld.Node = &_StructRepresentation_Map__Repr{} +var _ datamodel.Node = &_StructRepresentation_Map__Repr{} -func (_StructRepresentation_Map__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation_Map__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation_Map__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation_Map__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "fields": if n.fields.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.fields.v.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation_Map__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation_Map__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation_Map__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation_Map__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation_Map__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation_Map__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation_Map__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation_Map__Repr) MapIterator() datamodel.MapIterator { end := 1 if n.fields.m == schema.Maybe_Absent { end = 0 @@ -19763,10 +19763,10 @@ type _StructRepresentation_Map__ReprMapItr struct { end int } -func (itr *_StructRepresentation_Map__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Map__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { advance: if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -19785,7 +19785,7 @@ advance: func (itr *_StructRepresentation_Map__ReprMapItr) Done() bool { return itr.idx >= itr.end } -func (_StructRepresentation_Map__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation_Map__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructRepresentation_Map__Repr) Length() int64 { @@ -19816,16 +19816,16 @@ func (_StructRepresentation_Map__Repr) AsString() (string, error) { func (_StructRepresentation_Map__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map.Repr"}.AsBytes() } -func (_StructRepresentation_Map__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation_Map__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map.Repr"}.AsLink() } -func (_StructRepresentation_Map__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map__ReprPrototype{} } type _StructRepresentation_Map__ReprPrototype struct{} -func (_StructRepresentation_Map__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Map__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Map__ReprBuilder nb.Reset() return &nb @@ -19835,7 +19835,7 @@ type _StructRepresentation_Map__ReprBuilder struct { _StructRepresentation_Map__ReprAssembler } -func (nb *_StructRepresentation_Map__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation_Map__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -19863,7 +19863,7 @@ func (na *_StructRepresentation_Map__ReprAssembler) reset() { na.s = 0 na.ca_fields.reset() } -func (na *_StructRepresentation_Map__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Map__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -19876,7 +19876,7 @@ func (na *_StructRepresentation_Map__ReprAssembler) BeginMap(int64) (ipld.MapAss } return na, nil } -func (_StructRepresentation_Map__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr"}.BeginList(0) } func (na *_StructRepresentation_Map__ReprAssembler) AssignNull() error { @@ -19908,10 +19908,10 @@ func (_StructRepresentation_Map__ReprAssembler) AssignString(string) error { func (_StructRepresentation_Map__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr"}.AssignBytes(nil) } -func (_StructRepresentation_Map__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation_Map__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Map__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -19931,8 +19931,8 @@ func (na *_StructRepresentation_Map__ReprAssembler) AssignNode(v ipld.Node) erro *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -19949,7 +19949,7 @@ func (na *_StructRepresentation_Map__ReprAssembler) AssignNode(v ipld.Node) erro } return na.Finish() } -func (_StructRepresentation_Map__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map__ReprPrototype{} } func (ma *_StructRepresentation_Map__ReprAssembler) valueFinishTidy() bool { @@ -19966,7 +19966,7 @@ func (ma *_StructRepresentation_Map__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Map__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Map__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -19984,7 +19984,7 @@ func (ma *_StructRepresentation_Map__ReprAssembler) AssembleEntry(k string) (ipl switch k { case "fields": if ma.s&fieldBit__StructRepresentation_Map_Fields != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields_serial} } ma.s += fieldBit__StructRepresentation_Map_Fields ma.state = maState_midValue @@ -19995,9 +19995,9 @@ func (ma *_StructRepresentation_Map__ReprAssembler) AssembleEntry(k string) (ipl return &ma.ca_fields, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation_Map__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -20015,7 +20015,7 @@ func (ma *_StructRepresentation_Map__ReprAssembler) AssembleKey() ipld.NodeAssem ma.state = maState_midKey return (*_StructRepresentation_Map__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation_Map__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -20055,26 +20055,26 @@ func (ma *_StructRepresentation_Map__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Map_sufficient != fieldBits__StructRepresentation_Map_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Map__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Map__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Map__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Map__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructRepresentation_Map__ReprKeyAssembler _StructRepresentation_Map__ReprAssembler -func (_StructRepresentation_Map__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Map__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Map__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Map__ReprKeyAssembler) AssignNull() error { @@ -20096,29 +20096,29 @@ func (ka *_StructRepresentation_Map__ReprKeyAssembler) AssignString(k string) er switch k { case "fields": if ka.s&fieldBit__StructRepresentation_Map_Fields != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_Fields_serial} } ka.s += fieldBit__StructRepresentation_Map_Fields ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map.Repr", Key: &_String{k}} } func (_StructRepresentation_Map__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Map__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Map__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Map__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Map__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -20144,12 +20144,12 @@ func (m MaybeStructRepresentation_Map_FieldDetails) IsAbsent() bool { func (m MaybeStructRepresentation_Map_FieldDetails) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation_Map_FieldDetails) AsNode() ipld.Node { +func (m MaybeStructRepresentation_Map_FieldDetails) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -20167,42 +20167,42 @@ var ( fieldName__StructRepresentation_Map_FieldDetails_Rename = _String{"rename"} fieldName__StructRepresentation_Map_FieldDetails_Implicit = _String{"implicit"} ) -var _ ipld.Node = (StructRepresentation_Map_FieldDetails)(&_StructRepresentation_Map_FieldDetails{}) +var _ datamodel.Node = (StructRepresentation_Map_FieldDetails)(&_StructRepresentation_Map_FieldDetails{}) var _ schema.TypedNode = (StructRepresentation_Map_FieldDetails)(&_StructRepresentation_Map_FieldDetails{}) -func (StructRepresentation_Map_FieldDetails) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation_Map_FieldDetails) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation_Map_FieldDetails) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation_Map_FieldDetails) LookupByString(key string) (datamodel.Node, error) { switch key { case "rename": if n.rename.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } return &n.rename.v, nil case "implicit": if n.implicit.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } return n.implicit.v, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation_Map_FieldDetails) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation_Map_FieldDetails) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation_Map_FieldDetails) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation_Map_FieldDetails) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails"}.LookupByIndex(0) } -func (n StructRepresentation_Map_FieldDetails) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation_Map_FieldDetails) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation_Map_FieldDetails) MapIterator() ipld.MapIterator { +func (n StructRepresentation_Map_FieldDetails) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Map_FieldDetails__MapItr{n, 0} } @@ -20211,22 +20211,22 @@ type _StructRepresentation_Map_FieldDetails__MapItr struct { idx int } -func (itr *_StructRepresentation_Map_FieldDetails__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Map_FieldDetails__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: k = &fieldName__StructRepresentation_Map_FieldDetails_Rename if itr.n.rename.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } v = &itr.n.rename.v case 1: k = &fieldName__StructRepresentation_Map_FieldDetails_Implicit if itr.n.implicit.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } v = itr.n.implicit.v @@ -20240,7 +20240,7 @@ func (itr *_StructRepresentation_Map_FieldDetails__MapItr) Done() bool { return itr.idx >= 2 } -func (StructRepresentation_Map_FieldDetails) ListIterator() ipld.ListIterator { +func (StructRepresentation_Map_FieldDetails) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation_Map_FieldDetails) Length() int64 { @@ -20267,16 +20267,16 @@ func (StructRepresentation_Map_FieldDetails) AsString() (string, error) { func (StructRepresentation_Map_FieldDetails) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails"}.AsBytes() } -func (StructRepresentation_Map_FieldDetails) AsLink() (ipld.Link, error) { +func (StructRepresentation_Map_FieldDetails) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails"}.AsLink() } -func (StructRepresentation_Map_FieldDetails) Prototype() ipld.NodePrototype { +func (StructRepresentation_Map_FieldDetails) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map_FieldDetails__Prototype{} } type _StructRepresentation_Map_FieldDetails__Prototype struct{} -func (_StructRepresentation_Map_FieldDetails__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Map_FieldDetails__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Map_FieldDetails__Builder nb.Reset() return &nb @@ -20286,7 +20286,7 @@ type _StructRepresentation_Map_FieldDetails__Builder struct { _StructRepresentation_Map_FieldDetails__Assembler } -func (nb *_StructRepresentation_Map_FieldDetails__Builder) Build() ipld.Node { +func (nb *_StructRepresentation_Map_FieldDetails__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -20323,7 +20323,7 @@ var ( fieldBits__StructRepresentation_Map_FieldDetails_sufficient = 0 ) -func (na *_StructRepresentation_Map_FieldDetails__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Map_FieldDetails__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -20336,7 +20336,7 @@ func (na *_StructRepresentation_Map_FieldDetails__Assembler) BeginMap(int64) (ip } return na, nil } -func (_StructRepresentation_Map_FieldDetails__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map_FieldDetails__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails"}.BeginList(0) } func (na *_StructRepresentation_Map_FieldDetails__Assembler) AssignNull() error { @@ -20368,10 +20368,10 @@ func (_StructRepresentation_Map_FieldDetails__Assembler) AssignString(string) er func (_StructRepresentation_Map_FieldDetails__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails"}.AssignBytes(nil) } -func (_StructRepresentation_Map_FieldDetails__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map_FieldDetails__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails"}.AssignLink(nil) } -func (na *_StructRepresentation_Map_FieldDetails__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Map_FieldDetails__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -20391,8 +20391,8 @@ func (na *_StructRepresentation_Map_FieldDetails__Assembler) AssignNode(v ipld.N *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -20409,7 +20409,7 @@ func (na *_StructRepresentation_Map_FieldDetails__Assembler) AssignNode(v ipld.N } return na.Finish() } -func (_StructRepresentation_Map_FieldDetails__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map_FieldDetails__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map_FieldDetails__Prototype{} } func (ma *_StructRepresentation_Map_FieldDetails__Assembler) valueFinishTidy() bool { @@ -20435,7 +20435,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__Assembler) valueFinishTidy() b panic("unreachable") } } -func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -20453,7 +20453,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k str switch k { case "rename": if ma.s&fieldBit__StructRepresentation_Map_FieldDetails_Rename != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename} } ma.s += fieldBit__StructRepresentation_Map_FieldDetails_Rename ma.state = maState_midValue @@ -20463,7 +20463,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k str return &ma.ca_rename, nil case "implicit": if ma.s&fieldBit__StructRepresentation_Map_FieldDetails_Implicit != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit} } ma.s += fieldBit__StructRepresentation_Map_FieldDetails_Implicit ma.state = maState_midValue @@ -20472,9 +20472,9 @@ func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleEntry(k str ma.ca_implicit.m = &ma.w.implicit.m return &ma.ca_implicit, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails", Key: &_String{k}} } -func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -20492,7 +20492,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleKey() ipld. ma.state = maState_midKey return (*_StructRepresentation_Map_FieldDetails__KeyAssembler)(ma) } -func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map_FieldDetails__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -20535,26 +20535,26 @@ func (ma *_StructRepresentation_Map_FieldDetails__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Map_FieldDetails_sufficient != fieldBits__StructRepresentation_Map_FieldDetails_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Map_FieldDetails__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Map_FieldDetails__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Map_FieldDetails__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Map_FieldDetails__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructRepresentation_Map_FieldDetails__KeyAssembler _StructRepresentation_Map_FieldDetails__Assembler -func (_StructRepresentation_Map_FieldDetails__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Map_FieldDetails__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Map_FieldDetails__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map_FieldDetails__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignNull() error { @@ -20576,7 +20576,7 @@ func (ka *_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignString(k s switch k { case "rename": if ka.s&fieldBit__StructRepresentation_Map_FieldDetails_Rename != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename} } ka.s += fieldBit__StructRepresentation_Map_FieldDetails_Rename ka.state = maState_expectValue @@ -20584,36 +20584,36 @@ func (ka *_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignString(k s return nil case "implicit": if ka.s&fieldBit__StructRepresentation_Map_FieldDetails_Implicit != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit} } ka.s += fieldBit__StructRepresentation_Map_FieldDetails_Implicit ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails", Key: &_String{k}} } } func (_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Map_FieldDetails__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Map_FieldDetails__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map_FieldDetails__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation_Map_FieldDetails) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation_Map_FieldDetails) Representation() ipld.Node { +func (n StructRepresentation_Map_FieldDetails) Representation() datamodel.Node { return (*_StructRepresentation_Map_FieldDetails__Repr)(n) } @@ -20623,41 +20623,41 @@ var ( fieldName__StructRepresentation_Map_FieldDetails_Rename_serial = _String{"rename"} fieldName__StructRepresentation_Map_FieldDetails_Implicit_serial = _String{"implicit"} ) -var _ ipld.Node = &_StructRepresentation_Map_FieldDetails__Repr{} +var _ datamodel.Node = &_StructRepresentation_Map_FieldDetails__Repr{} -func (_StructRepresentation_Map_FieldDetails__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation_Map_FieldDetails__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation_Map_FieldDetails__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation_Map_FieldDetails__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "rename": if n.rename.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.rename.v.Representation(), nil case "implicit": if n.implicit.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.implicit.v.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation_Map_FieldDetails__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation_Map_FieldDetails__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation_Map_FieldDetails__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation_Map_FieldDetails__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation_Map_FieldDetails__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation_Map_FieldDetails__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation_Map_FieldDetails__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation_Map_FieldDetails__Repr) MapIterator() datamodel.MapIterator { end := 2 if n.implicit.m == schema.Maybe_Absent { end = 1 @@ -20679,10 +20679,10 @@ type _StructRepresentation_Map_FieldDetails__ReprMapItr struct { end int } -func (itr *_StructRepresentation_Map_FieldDetails__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Map_FieldDetails__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { advance: if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -20708,7 +20708,7 @@ advance: func (itr *_StructRepresentation_Map_FieldDetails__ReprMapItr) Done() bool { return itr.idx >= itr.end } -func (_StructRepresentation_Map_FieldDetails__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation_Map_FieldDetails__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructRepresentation_Map_FieldDetails__Repr) Length() int64 { @@ -20742,16 +20742,16 @@ func (_StructRepresentation_Map_FieldDetails__Repr) AsString() (string, error) { func (_StructRepresentation_Map_FieldDetails__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr"}.AsBytes() } -func (_StructRepresentation_Map_FieldDetails__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation_Map_FieldDetails__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr"}.AsLink() } -func (_StructRepresentation_Map_FieldDetails__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map_FieldDetails__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map_FieldDetails__ReprPrototype{} } type _StructRepresentation_Map_FieldDetails__ReprPrototype struct{} -func (_StructRepresentation_Map_FieldDetails__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Map_FieldDetails__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Map_FieldDetails__ReprBuilder nb.Reset() return &nb @@ -20761,7 +20761,7 @@ type _StructRepresentation_Map_FieldDetails__ReprBuilder struct { _StructRepresentation_Map_FieldDetails__ReprAssembler } -func (nb *_StructRepresentation_Map_FieldDetails__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation_Map_FieldDetails__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -20791,7 +20791,7 @@ func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) reset() { na.ca_rename.reset() na.ca_implicit.reset() } -func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -20804,7 +20804,7 @@ func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) BeginMap(int64) } return na, nil } -func (_StructRepresentation_Map_FieldDetails__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map_FieldDetails__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr"}.BeginList(0) } func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNull() error { @@ -20836,10 +20836,10 @@ func (_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignString(string func (_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr"}.AssignBytes(nil) } -func (_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -20859,8 +20859,8 @@ func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNode(v ip *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -20877,7 +20877,7 @@ func (na *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssignNode(v ip } return na.Finish() } -func (_StructRepresentation_Map_FieldDetails__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map_FieldDetails__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Map_FieldDetails__ReprPrototype{} } func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) valueFinishTidy() bool { @@ -20903,7 +20903,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) valueFinishTidy panic("unreachable") } } -func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -20921,7 +20921,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k switch k { case "rename": if ma.s&fieldBit__StructRepresentation_Map_FieldDetails_Rename != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename_serial} } ma.s += fieldBit__StructRepresentation_Map_FieldDetails_Rename ma.state = maState_midValue @@ -20932,7 +20932,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k return &ma.ca_rename, nil case "implicit": if ma.s&fieldBit__StructRepresentation_Map_FieldDetails_Implicit != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit_serial} } ma.s += fieldBit__StructRepresentation_Map_FieldDetails_Implicit ma.state = maState_midValue @@ -20943,9 +20943,9 @@ func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleEntry(k return &ma.ca_implicit, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -20963,7 +20963,7 @@ func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleKey() i ma.state = maState_midKey return (*_StructRepresentation_Map_FieldDetails__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -21008,26 +21008,26 @@ func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) Finish() error panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Map_FieldDetails_sufficient != fieldBits__StructRepresentation_Map_FieldDetails_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Map_FieldDetails__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructRepresentation_Map_FieldDetails__ReprKeyAssembler _StructRepresentation_Map_FieldDetails__ReprAssembler -func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignNull() error { @@ -21049,7 +21049,7 @@ func (ka *_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignString switch k { case "rename": if ka.s&fieldBit__StructRepresentation_Map_FieldDetails_Rename != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Rename_serial} } ka.s += fieldBit__StructRepresentation_Map_FieldDetails_Rename ka.state = maState_expectValue @@ -21057,29 +21057,29 @@ func (ka *_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignString return nil case "implicit": if ka.s&fieldBit__StructRepresentation_Map_FieldDetails_Implicit != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Map_FieldDetails_Implicit_serial} } ka.s += fieldBit__StructRepresentation_Map_FieldDetails_Implicit ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr", Key: &_String{k}} } func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Map_FieldDetails.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Map_FieldDetails__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -21105,12 +21105,12 @@ func (m MaybeStructRepresentation_Stringjoin) IsAbsent() bool { func (m MaybeStructRepresentation_Stringjoin) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation_Stringjoin) AsNode() ipld.Node { +func (m MaybeStructRepresentation_Stringjoin) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -21128,39 +21128,39 @@ var ( fieldName__StructRepresentation_Stringjoin_Join = _String{"join"} fieldName__StructRepresentation_Stringjoin_FieldOrder = _String{"fieldOrder"} ) -var _ ipld.Node = (StructRepresentation_Stringjoin)(&_StructRepresentation_Stringjoin{}) +var _ datamodel.Node = (StructRepresentation_Stringjoin)(&_StructRepresentation_Stringjoin{}) var _ schema.TypedNode = (StructRepresentation_Stringjoin)(&_StructRepresentation_Stringjoin{}) -func (StructRepresentation_Stringjoin) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation_Stringjoin) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation_Stringjoin) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation_Stringjoin) LookupByString(key string) (datamodel.Node, error) { switch key { case "join": return &n.join, nil case "fieldOrder": if n.fieldOrder.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } return &n.fieldOrder.v, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation_Stringjoin) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation_Stringjoin) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation_Stringjoin) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation_Stringjoin) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringjoin"}.LookupByIndex(0) } -func (n StructRepresentation_Stringjoin) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation_Stringjoin) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation_Stringjoin) MapIterator() ipld.MapIterator { +func (n StructRepresentation_Stringjoin) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Stringjoin__MapItr{n, 0} } @@ -21169,9 +21169,9 @@ type _StructRepresentation_Stringjoin__MapItr struct { idx int } -func (itr *_StructRepresentation_Stringjoin__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Stringjoin__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -21180,7 +21180,7 @@ func (itr *_StructRepresentation_Stringjoin__MapItr) Next() (k ipld.Node, v ipld case 1: k = &fieldName__StructRepresentation_Stringjoin_FieldOrder if itr.n.fieldOrder.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } v = &itr.n.fieldOrder.v @@ -21194,7 +21194,7 @@ func (itr *_StructRepresentation_Stringjoin__MapItr) Done() bool { return itr.idx >= 2 } -func (StructRepresentation_Stringjoin) ListIterator() ipld.ListIterator { +func (StructRepresentation_Stringjoin) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation_Stringjoin) Length() int64 { @@ -21221,16 +21221,16 @@ func (StructRepresentation_Stringjoin) AsString() (string, error) { func (StructRepresentation_Stringjoin) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringjoin"}.AsBytes() } -func (StructRepresentation_Stringjoin) AsLink() (ipld.Link, error) { +func (StructRepresentation_Stringjoin) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringjoin"}.AsLink() } -func (StructRepresentation_Stringjoin) Prototype() ipld.NodePrototype { +func (StructRepresentation_Stringjoin) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringjoin__Prototype{} } type _StructRepresentation_Stringjoin__Prototype struct{} -func (_StructRepresentation_Stringjoin__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Stringjoin__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Stringjoin__Builder nb.Reset() return &nb @@ -21240,7 +21240,7 @@ type _StructRepresentation_Stringjoin__Builder struct { _StructRepresentation_Stringjoin__Assembler } -func (nb *_StructRepresentation_Stringjoin__Builder) Build() ipld.Node { +func (nb *_StructRepresentation_Stringjoin__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -21277,7 +21277,7 @@ var ( fieldBits__StructRepresentation_Stringjoin_sufficient = 0 + 1<<0 ) -func (na *_StructRepresentation_Stringjoin__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Stringjoin__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -21290,7 +21290,7 @@ func (na *_StructRepresentation_Stringjoin__Assembler) BeginMap(int64) (ipld.Map } return na, nil } -func (_StructRepresentation_Stringjoin__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringjoin__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin"}.BeginList(0) } func (na *_StructRepresentation_Stringjoin__Assembler) AssignNull() error { @@ -21322,10 +21322,10 @@ func (_StructRepresentation_Stringjoin__Assembler) AssignString(string) error { func (_StructRepresentation_Stringjoin__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin"}.AssignBytes(nil) } -func (_StructRepresentation_Stringjoin__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringjoin__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin"}.AssignLink(nil) } -func (na *_StructRepresentation_Stringjoin__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Stringjoin__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -21345,8 +21345,8 @@ func (na *_StructRepresentation_Stringjoin__Assembler) AssignNode(v ipld.Node) e *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringjoin", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringjoin", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -21363,7 +21363,7 @@ func (na *_StructRepresentation_Stringjoin__Assembler) AssignNode(v ipld.Node) e } return na.Finish() } -func (_StructRepresentation_Stringjoin__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringjoin__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringjoin__Prototype{} } func (ma *_StructRepresentation_Stringjoin__Assembler) valueFinishTidy() bool { @@ -21390,7 +21390,7 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -21408,7 +21408,7 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleEntry(k string) ( switch k { case "join": if ma.s&fieldBit__StructRepresentation_Stringjoin_Join != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join} } ma.s += fieldBit__StructRepresentation_Stringjoin_Join ma.state = maState_midValue @@ -21418,7 +21418,7 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleEntry(k string) ( return &ma.ca_join, nil case "fieldOrder": if ma.s&fieldBit__StructRepresentation_Stringjoin_FieldOrder != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder} } ma.s += fieldBit__StructRepresentation_Stringjoin_FieldOrder ma.state = maState_midValue @@ -21427,9 +21427,9 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleEntry(k string) ( ma.ca_fieldOrder.m = &ma.w.fieldOrder.m return &ma.ca_fieldOrder, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin", Key: &_String{k}} } -func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -21447,7 +21447,7 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleKey() ipld.NodeAs ma.state = maState_midKey return (*_StructRepresentation_Stringjoin__KeyAssembler)(ma) } -func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringjoin__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -21490,7 +21490,7 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Stringjoin_sufficient != fieldBits__StructRepresentation_Stringjoin_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__StructRepresentation_Stringjoin_Join == 0 { err.Missing = append(err.Missing, "join") } @@ -21500,19 +21500,19 @@ func (ma *_StructRepresentation_Stringjoin__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Stringjoin__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Stringjoin__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Stringjoin__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Stringjoin__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructRepresentation_Stringjoin__KeyAssembler _StructRepresentation_Stringjoin__Assembler -func (_StructRepresentation_Stringjoin__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Stringjoin__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Stringjoin__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringjoin__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Stringjoin__KeyAssembler) AssignNull() error { @@ -21534,7 +21534,7 @@ func (ka *_StructRepresentation_Stringjoin__KeyAssembler) AssignString(k string) switch k { case "join": if ka.s&fieldBit__StructRepresentation_Stringjoin_Join != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join} } ka.s += fieldBit__StructRepresentation_Stringjoin_Join ka.state = maState_expectValue @@ -21542,36 +21542,36 @@ func (ka *_StructRepresentation_Stringjoin__KeyAssembler) AssignString(k string) return nil case "fieldOrder": if ka.s&fieldBit__StructRepresentation_Stringjoin_FieldOrder != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder} } ka.s += fieldBit__StructRepresentation_Stringjoin_FieldOrder ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin", Key: &_String{k}} } } func (_StructRepresentation_Stringjoin__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Stringjoin__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringjoin__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Stringjoin__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Stringjoin__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Stringjoin__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringjoin__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation_Stringjoin) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation_Stringjoin) Representation() ipld.Node { +func (n StructRepresentation_Stringjoin) Representation() datamodel.Node { return (*_StructRepresentation_Stringjoin__Repr)(n) } @@ -21581,38 +21581,38 @@ var ( fieldName__StructRepresentation_Stringjoin_Join_serial = _String{"join"} fieldName__StructRepresentation_Stringjoin_FieldOrder_serial = _String{"fieldOrder"} ) -var _ ipld.Node = &_StructRepresentation_Stringjoin__Repr{} +var _ datamodel.Node = &_StructRepresentation_Stringjoin__Repr{} -func (_StructRepresentation_Stringjoin__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation_Stringjoin__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation_Stringjoin__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation_Stringjoin__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "join": return n.join.Representation(), nil case "fieldOrder": if n.fieldOrder.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.fieldOrder.v.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation_Stringjoin__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation_Stringjoin__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation_Stringjoin__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation_Stringjoin__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation_Stringjoin__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation_Stringjoin__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation_Stringjoin__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation_Stringjoin__Repr) MapIterator() datamodel.MapIterator { end := 2 if n.fieldOrder.m == schema.Maybe_Absent { end = 1 @@ -21629,10 +21629,10 @@ type _StructRepresentation_Stringjoin__ReprMapItr struct { end int } -func (itr *_StructRepresentation_Stringjoin__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Stringjoin__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { advance: if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -21654,7 +21654,7 @@ advance: func (itr *_StructRepresentation_Stringjoin__ReprMapItr) Done() bool { return itr.idx >= itr.end } -func (_StructRepresentation_Stringjoin__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation_Stringjoin__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructRepresentation_Stringjoin__Repr) Length() int64 { @@ -21685,16 +21685,16 @@ func (_StructRepresentation_Stringjoin__Repr) AsString() (string, error) { func (_StructRepresentation_Stringjoin__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr"}.AsBytes() } -func (_StructRepresentation_Stringjoin__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation_Stringjoin__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr"}.AsLink() } -func (_StructRepresentation_Stringjoin__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringjoin__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringjoin__ReprPrototype{} } type _StructRepresentation_Stringjoin__ReprPrototype struct{} -func (_StructRepresentation_Stringjoin__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Stringjoin__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Stringjoin__ReprBuilder nb.Reset() return &nb @@ -21704,7 +21704,7 @@ type _StructRepresentation_Stringjoin__ReprBuilder struct { _StructRepresentation_Stringjoin__ReprAssembler } -func (nb *_StructRepresentation_Stringjoin__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation_Stringjoin__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -21734,7 +21734,7 @@ func (na *_StructRepresentation_Stringjoin__ReprAssembler) reset() { na.ca_join.reset() na.ca_fieldOrder.reset() } -func (na *_StructRepresentation_Stringjoin__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Stringjoin__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -21747,7 +21747,7 @@ func (na *_StructRepresentation_Stringjoin__ReprAssembler) BeginMap(int64) (ipld } return na, nil } -func (_StructRepresentation_Stringjoin__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringjoin__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr"}.BeginList(0) } func (na *_StructRepresentation_Stringjoin__ReprAssembler) AssignNull() error { @@ -21779,10 +21779,10 @@ func (_StructRepresentation_Stringjoin__ReprAssembler) AssignString(string) erro func (_StructRepresentation_Stringjoin__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr"}.AssignBytes(nil) } -func (_StructRepresentation_Stringjoin__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringjoin__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation_Stringjoin__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Stringjoin__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -21802,8 +21802,8 @@ func (na *_StructRepresentation_Stringjoin__ReprAssembler) AssignNode(v ipld.Nod *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -21820,7 +21820,7 @@ func (na *_StructRepresentation_Stringjoin__ReprAssembler) AssignNode(v ipld.Nod } return na.Finish() } -func (_StructRepresentation_Stringjoin__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringjoin__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringjoin__ReprPrototype{} } func (ma *_StructRepresentation_Stringjoin__ReprAssembler) valueFinishTidy() bool { @@ -21846,7 +21846,7 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) valueFinishTidy() boo panic("unreachable") } } -func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -21864,7 +21864,7 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleEntry(k strin switch k { case "join": if ma.s&fieldBit__StructRepresentation_Stringjoin_Join != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join_serial} } ma.s += fieldBit__StructRepresentation_Stringjoin_Join ma.state = maState_midValue @@ -21874,7 +21874,7 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleEntry(k strin return &ma.ca_join, nil case "fieldOrder": if ma.s&fieldBit__StructRepresentation_Stringjoin_FieldOrder != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder_serial} } ma.s += fieldBit__StructRepresentation_Stringjoin_FieldOrder ma.state = maState_midValue @@ -21885,9 +21885,9 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleEntry(k strin return &ma.ca_fieldOrder, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -21905,7 +21905,7 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleKey() ipld.No ma.state = maState_midKey return (*_StructRepresentation_Stringjoin__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringjoin__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -21949,7 +21949,7 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Stringjoin_sufficient != fieldBits__StructRepresentation_Stringjoin_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__StructRepresentation_Stringjoin_Join == 0 { err.Missing = append(err.Missing, "join") } @@ -21959,19 +21959,19 @@ func (ma *_StructRepresentation_Stringjoin__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Stringjoin__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Stringjoin__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Stringjoin__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Stringjoin__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructRepresentation_Stringjoin__ReprKeyAssembler _StructRepresentation_Stringjoin__ReprAssembler -func (_StructRepresentation_Stringjoin__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Stringjoin__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Stringjoin__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringjoin__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignNull() error { @@ -21993,7 +21993,7 @@ func (ka *_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignString(k str switch k { case "join": if ka.s&fieldBit__StructRepresentation_Stringjoin_Join != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_Join_serial} } ka.s += fieldBit__StructRepresentation_Stringjoin_Join ka.state = maState_expectValue @@ -22001,29 +22001,29 @@ func (ka *_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignString(k str return nil case "fieldOrder": if ka.s&fieldBit__StructRepresentation_Stringjoin_FieldOrder != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringjoin_FieldOrder_serial} } ka.s += fieldBit__StructRepresentation_Stringjoin_FieldOrder ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr", Key: &_String{k}} } func (_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringjoin.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Stringjoin__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Stringjoin__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringjoin__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -22049,12 +22049,12 @@ func (m MaybeStructRepresentation_Stringpairs) IsAbsent() bool { func (m MaybeStructRepresentation_Stringpairs) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation_Stringpairs) AsNode() ipld.Node { +func (m MaybeStructRepresentation_Stringpairs) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -22072,36 +22072,36 @@ var ( fieldName__StructRepresentation_Stringpairs_InnerDelim = _String{"innerDelim"} fieldName__StructRepresentation_Stringpairs_EntryDelim = _String{"entryDelim"} ) -var _ ipld.Node = (StructRepresentation_Stringpairs)(&_StructRepresentation_Stringpairs{}) +var _ datamodel.Node = (StructRepresentation_Stringpairs)(&_StructRepresentation_Stringpairs{}) var _ schema.TypedNode = (StructRepresentation_Stringpairs)(&_StructRepresentation_Stringpairs{}) -func (StructRepresentation_Stringpairs) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation_Stringpairs) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation_Stringpairs) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation_Stringpairs) LookupByString(key string) (datamodel.Node, error) { switch key { case "innerDelim": return &n.innerDelim, nil case "entryDelim": return &n.entryDelim, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation_Stringpairs) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation_Stringpairs) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation_Stringpairs) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation_Stringpairs) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringpairs"}.LookupByIndex(0) } -func (n StructRepresentation_Stringpairs) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation_Stringpairs) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation_Stringpairs) MapIterator() ipld.MapIterator { +func (n StructRepresentation_Stringpairs) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Stringpairs__MapItr{n, 0} } @@ -22110,9 +22110,9 @@ type _StructRepresentation_Stringpairs__MapItr struct { idx int } -func (itr *_StructRepresentation_Stringpairs__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Stringpairs__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -22131,7 +22131,7 @@ func (itr *_StructRepresentation_Stringpairs__MapItr) Done() bool { return itr.idx >= 2 } -func (StructRepresentation_Stringpairs) ListIterator() ipld.ListIterator { +func (StructRepresentation_Stringpairs) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation_Stringpairs) Length() int64 { @@ -22158,16 +22158,16 @@ func (StructRepresentation_Stringpairs) AsString() (string, error) { func (StructRepresentation_Stringpairs) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringpairs"}.AsBytes() } -func (StructRepresentation_Stringpairs) AsLink() (ipld.Link, error) { +func (StructRepresentation_Stringpairs) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringpairs"}.AsLink() } -func (StructRepresentation_Stringpairs) Prototype() ipld.NodePrototype { +func (StructRepresentation_Stringpairs) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringpairs__Prototype{} } type _StructRepresentation_Stringpairs__Prototype struct{} -func (_StructRepresentation_Stringpairs__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Stringpairs__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Stringpairs__Builder nb.Reset() return &nb @@ -22177,7 +22177,7 @@ type _StructRepresentation_Stringpairs__Builder struct { _StructRepresentation_Stringpairs__Assembler } -func (nb *_StructRepresentation_Stringpairs__Builder) Build() ipld.Node { +func (nb *_StructRepresentation_Stringpairs__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -22214,7 +22214,7 @@ var ( fieldBits__StructRepresentation_Stringpairs_sufficient = 0 + 1<<0 + 1<<1 ) -func (na *_StructRepresentation_Stringpairs__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Stringpairs__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -22227,7 +22227,7 @@ func (na *_StructRepresentation_Stringpairs__Assembler) BeginMap(int64) (ipld.Ma } return na, nil } -func (_StructRepresentation_Stringpairs__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringpairs__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs"}.BeginList(0) } func (na *_StructRepresentation_Stringpairs__Assembler) AssignNull() error { @@ -22259,10 +22259,10 @@ func (_StructRepresentation_Stringpairs__Assembler) AssignString(string) error { func (_StructRepresentation_Stringpairs__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs"}.AssignBytes(nil) } -func (_StructRepresentation_Stringpairs__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringpairs__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs"}.AssignLink(nil) } -func (na *_StructRepresentation_Stringpairs__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Stringpairs__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -22282,8 +22282,8 @@ func (na *_StructRepresentation_Stringpairs__Assembler) AssignNode(v ipld.Node) *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringpairs", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringpairs", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -22300,7 +22300,7 @@ func (na *_StructRepresentation_Stringpairs__Assembler) AssignNode(v ipld.Node) } return na.Finish() } -func (_StructRepresentation_Stringpairs__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringpairs__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringpairs__Prototype{} } func (ma *_StructRepresentation_Stringpairs__Assembler) valueFinishTidy() bool { @@ -22329,7 +22329,7 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -22347,7 +22347,7 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleEntry(k string) switch k { case "innerDelim": if ma.s&fieldBit__StructRepresentation_Stringpairs_InnerDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim} } ma.s += fieldBit__StructRepresentation_Stringpairs_InnerDelim ma.state = maState_midValue @@ -22357,7 +22357,7 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleEntry(k string) return &ma.ca_innerDelim, nil case "entryDelim": if ma.s&fieldBit__StructRepresentation_Stringpairs_EntryDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim} } ma.s += fieldBit__StructRepresentation_Stringpairs_EntryDelim ma.state = maState_midValue @@ -22366,9 +22366,9 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleEntry(k string) ma.ca_entryDelim.m = &ma.cm return &ma.ca_entryDelim, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs", Key: &_String{k}} } -func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -22386,7 +22386,7 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleKey() ipld.NodeA ma.state = maState_midKey return (*_StructRepresentation_Stringpairs__KeyAssembler)(ma) } -func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringpairs__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -22429,7 +22429,7 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Stringpairs_sufficient != fieldBits__StructRepresentation_Stringpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__StructRepresentation_Stringpairs_InnerDelim == 0 { err.Missing = append(err.Missing, "innerDelim") } @@ -22442,19 +22442,19 @@ func (ma *_StructRepresentation_Stringpairs__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Stringpairs__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Stringpairs__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Stringpairs__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Stringpairs__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructRepresentation_Stringpairs__KeyAssembler _StructRepresentation_Stringpairs__Assembler -func (_StructRepresentation_Stringpairs__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Stringpairs__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Stringpairs__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringpairs__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Stringpairs__KeyAssembler) AssignNull() error { @@ -22476,7 +22476,7 @@ func (ka *_StructRepresentation_Stringpairs__KeyAssembler) AssignString(k string switch k { case "innerDelim": if ka.s&fieldBit__StructRepresentation_Stringpairs_InnerDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim} } ka.s += fieldBit__StructRepresentation_Stringpairs_InnerDelim ka.state = maState_expectValue @@ -22484,36 +22484,36 @@ func (ka *_StructRepresentation_Stringpairs__KeyAssembler) AssignString(k string return nil case "entryDelim": if ka.s&fieldBit__StructRepresentation_Stringpairs_EntryDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim} } ka.s += fieldBit__StructRepresentation_Stringpairs_EntryDelim ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs", Key: &_String{k}} } } func (_StructRepresentation_Stringpairs__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Stringpairs__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringpairs__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Stringpairs__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Stringpairs__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Stringpairs__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringpairs__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation_Stringpairs) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation_Stringpairs) Representation() ipld.Node { +func (n StructRepresentation_Stringpairs) Representation() datamodel.Node { return (*_StructRepresentation_Stringpairs__Repr)(n) } @@ -22523,35 +22523,35 @@ var ( fieldName__StructRepresentation_Stringpairs_InnerDelim_serial = _String{"innerDelim"} fieldName__StructRepresentation_Stringpairs_EntryDelim_serial = _String{"entryDelim"} ) -var _ ipld.Node = &_StructRepresentation_Stringpairs__Repr{} +var _ datamodel.Node = &_StructRepresentation_Stringpairs__Repr{} -func (_StructRepresentation_Stringpairs__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation_Stringpairs__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation_Stringpairs__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation_Stringpairs__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "innerDelim": return n.innerDelim.Representation(), nil case "entryDelim": return n.entryDelim.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation_Stringpairs__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation_Stringpairs__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation_Stringpairs__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation_Stringpairs__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation_Stringpairs__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation_Stringpairs__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation_Stringpairs__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation_Stringpairs__Repr) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Stringpairs__ReprMapItr{n, 0} } @@ -22560,9 +22560,9 @@ type _StructRepresentation_Stringpairs__ReprMapItr struct { idx int } -func (itr *_StructRepresentation_Stringpairs__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Stringpairs__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -22580,7 +22580,7 @@ func (itr *_StructRepresentation_Stringpairs__ReprMapItr) Next() (k ipld.Node, v func (itr *_StructRepresentation_Stringpairs__ReprMapItr) Done() bool { return itr.idx >= 2 } -func (_StructRepresentation_Stringpairs__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation_Stringpairs__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructRepresentation_Stringpairs__Repr) Length() int64 { @@ -22608,16 +22608,16 @@ func (_StructRepresentation_Stringpairs__Repr) AsString() (string, error) { func (_StructRepresentation_Stringpairs__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr"}.AsBytes() } -func (_StructRepresentation_Stringpairs__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation_Stringpairs__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr"}.AsLink() } -func (_StructRepresentation_Stringpairs__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringpairs__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringpairs__ReprPrototype{} } type _StructRepresentation_Stringpairs__ReprPrototype struct{} -func (_StructRepresentation_Stringpairs__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Stringpairs__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Stringpairs__ReprBuilder nb.Reset() return &nb @@ -22627,7 +22627,7 @@ type _StructRepresentation_Stringpairs__ReprBuilder struct { _StructRepresentation_Stringpairs__ReprAssembler } -func (nb *_StructRepresentation_Stringpairs__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation_Stringpairs__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -22657,7 +22657,7 @@ func (na *_StructRepresentation_Stringpairs__ReprAssembler) reset() { na.ca_innerDelim.reset() na.ca_entryDelim.reset() } -func (na *_StructRepresentation_Stringpairs__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Stringpairs__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -22670,7 +22670,7 @@ func (na *_StructRepresentation_Stringpairs__ReprAssembler) BeginMap(int64) (ipl } return na, nil } -func (_StructRepresentation_Stringpairs__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringpairs__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr"}.BeginList(0) } func (na *_StructRepresentation_Stringpairs__ReprAssembler) AssignNull() error { @@ -22702,10 +22702,10 @@ func (_StructRepresentation_Stringpairs__ReprAssembler) AssignString(string) err func (_StructRepresentation_Stringpairs__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr"}.AssignBytes(nil) } -func (_StructRepresentation_Stringpairs__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringpairs__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation_Stringpairs__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Stringpairs__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -22725,8 +22725,8 @@ func (na *_StructRepresentation_Stringpairs__ReprAssembler) AssignNode(v ipld.No *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -22743,7 +22743,7 @@ func (na *_StructRepresentation_Stringpairs__ReprAssembler) AssignNode(v ipld.No } return na.Finish() } -func (_StructRepresentation_Stringpairs__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringpairs__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Stringpairs__ReprPrototype{} } func (ma *_StructRepresentation_Stringpairs__ReprAssembler) valueFinishTidy() bool { @@ -22770,7 +22770,7 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) valueFinishTidy() bo panic("unreachable") } } -func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -22788,7 +22788,7 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k stri switch k { case "innerDelim": if ma.s&fieldBit__StructRepresentation_Stringpairs_InnerDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim_serial} } ma.s += fieldBit__StructRepresentation_Stringpairs_InnerDelim ma.state = maState_midValue @@ -22798,7 +22798,7 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k stri return &ma.ca_innerDelim, nil case "entryDelim": if ma.s&fieldBit__StructRepresentation_Stringpairs_EntryDelim != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim_serial} } ma.s += fieldBit__StructRepresentation_Stringpairs_EntryDelim ma.state = maState_midValue @@ -22808,9 +22808,9 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleEntry(k stri return &ma.ca_entryDelim, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -22828,7 +22828,7 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleKey() ipld.N ma.state = maState_midKey return (*_StructRepresentation_Stringpairs__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Stringpairs__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -22871,7 +22871,7 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Stringpairs_sufficient != fieldBits__StructRepresentation_Stringpairs_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__StructRepresentation_Stringpairs_InnerDelim == 0 { err.Missing = append(err.Missing, "innerDelim") } @@ -22884,19 +22884,19 @@ func (ma *_StructRepresentation_Stringpairs__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Stringpairs__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Stringpairs__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Stringpairs__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Stringpairs__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructRepresentation_Stringpairs__ReprKeyAssembler _StructRepresentation_Stringpairs__ReprAssembler -func (_StructRepresentation_Stringpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Stringpairs__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Stringpairs__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Stringpairs__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignNull() error { @@ -22918,7 +22918,7 @@ func (ka *_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignString(k st switch k { case "innerDelim": if ka.s&fieldBit__StructRepresentation_Stringpairs_InnerDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_InnerDelim_serial} } ka.s += fieldBit__StructRepresentation_Stringpairs_InnerDelim ka.state = maState_expectValue @@ -22926,29 +22926,29 @@ func (ka *_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignString(k st return nil case "entryDelim": if ka.s&fieldBit__StructRepresentation_Stringpairs_EntryDelim != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Stringpairs_EntryDelim_serial} } ka.s += fieldBit__StructRepresentation_Stringpairs_EntryDelim ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr", Key: &_String{k}} } func (_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Stringpairs.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Stringpairs__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Stringpairs__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Stringpairs__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -22971,12 +22971,12 @@ func (m MaybeStructRepresentation_Tuple) IsAbsent() bool { func (m MaybeStructRepresentation_Tuple) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeStructRepresentation_Tuple) AsNode() ipld.Node { +func (m MaybeStructRepresentation_Tuple) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -22993,37 +22993,37 @@ func (m MaybeStructRepresentation_Tuple) Must() StructRepresentation_Tuple { var ( fieldName__StructRepresentation_Tuple_FieldOrder = _String{"fieldOrder"} ) -var _ ipld.Node = (StructRepresentation_Tuple)(&_StructRepresentation_Tuple{}) +var _ datamodel.Node = (StructRepresentation_Tuple)(&_StructRepresentation_Tuple{}) var _ schema.TypedNode = (StructRepresentation_Tuple)(&_StructRepresentation_Tuple{}) -func (StructRepresentation_Tuple) Kind() ipld.Kind { - return ipld.Kind_Map +func (StructRepresentation_Tuple) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n StructRepresentation_Tuple) LookupByString(key string) (ipld.Node, error) { +func (n StructRepresentation_Tuple) LookupByString(key string) (datamodel.Node, error) { switch key { case "fieldOrder": if n.fieldOrder.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } return &n.fieldOrder.v, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n StructRepresentation_Tuple) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n StructRepresentation_Tuple) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (StructRepresentation_Tuple) LookupByIndex(idx int64) (ipld.Node, error) { +func (StructRepresentation_Tuple) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Tuple"}.LookupByIndex(0) } -func (n StructRepresentation_Tuple) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n StructRepresentation_Tuple) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n StructRepresentation_Tuple) MapIterator() ipld.MapIterator { +func (n StructRepresentation_Tuple) MapIterator() datamodel.MapIterator { return &_StructRepresentation_Tuple__MapItr{n, 0} } @@ -23032,15 +23032,15 @@ type _StructRepresentation_Tuple__MapItr struct { idx int } -func (itr *_StructRepresentation_Tuple__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Tuple__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: k = &fieldName__StructRepresentation_Tuple_FieldOrder if itr.n.fieldOrder.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } v = &itr.n.fieldOrder.v @@ -23054,7 +23054,7 @@ func (itr *_StructRepresentation_Tuple__MapItr) Done() bool { return itr.idx >= 1 } -func (StructRepresentation_Tuple) ListIterator() ipld.ListIterator { +func (StructRepresentation_Tuple) ListIterator() datamodel.ListIterator { return nil } func (StructRepresentation_Tuple) Length() int64 { @@ -23081,16 +23081,16 @@ func (StructRepresentation_Tuple) AsString() (string, error) { func (StructRepresentation_Tuple) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Tuple"}.AsBytes() } -func (StructRepresentation_Tuple) AsLink() (ipld.Link, error) { +func (StructRepresentation_Tuple) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Tuple"}.AsLink() } -func (StructRepresentation_Tuple) Prototype() ipld.NodePrototype { +func (StructRepresentation_Tuple) Prototype() datamodel.NodePrototype { return _StructRepresentation_Tuple__Prototype{} } type _StructRepresentation_Tuple__Prototype struct{} -func (_StructRepresentation_Tuple__Prototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Tuple__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Tuple__Builder nb.Reset() return &nb @@ -23100,7 +23100,7 @@ type _StructRepresentation_Tuple__Builder struct { _StructRepresentation_Tuple__Assembler } -func (nb *_StructRepresentation_Tuple__Builder) Build() ipld.Node { +func (nb *_StructRepresentation_Tuple__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -23134,7 +23134,7 @@ var ( fieldBits__StructRepresentation_Tuple_sufficient = 0 ) -func (na *_StructRepresentation_Tuple__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Tuple__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -23147,7 +23147,7 @@ func (na *_StructRepresentation_Tuple__Assembler) BeginMap(int64) (ipld.MapAssem } return na, nil } -func (_StructRepresentation_Tuple__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Tuple__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Tuple"}.BeginList(0) } func (na *_StructRepresentation_Tuple__Assembler) AssignNull() error { @@ -23179,10 +23179,10 @@ func (_StructRepresentation_Tuple__Assembler) AssignString(string) error { func (_StructRepresentation_Tuple__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Tuple"}.AssignBytes(nil) } -func (_StructRepresentation_Tuple__Assembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Tuple__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Tuple"}.AssignLink(nil) } -func (na *_StructRepresentation_Tuple__Assembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Tuple__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -23202,8 +23202,8 @@ func (na *_StructRepresentation_Tuple__Assembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Tuple", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Tuple", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -23220,7 +23220,7 @@ func (na *_StructRepresentation_Tuple__Assembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_StructRepresentation_Tuple__Assembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Tuple__Assembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Tuple__Prototype{} } func (ma *_StructRepresentation_Tuple__Assembler) valueFinishTidy() bool { @@ -23237,7 +23237,7 @@ func (ma *_StructRepresentation_Tuple__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Tuple__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Tuple__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -23255,7 +23255,7 @@ func (ma *_StructRepresentation_Tuple__Assembler) AssembleEntry(k string) (ipld. switch k { case "fieldOrder": if ma.s&fieldBit__StructRepresentation_Tuple_FieldOrder != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder} } ma.s += fieldBit__StructRepresentation_Tuple_FieldOrder ma.state = maState_midValue @@ -23264,9 +23264,9 @@ func (ma *_StructRepresentation_Tuple__Assembler) AssembleEntry(k string) (ipld. ma.ca_fieldOrder.m = &ma.w.fieldOrder.m return &ma.ca_fieldOrder, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple", Key: &_String{k}} } -func (ma *_StructRepresentation_Tuple__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Tuple__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -23284,7 +23284,7 @@ func (ma *_StructRepresentation_Tuple__Assembler) AssembleKey() ipld.NodeAssembl ma.state = maState_midKey return (*_StructRepresentation_Tuple__KeyAssembler)(ma) } -func (ma *_StructRepresentation_Tuple__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Tuple__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -23323,26 +23323,26 @@ func (ma *_StructRepresentation_Tuple__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Tuple_sufficient != fieldBits__StructRepresentation_Tuple_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Tuple__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Tuple__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Tuple__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Tuple__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _StructRepresentation_Tuple__KeyAssembler _StructRepresentation_Tuple__Assembler -func (_StructRepresentation_Tuple__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Tuple__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Tuple__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Tuple__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Tuple__KeyAssembler) AssignNull() error { @@ -23364,36 +23364,36 @@ func (ka *_StructRepresentation_Tuple__KeyAssembler) AssignString(k string) erro switch k { case "fieldOrder": if ka.s&fieldBit__StructRepresentation_Tuple_FieldOrder != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder} } ka.s += fieldBit__StructRepresentation_Tuple_FieldOrder ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple", Key: &_String{k}} } } func (_StructRepresentation_Tuple__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Tuple__KeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Tuple__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Tuple__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Tuple__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Tuple__KeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Tuple__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (StructRepresentation_Tuple) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n StructRepresentation_Tuple) Representation() ipld.Node { +func (n StructRepresentation_Tuple) Representation() datamodel.Node { return (*_StructRepresentation_Tuple__Repr)(n) } @@ -23402,36 +23402,36 @@ type _StructRepresentation_Tuple__Repr _StructRepresentation_Tuple var ( fieldName__StructRepresentation_Tuple_FieldOrder_serial = _String{"fieldOrder"} ) -var _ ipld.Node = &_StructRepresentation_Tuple__Repr{} +var _ datamodel.Node = &_StructRepresentation_Tuple__Repr{} -func (_StructRepresentation_Tuple__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_StructRepresentation_Tuple__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_StructRepresentation_Tuple__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_StructRepresentation_Tuple__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "fieldOrder": if n.fieldOrder.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.fieldOrder.v.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_StructRepresentation_Tuple__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_StructRepresentation_Tuple__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_StructRepresentation_Tuple__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_StructRepresentation_Tuple__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Tuple.Repr"}.LookupByIndex(0) } -func (n _StructRepresentation_Tuple__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _StructRepresentation_Tuple__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_StructRepresentation_Tuple__Repr) MapIterator() ipld.MapIterator { +func (n *_StructRepresentation_Tuple__Repr) MapIterator() datamodel.MapIterator { end := 1 if n.fieldOrder.m == schema.Maybe_Absent { end = 0 @@ -23448,10 +23448,10 @@ type _StructRepresentation_Tuple__ReprMapItr struct { end int } -func (itr *_StructRepresentation_Tuple__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_StructRepresentation_Tuple__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { advance: if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -23470,7 +23470,7 @@ advance: func (itr *_StructRepresentation_Tuple__ReprMapItr) Done() bool { return itr.idx >= itr.end } -func (_StructRepresentation_Tuple__Repr) ListIterator() ipld.ListIterator { +func (_StructRepresentation_Tuple__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_StructRepresentation_Tuple__Repr) Length() int64 { @@ -23501,16 +23501,16 @@ func (_StructRepresentation_Tuple__Repr) AsString() (string, error) { func (_StructRepresentation_Tuple__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Tuple.Repr"}.AsBytes() } -func (_StructRepresentation_Tuple__Repr) AsLink() (ipld.Link, error) { +func (_StructRepresentation_Tuple__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.StructRepresentation_Tuple.Repr"}.AsLink() } -func (_StructRepresentation_Tuple__Repr) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Tuple__Repr) Prototype() datamodel.NodePrototype { return _StructRepresentation_Tuple__ReprPrototype{} } type _StructRepresentation_Tuple__ReprPrototype struct{} -func (_StructRepresentation_Tuple__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_StructRepresentation_Tuple__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _StructRepresentation_Tuple__ReprBuilder nb.Reset() return &nb @@ -23520,7 +23520,7 @@ type _StructRepresentation_Tuple__ReprBuilder struct { _StructRepresentation_Tuple__ReprAssembler } -func (nb *_StructRepresentation_Tuple__ReprBuilder) Build() ipld.Node { +func (nb *_StructRepresentation_Tuple__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -23548,7 +23548,7 @@ func (na *_StructRepresentation_Tuple__ReprAssembler) reset() { na.s = 0 na.ca_fieldOrder.reset() } -func (na *_StructRepresentation_Tuple__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_StructRepresentation_Tuple__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -23561,7 +23561,7 @@ func (na *_StructRepresentation_Tuple__ReprAssembler) BeginMap(int64) (ipld.MapA } return na, nil } -func (_StructRepresentation_Tuple__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Tuple__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr"}.BeginList(0) } func (na *_StructRepresentation_Tuple__ReprAssembler) AssignNull() error { @@ -23593,10 +23593,10 @@ func (_StructRepresentation_Tuple__ReprAssembler) AssignString(string) error { func (_StructRepresentation_Tuple__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr"}.AssignBytes(nil) } -func (_StructRepresentation_Tuple__ReprAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Tuple__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr"}.AssignLink(nil) } -func (na *_StructRepresentation_Tuple__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_StructRepresentation_Tuple__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -23616,8 +23616,8 @@ func (na *_StructRepresentation_Tuple__ReprAssembler) AssignNode(v ipld.Node) er *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Tuple.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.StructRepresentation_Tuple.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -23634,7 +23634,7 @@ func (na *_StructRepresentation_Tuple__ReprAssembler) AssignNode(v ipld.Node) er } return na.Finish() } -func (_StructRepresentation_Tuple__ReprAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Tuple__ReprAssembler) Prototype() datamodel.NodePrototype { return _StructRepresentation_Tuple__ReprPrototype{} } func (ma *_StructRepresentation_Tuple__ReprAssembler) valueFinishTidy() bool { @@ -23651,7 +23651,7 @@ func (ma *_StructRepresentation_Tuple__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -23669,7 +23669,7 @@ func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleEntry(k string) (i switch k { case "fieldOrder": if ma.s&fieldBit__StructRepresentation_Tuple_FieldOrder != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder_serial} } ma.s += fieldBit__StructRepresentation_Tuple_FieldOrder ma.state = maState_midValue @@ -23680,9 +23680,9 @@ func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleEntry(k string) (i return &ma.ca_fieldOrder, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple.Repr", Key: &_String{k}} } -func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -23700,7 +23700,7 @@ func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleKey() ipld.NodeAss ma.state = maState_midKey return (*_StructRepresentation_Tuple__ReprKeyAssembler)(ma) } -func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_StructRepresentation_Tuple__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -23740,26 +23740,26 @@ func (ma *_StructRepresentation_Tuple__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__StructRepresentation_Tuple_sufficient != fieldBits__StructRepresentation_Tuple_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_StructRepresentation_Tuple__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_StructRepresentation_Tuple__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_StructRepresentation_Tuple__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_StructRepresentation_Tuple__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _StructRepresentation_Tuple__ReprKeyAssembler _StructRepresentation_Tuple__ReprAssembler -func (_StructRepresentation_Tuple__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_StructRepresentation_Tuple__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr.KeyAssembler"}.BeginMap(0) } -func (_StructRepresentation_Tuple__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_StructRepresentation_Tuple__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr.KeyAssembler"}.BeginList(0) } func (na *_StructRepresentation_Tuple__ReprKeyAssembler) AssignNull() error { @@ -23781,29 +23781,29 @@ func (ka *_StructRepresentation_Tuple__ReprKeyAssembler) AssignString(k string) switch k { case "fieldOrder": if ka.s&fieldBit__StructRepresentation_Tuple_FieldOrder != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__StructRepresentation_Tuple_FieldOrder_serial} } ka.s += fieldBit__StructRepresentation_Tuple_FieldOrder ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.StructRepresentation_Tuple.Repr", Key: &_String{k}} } func (_StructRepresentation_Tuple__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_StructRepresentation_Tuple__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_StructRepresentation_Tuple__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.StructRepresentation_Tuple.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_StructRepresentation_Tuple__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_StructRepresentation_Tuple__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_StructRepresentation_Tuple__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_StructRepresentation_Tuple__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -23822,12 +23822,12 @@ func (m MaybeTypeBool) IsAbsent() bool { func (m MaybeTypeBool) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeBool) AsNode() ipld.Node { +func (m MaybeTypeBool) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -23842,32 +23842,32 @@ func (m MaybeTypeBool) Must() TypeBool { } var () -var _ ipld.Node = (TypeBool)(&_TypeBool{}) +var _ datamodel.Node = (TypeBool)(&_TypeBool{}) var _ schema.TypedNode = (TypeBool)(&_TypeBool{}) -func (TypeBool) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeBool) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeBool) LookupByString(key string) (ipld.Node, error) { +func (n TypeBool) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeBool) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeBool) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeBool) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeBool) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeBool"}.LookupByIndex(0) } -func (n TypeBool) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeBool) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeBool) MapIterator() ipld.MapIterator { +func (n TypeBool) MapIterator() datamodel.MapIterator { return &_TypeBool__MapItr{n, 0} } @@ -23876,15 +23876,15 @@ type _TypeBool__MapItr struct { idx int } -func (itr *_TypeBool__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeBool__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeBool__MapItr) Done() bool { return itr.idx >= 0 } -func (TypeBool) ListIterator() ipld.ListIterator { +func (TypeBool) ListIterator() datamodel.ListIterator { return nil } func (TypeBool) Length() int64 { @@ -23911,16 +23911,16 @@ func (TypeBool) AsString() (string, error) { func (TypeBool) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeBool"}.AsBytes() } -func (TypeBool) AsLink() (ipld.Link, error) { +func (TypeBool) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeBool"}.AsLink() } -func (TypeBool) Prototype() ipld.NodePrototype { +func (TypeBool) Prototype() datamodel.NodePrototype { return _TypeBool__Prototype{} } type _TypeBool__Prototype struct{} -func (_TypeBool__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeBool__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeBool__Builder nb.Reset() return &nb @@ -23930,7 +23930,7 @@ type _TypeBool__Builder struct { _TypeBool__Assembler } -func (nb *_TypeBool__Builder) Build() ipld.Node { +func (nb *_TypeBool__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -23961,7 +23961,7 @@ var ( fieldBits__TypeBool_sufficient = 0 ) -func (na *_TypeBool__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeBool__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -23974,7 +23974,7 @@ func (na *_TypeBool__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeBool__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBool__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeBool"}.BeginList(0) } func (na *_TypeBool__Assembler) AssignNull() error { @@ -24006,10 +24006,10 @@ func (_TypeBool__Assembler) AssignString(string) error { func (_TypeBool__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBool"}.AssignBytes(nil) } -func (_TypeBool__Assembler) AssignLink(ipld.Link) error { +func (_TypeBool__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBool"}.AssignLink(nil) } -func (na *_TypeBool__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeBool__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -24029,8 +24029,8 @@ func (na *_TypeBool__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeBool", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeBool", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -24047,7 +24047,7 @@ func (na *_TypeBool__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeBool__Assembler) Prototype() ipld.NodePrototype { +func (_TypeBool__Assembler) Prototype() datamodel.NodePrototype { return _TypeBool__Prototype{} } func (ma *_TypeBool__Assembler) valueFinishTidy() bool { @@ -24056,7 +24056,7 @@ func (ma *_TypeBool__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeBool__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeBool__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -24071,9 +24071,9 @@ func (ma *_TypeBool__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBool", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeBool", Key: &_String{k}} } -func (ma *_TypeBool__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeBool__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -24091,7 +24091,7 @@ func (ma *_TypeBool__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeBool__KeyAssembler)(ma) } -func (ma *_TypeBool__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeBool__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -24126,26 +24126,26 @@ func (ma *_TypeBool__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeBool_sufficient != fieldBits__TypeBool_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeBool__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeBool__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeBool__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeBool__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeBool__KeyAssembler _TypeBool__Assembler -func (_TypeBool__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeBool__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.KeyAssembler"}.BeginMap(0) } -func (_TypeBool__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBool__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.KeyAssembler"}.BeginList(0) } func (na *_TypeBool__KeyAssembler) AssignNull() error { @@ -24166,60 +24166,60 @@ func (ka *_TypeBool__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBool", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeBool", Key: &_String{k}} } } func (_TypeBool__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.KeyAssembler"}.AssignBytes(nil) } -func (_TypeBool__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeBool__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeBool__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeBool__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeBool__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeBool__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeBool) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeBool) Representation() ipld.Node { +func (n TypeBool) Representation() datamodel.Node { return (*_TypeBool__Repr)(n) } type _TypeBool__Repr _TypeBool var () -var _ ipld.Node = &_TypeBool__Repr{} +var _ datamodel.Node = &_TypeBool__Repr{} -func (_TypeBool__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeBool__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeBool__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeBool__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeBool__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeBool__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeBool__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeBool__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeBool.Repr"}.LookupByIndex(0) } -func (n _TypeBool__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeBool__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeBool__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeBool__Repr) MapIterator() datamodel.MapIterator { return &_TypeBool__ReprMapItr{n, 0} } @@ -24228,14 +24228,14 @@ type _TypeBool__ReprMapItr struct { idx int } -func (itr *_TypeBool__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeBool__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeBool__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_TypeBool__Repr) ListIterator() ipld.ListIterator { +func (_TypeBool__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeBool__Repr) Length() int64 { @@ -24263,16 +24263,16 @@ func (_TypeBool__Repr) AsString() (string, error) { func (_TypeBool__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeBool.Repr"}.AsBytes() } -func (_TypeBool__Repr) AsLink() (ipld.Link, error) { +func (_TypeBool__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeBool.Repr"}.AsLink() } -func (_TypeBool__Repr) Prototype() ipld.NodePrototype { +func (_TypeBool__Repr) Prototype() datamodel.NodePrototype { return _TypeBool__ReprPrototype{} } type _TypeBool__ReprPrototype struct{} -func (_TypeBool__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeBool__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeBool__ReprBuilder nb.Reset() return &nb @@ -24282,7 +24282,7 @@ type _TypeBool__ReprBuilder struct { _TypeBool__ReprAssembler } -func (nb *_TypeBool__ReprBuilder) Build() ipld.Node { +func (nb *_TypeBool__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -24308,7 +24308,7 @@ func (na *_TypeBool__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_TypeBool__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeBool__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -24321,7 +24321,7 @@ func (na *_TypeBool__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeBool__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBool__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeBool.Repr"}.BeginList(0) } func (na *_TypeBool__ReprAssembler) AssignNull() error { @@ -24353,10 +24353,10 @@ func (_TypeBool__ReprAssembler) AssignString(string) error { func (_TypeBool__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBool.Repr"}.AssignBytes(nil) } -func (_TypeBool__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeBool__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBool.Repr"}.AssignLink(nil) } -func (na *_TypeBool__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeBool__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -24376,8 +24376,8 @@ func (na *_TypeBool__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeBool.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeBool.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -24394,7 +24394,7 @@ func (na *_TypeBool__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeBool__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeBool__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeBool__ReprPrototype{} } func (ma *_TypeBool__ReprAssembler) valueFinishTidy() bool { @@ -24403,7 +24403,7 @@ func (ma *_TypeBool__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeBool__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeBool__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -24418,9 +24418,9 @@ func (ma *_TypeBool__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBool.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeBool.Repr", Key: &_String{k}} } -func (ma *_TypeBool__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeBool__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -24438,7 +24438,7 @@ func (ma *_TypeBool__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeBool__ReprKeyAssembler)(ma) } -func (ma *_TypeBool__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeBool__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -24473,26 +24473,26 @@ func (ma *_TypeBool__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeBool_sufficient != fieldBits__TypeBool_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeBool__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeBool__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeBool__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeBool__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeBool__ReprKeyAssembler _TypeBool__ReprAssembler -func (_TypeBool__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeBool__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeBool__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBool__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeBool__ReprKeyAssembler) AssignNull() error { @@ -24511,22 +24511,22 @@ func (ka *_TypeBool__ReprKeyAssembler) AssignString(k string) error { if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBool.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeBool.Repr", Key: &_String{k}} } func (_TypeBool__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeBool__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeBool__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBool.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeBool__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeBool__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeBool__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeBool__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -24545,12 +24545,12 @@ func (m MaybeTypeBytes) IsAbsent() bool { func (m MaybeTypeBytes) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeBytes) AsNode() ipld.Node { +func (m MaybeTypeBytes) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -24565,32 +24565,32 @@ func (m MaybeTypeBytes) Must() TypeBytes { } var () -var _ ipld.Node = (TypeBytes)(&_TypeBytes{}) +var _ datamodel.Node = (TypeBytes)(&_TypeBytes{}) var _ schema.TypedNode = (TypeBytes)(&_TypeBytes{}) -func (TypeBytes) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeBytes) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeBytes) LookupByString(key string) (ipld.Node, error) { +func (n TypeBytes) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeBytes) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeBytes) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeBytes) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeBytes) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeBytes"}.LookupByIndex(0) } -func (n TypeBytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeBytes) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeBytes) MapIterator() ipld.MapIterator { +func (n TypeBytes) MapIterator() datamodel.MapIterator { return &_TypeBytes__MapItr{n, 0} } @@ -24599,15 +24599,15 @@ type _TypeBytes__MapItr struct { idx int } -func (itr *_TypeBytes__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeBytes__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeBytes__MapItr) Done() bool { return itr.idx >= 0 } -func (TypeBytes) ListIterator() ipld.ListIterator { +func (TypeBytes) ListIterator() datamodel.ListIterator { return nil } func (TypeBytes) Length() int64 { @@ -24634,16 +24634,16 @@ func (TypeBytes) AsString() (string, error) { func (TypeBytes) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeBytes"}.AsBytes() } -func (TypeBytes) AsLink() (ipld.Link, error) { +func (TypeBytes) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeBytes"}.AsLink() } -func (TypeBytes) Prototype() ipld.NodePrototype { +func (TypeBytes) Prototype() datamodel.NodePrototype { return _TypeBytes__Prototype{} } type _TypeBytes__Prototype struct{} -func (_TypeBytes__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeBytes__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeBytes__Builder nb.Reset() return &nb @@ -24653,7 +24653,7 @@ type _TypeBytes__Builder struct { _TypeBytes__Assembler } -func (nb *_TypeBytes__Builder) Build() ipld.Node { +func (nb *_TypeBytes__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -24684,7 +24684,7 @@ var ( fieldBits__TypeBytes_sufficient = 0 ) -func (na *_TypeBytes__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeBytes__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -24697,7 +24697,7 @@ func (na *_TypeBytes__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeBytes__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBytes__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeBytes"}.BeginList(0) } func (na *_TypeBytes__Assembler) AssignNull() error { @@ -24729,10 +24729,10 @@ func (_TypeBytes__Assembler) AssignString(string) error { func (_TypeBytes__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBytes"}.AssignBytes(nil) } -func (_TypeBytes__Assembler) AssignLink(ipld.Link) error { +func (_TypeBytes__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBytes"}.AssignLink(nil) } -func (na *_TypeBytes__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeBytes__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -24752,8 +24752,8 @@ func (na *_TypeBytes__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeBytes", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeBytes", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -24770,7 +24770,7 @@ func (na *_TypeBytes__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeBytes__Assembler) Prototype() ipld.NodePrototype { +func (_TypeBytes__Assembler) Prototype() datamodel.NodePrototype { return _TypeBytes__Prototype{} } func (ma *_TypeBytes__Assembler) valueFinishTidy() bool { @@ -24779,7 +24779,7 @@ func (ma *_TypeBytes__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeBytes__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeBytes__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -24794,9 +24794,9 @@ func (ma *_TypeBytes__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBytes", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeBytes", Key: &_String{k}} } -func (ma *_TypeBytes__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeBytes__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -24814,7 +24814,7 @@ func (ma *_TypeBytes__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeBytes__KeyAssembler)(ma) } -func (ma *_TypeBytes__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeBytes__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -24849,26 +24849,26 @@ func (ma *_TypeBytes__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeBytes_sufficient != fieldBits__TypeBytes_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeBytes__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeBytes__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeBytes__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeBytes__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeBytes__KeyAssembler _TypeBytes__Assembler -func (_TypeBytes__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeBytes__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.KeyAssembler"}.BeginMap(0) } -func (_TypeBytes__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBytes__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.KeyAssembler"}.BeginList(0) } func (na *_TypeBytes__KeyAssembler) AssignNull() error { @@ -24889,60 +24889,60 @@ func (ka *_TypeBytes__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBytes", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeBytes", Key: &_String{k}} } } func (_TypeBytes__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.KeyAssembler"}.AssignBytes(nil) } -func (_TypeBytes__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeBytes__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeBytes__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeBytes__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeBytes__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeBytes__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeBytes) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeBytes) Representation() ipld.Node { +func (n TypeBytes) Representation() datamodel.Node { return (*_TypeBytes__Repr)(n) } type _TypeBytes__Repr _TypeBytes var () -var _ ipld.Node = &_TypeBytes__Repr{} +var _ datamodel.Node = &_TypeBytes__Repr{} -func (_TypeBytes__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeBytes__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeBytes__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeBytes__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeBytes__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeBytes__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeBytes__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeBytes__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeBytes.Repr"}.LookupByIndex(0) } -func (n _TypeBytes__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeBytes__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeBytes__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeBytes__Repr) MapIterator() datamodel.MapIterator { return &_TypeBytes__ReprMapItr{n, 0} } @@ -24951,14 +24951,14 @@ type _TypeBytes__ReprMapItr struct { idx int } -func (itr *_TypeBytes__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeBytes__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeBytes__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_TypeBytes__Repr) ListIterator() ipld.ListIterator { +func (_TypeBytes__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeBytes__Repr) Length() int64 { @@ -24986,16 +24986,16 @@ func (_TypeBytes__Repr) AsString() (string, error) { func (_TypeBytes__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeBytes.Repr"}.AsBytes() } -func (_TypeBytes__Repr) AsLink() (ipld.Link, error) { +func (_TypeBytes__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeBytes.Repr"}.AsLink() } -func (_TypeBytes__Repr) Prototype() ipld.NodePrototype { +func (_TypeBytes__Repr) Prototype() datamodel.NodePrototype { return _TypeBytes__ReprPrototype{} } type _TypeBytes__ReprPrototype struct{} -func (_TypeBytes__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeBytes__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeBytes__ReprBuilder nb.Reset() return &nb @@ -25005,7 +25005,7 @@ type _TypeBytes__ReprBuilder struct { _TypeBytes__ReprAssembler } -func (nb *_TypeBytes__ReprBuilder) Build() ipld.Node { +func (nb *_TypeBytes__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -25031,7 +25031,7 @@ func (na *_TypeBytes__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_TypeBytes__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeBytes__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -25044,7 +25044,7 @@ func (na *_TypeBytes__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) } return na, nil } -func (_TypeBytes__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBytes__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeBytes.Repr"}.BeginList(0) } func (na *_TypeBytes__ReprAssembler) AssignNull() error { @@ -25076,10 +25076,10 @@ func (_TypeBytes__ReprAssembler) AssignString(string) error { func (_TypeBytes__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBytes.Repr"}.AssignBytes(nil) } -func (_TypeBytes__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeBytes__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeBytes.Repr"}.AssignLink(nil) } -func (na *_TypeBytes__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeBytes__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -25099,8 +25099,8 @@ func (na *_TypeBytes__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeBytes.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeBytes.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -25117,7 +25117,7 @@ func (na *_TypeBytes__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeBytes__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeBytes__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeBytes__ReprPrototype{} } func (ma *_TypeBytes__ReprAssembler) valueFinishTidy() bool { @@ -25126,7 +25126,7 @@ func (ma *_TypeBytes__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeBytes__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeBytes__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -25141,9 +25141,9 @@ func (ma *_TypeBytes__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBytes.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeBytes.Repr", Key: &_String{k}} } -func (ma *_TypeBytes__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeBytes__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -25161,7 +25161,7 @@ func (ma *_TypeBytes__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeBytes__ReprKeyAssembler)(ma) } -func (ma *_TypeBytes__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeBytes__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -25196,26 +25196,26 @@ func (ma *_TypeBytes__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeBytes_sufficient != fieldBits__TypeBytes_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeBytes__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeBytes__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeBytes__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeBytes__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeBytes__ReprKeyAssembler _TypeBytes__ReprAssembler -func (_TypeBytes__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeBytes__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeBytes__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeBytes__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeBytes__ReprKeyAssembler) AssignNull() error { @@ -25234,22 +25234,22 @@ func (ka *_TypeBytes__ReprKeyAssembler) AssignString(k string) error { if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeBytes.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeBytes.Repr", Key: &_String{k}} } func (_TypeBytes__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeBytes__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeBytes__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeBytes.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeBytes__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeBytes__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeBytes__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeBytes__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -25272,12 +25272,12 @@ func (m MaybeTypeCopy) IsAbsent() bool { func (m MaybeTypeCopy) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeCopy) AsNode() ipld.Node { +func (m MaybeTypeCopy) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -25294,34 +25294,34 @@ func (m MaybeTypeCopy) Must() TypeCopy { var ( fieldName__TypeCopy_FromType = _String{"fromType"} ) -var _ ipld.Node = (TypeCopy)(&_TypeCopy{}) +var _ datamodel.Node = (TypeCopy)(&_TypeCopy{}) var _ schema.TypedNode = (TypeCopy)(&_TypeCopy{}) -func (TypeCopy) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeCopy) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeCopy) LookupByString(key string) (ipld.Node, error) { +func (n TypeCopy) LookupByString(key string) (datamodel.Node, error) { switch key { case "fromType": return &n.fromType, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeCopy) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeCopy) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeCopy) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeCopy) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeCopy"}.LookupByIndex(0) } -func (n TypeCopy) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeCopy) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeCopy) MapIterator() ipld.MapIterator { +func (n TypeCopy) MapIterator() datamodel.MapIterator { return &_TypeCopy__MapItr{n, 0} } @@ -25330,9 +25330,9 @@ type _TypeCopy__MapItr struct { idx int } -func (itr *_TypeCopy__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeCopy__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -25348,7 +25348,7 @@ func (itr *_TypeCopy__MapItr) Done() bool { return itr.idx >= 1 } -func (TypeCopy) ListIterator() ipld.ListIterator { +func (TypeCopy) ListIterator() datamodel.ListIterator { return nil } func (TypeCopy) Length() int64 { @@ -25375,16 +25375,16 @@ func (TypeCopy) AsString() (string, error) { func (TypeCopy) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeCopy"}.AsBytes() } -func (TypeCopy) AsLink() (ipld.Link, error) { +func (TypeCopy) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeCopy"}.AsLink() } -func (TypeCopy) Prototype() ipld.NodePrototype { +func (TypeCopy) Prototype() datamodel.NodePrototype { return _TypeCopy__Prototype{} } type _TypeCopy__Prototype struct{} -func (_TypeCopy__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeCopy__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeCopy__Builder nb.Reset() return &nb @@ -25394,7 +25394,7 @@ type _TypeCopy__Builder struct { _TypeCopy__Assembler } -func (nb *_TypeCopy__Builder) Build() ipld.Node { +func (nb *_TypeCopy__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -25428,7 +25428,7 @@ var ( fieldBits__TypeCopy_sufficient = 0 + 1<<0 ) -func (na *_TypeCopy__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeCopy__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -25441,7 +25441,7 @@ func (na *_TypeCopy__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeCopy__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeCopy__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeCopy"}.BeginList(0) } func (na *_TypeCopy__Assembler) AssignNull() error { @@ -25473,10 +25473,10 @@ func (_TypeCopy__Assembler) AssignString(string) error { func (_TypeCopy__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeCopy"}.AssignBytes(nil) } -func (_TypeCopy__Assembler) AssignLink(ipld.Link) error { +func (_TypeCopy__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeCopy"}.AssignLink(nil) } -func (na *_TypeCopy__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeCopy__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -25496,8 +25496,8 @@ func (na *_TypeCopy__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeCopy", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeCopy", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -25514,7 +25514,7 @@ func (na *_TypeCopy__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeCopy__Assembler) Prototype() ipld.NodePrototype { +func (_TypeCopy__Assembler) Prototype() datamodel.NodePrototype { return _TypeCopy__Prototype{} } func (ma *_TypeCopy__Assembler) valueFinishTidy() bool { @@ -25533,7 +25533,7 @@ func (ma *_TypeCopy__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeCopy__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeCopy__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -25551,7 +25551,7 @@ func (ma *_TypeCopy__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err switch k { case "fromType": if ma.s&fieldBit__TypeCopy_FromType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType} } ma.s += fieldBit__TypeCopy_FromType ma.state = maState_midValue @@ -25560,9 +25560,9 @@ func (ma *_TypeCopy__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err ma.ca_fromType.m = &ma.cm return &ma.ca_fromType, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeCopy", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeCopy", Key: &_String{k}} } -func (ma *_TypeCopy__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeCopy__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -25580,7 +25580,7 @@ func (ma *_TypeCopy__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeCopy__KeyAssembler)(ma) } -func (ma *_TypeCopy__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeCopy__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -25619,7 +25619,7 @@ func (ma *_TypeCopy__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeCopy_sufficient != fieldBits__TypeCopy_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeCopy_FromType == 0 { err.Missing = append(err.Missing, "fromType") } @@ -25629,19 +25629,19 @@ func (ma *_TypeCopy__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeCopy__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeCopy__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeCopy__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeCopy__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeCopy__KeyAssembler _TypeCopy__Assembler -func (_TypeCopy__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeCopy__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.KeyAssembler"}.BeginMap(0) } -func (_TypeCopy__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeCopy__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.KeyAssembler"}.BeginList(0) } func (na *_TypeCopy__KeyAssembler) AssignNull() error { @@ -25663,36 +25663,36 @@ func (ka *_TypeCopy__KeyAssembler) AssignString(k string) error { switch k { case "fromType": if ka.s&fieldBit__TypeCopy_FromType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType} } ka.s += fieldBit__TypeCopy_FromType ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeCopy", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeCopy", Key: &_String{k}} } } func (_TypeCopy__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.KeyAssembler"}.AssignBytes(nil) } -func (_TypeCopy__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeCopy__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeCopy__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeCopy__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeCopy__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeCopy__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeCopy) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeCopy) Representation() ipld.Node { +func (n TypeCopy) Representation() datamodel.Node { return (*_TypeCopy__Repr)(n) } @@ -25701,33 +25701,33 @@ type _TypeCopy__Repr _TypeCopy var ( fieldName__TypeCopy_FromType_serial = _String{"fromType"} ) -var _ ipld.Node = &_TypeCopy__Repr{} +var _ datamodel.Node = &_TypeCopy__Repr{} -func (_TypeCopy__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeCopy__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeCopy__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeCopy__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "fromType": return n.fromType.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeCopy__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeCopy__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeCopy__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeCopy__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeCopy.Repr"}.LookupByIndex(0) } -func (n _TypeCopy__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeCopy__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeCopy__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeCopy__Repr) MapIterator() datamodel.MapIterator { return &_TypeCopy__ReprMapItr{n, 0} } @@ -25736,9 +25736,9 @@ type _TypeCopy__ReprMapItr struct { idx int } -func (itr *_TypeCopy__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeCopy__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -25753,7 +25753,7 @@ func (itr *_TypeCopy__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_TypeCopy__ReprMapItr) Done() bool { return itr.idx >= 1 } -func (_TypeCopy__Repr) ListIterator() ipld.ListIterator { +func (_TypeCopy__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeCopy__Repr) Length() int64 { @@ -25781,16 +25781,16 @@ func (_TypeCopy__Repr) AsString() (string, error) { func (_TypeCopy__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeCopy.Repr"}.AsBytes() } -func (_TypeCopy__Repr) AsLink() (ipld.Link, error) { +func (_TypeCopy__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeCopy.Repr"}.AsLink() } -func (_TypeCopy__Repr) Prototype() ipld.NodePrototype { +func (_TypeCopy__Repr) Prototype() datamodel.NodePrototype { return _TypeCopy__ReprPrototype{} } type _TypeCopy__ReprPrototype struct{} -func (_TypeCopy__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeCopy__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeCopy__ReprBuilder nb.Reset() return &nb @@ -25800,7 +25800,7 @@ type _TypeCopy__ReprBuilder struct { _TypeCopy__ReprAssembler } -func (nb *_TypeCopy__ReprBuilder) Build() ipld.Node { +func (nb *_TypeCopy__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -25828,7 +25828,7 @@ func (na *_TypeCopy__ReprAssembler) reset() { na.s = 0 na.ca_fromType.reset() } -func (na *_TypeCopy__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeCopy__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -25841,7 +25841,7 @@ func (na *_TypeCopy__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeCopy__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeCopy__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeCopy.Repr"}.BeginList(0) } func (na *_TypeCopy__ReprAssembler) AssignNull() error { @@ -25873,10 +25873,10 @@ func (_TypeCopy__ReprAssembler) AssignString(string) error { func (_TypeCopy__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeCopy.Repr"}.AssignBytes(nil) } -func (_TypeCopy__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeCopy__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeCopy.Repr"}.AssignLink(nil) } -func (na *_TypeCopy__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeCopy__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -25896,8 +25896,8 @@ func (na *_TypeCopy__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeCopy.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeCopy.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -25914,7 +25914,7 @@ func (na *_TypeCopy__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeCopy__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeCopy__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeCopy__ReprPrototype{} } func (ma *_TypeCopy__ReprAssembler) valueFinishTidy() bool { @@ -25932,7 +25932,7 @@ func (ma *_TypeCopy__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeCopy__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeCopy__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -25950,7 +25950,7 @@ func (ma *_TypeCopy__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, switch k { case "fromType": if ma.s&fieldBit__TypeCopy_FromType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType_serial} } ma.s += fieldBit__TypeCopy_FromType ma.state = maState_midValue @@ -25960,9 +25960,9 @@ func (ma *_TypeCopy__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_fromType, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeCopy.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeCopy.Repr", Key: &_String{k}} } -func (ma *_TypeCopy__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeCopy__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -25980,7 +25980,7 @@ func (ma *_TypeCopy__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeCopy__ReprKeyAssembler)(ma) } -func (ma *_TypeCopy__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeCopy__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -26019,7 +26019,7 @@ func (ma *_TypeCopy__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeCopy_sufficient != fieldBits__TypeCopy_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeCopy_FromType == 0 { err.Missing = append(err.Missing, "fromType") } @@ -26029,19 +26029,19 @@ func (ma *_TypeCopy__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeCopy__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeCopy__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeCopy__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeCopy__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeCopy__ReprKeyAssembler _TypeCopy__ReprAssembler -func (_TypeCopy__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeCopy__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeCopy__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeCopy__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeCopy__ReprKeyAssembler) AssignNull() error { @@ -26063,29 +26063,29 @@ func (ka *_TypeCopy__ReprKeyAssembler) AssignString(k string) error { switch k { case "fromType": if ka.s&fieldBit__TypeCopy_FromType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeCopy_FromType_serial} } ka.s += fieldBit__TypeCopy_FromType ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeCopy.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeCopy.Repr", Key: &_String{k}} } func (_TypeCopy__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeCopy__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeCopy__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeCopy.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeCopy__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeCopy__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeCopy__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeCopy__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -26135,12 +26135,12 @@ func (m MaybeTypeDefn) IsAbsent() bool { func (m MaybeTypeDefn) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeDefn) AsNode() ipld.Node { +func (m MaybeTypeDefn) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -26168,92 +26168,92 @@ var ( memberName__TypeDefn_TypeEnum = _String{"TypeEnum"} memberName__TypeDefn_TypeCopy = _String{"TypeCopy"} ) -var _ ipld.Node = (TypeDefn)(&_TypeDefn{}) +var _ datamodel.Node = (TypeDefn)(&_TypeDefn{}) var _ schema.TypedNode = (TypeDefn)(&_TypeDefn{}) -func (TypeDefn) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeDefn) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeDefn) LookupByString(key string) (ipld.Node, error) { +func (n TypeDefn) LookupByString(key string) (datamodel.Node, error) { switch key { case "TypeBool": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "TypeString": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil case "TypeBytes": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x3, nil case "TypeInt": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x4, nil case "TypeFloat": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x5, nil case "TypeMap": if n.tag != 6 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x6, nil case "TypeList": if n.tag != 7 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x7, nil case "TypeLink": if n.tag != 8 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x8, nil case "TypeUnion": if n.tag != 9 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x9, nil case "TypeStruct": if n.tag != 10 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x10, nil case "TypeEnum": if n.tag != 11 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x11, nil case "TypeCopy": if n.tag != 12 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x12, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeDefn) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeDefn) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeDefn) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeDefn) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeDefn"}.LookupByIndex(0) } -func (n TypeDefn) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeDefn) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeDefn) MapIterator() ipld.MapIterator { +func (n TypeDefn) MapIterator() datamodel.MapIterator { return &_TypeDefn__MapItr{n, false} } @@ -26262,9 +26262,9 @@ type _TypeDefn__MapItr struct { done bool } -func (itr *_TypeDefn__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeDefn__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -26301,7 +26301,7 @@ func (itr *_TypeDefn__MapItr) Done() bool { return itr.done } -func (TypeDefn) ListIterator() ipld.ListIterator { +func (TypeDefn) ListIterator() datamodel.ListIterator { return nil } func (TypeDefn) Length() int64 { @@ -26328,16 +26328,16 @@ func (TypeDefn) AsString() (string, error) { func (TypeDefn) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeDefn"}.AsBytes() } -func (TypeDefn) AsLink() (ipld.Link, error) { +func (TypeDefn) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeDefn"}.AsLink() } -func (TypeDefn) Prototype() ipld.NodePrototype { +func (TypeDefn) Prototype() datamodel.NodePrototype { return _TypeDefn__Prototype{} } type _TypeDefn__Prototype struct{} -func (_TypeDefn__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeDefn__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeDefn__Builder nb.Reset() return &nb @@ -26347,7 +26347,7 @@ type _TypeDefn__Builder struct { _TypeDefn__Assembler } -func (nb *_TypeDefn__Builder) Build() ipld.Node { +func (nb *_TypeDefn__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -26437,7 +26437,7 @@ func (na *_TypeDefn__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_TypeDefn__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeDefn__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -26450,7 +26450,7 @@ func (na *_TypeDefn__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeDefn__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefn__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefn"}.BeginList(0) } func (na *_TypeDefn__Assembler) AssignNull() error { @@ -26482,10 +26482,10 @@ func (_TypeDefn__Assembler) AssignString(string) error { func (_TypeDefn__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefn"}.AssignBytes(nil) } -func (_TypeDefn__Assembler) AssignLink(ipld.Link) error { +func (_TypeDefn__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefn"}.AssignLink(nil) } -func (na *_TypeDefn__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeDefn__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -26505,8 +26505,8 @@ func (na *_TypeDefn__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeDefn", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeDefn", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -26523,7 +26523,7 @@ func (na *_TypeDefn__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeDefn__Assembler) Prototype() ipld.NodePrototype { +func (_TypeDefn__Assembler) Prototype() datamodel.NodePrototype { return _TypeDefn__Prototype{} } func (ma *_TypeDefn__Assembler) valueFinishTidy() bool { @@ -26535,7 +26535,7 @@ func (ma *_TypeDefn__Assembler) valueFinishTidy() bool { return false } } -func (ma *_TypeDefn__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeDefn__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -26639,9 +26639,9 @@ func (ma *_TypeDefn__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err ma.ca12.m = &ma.cm return &ma.ca12, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefn", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefn", Key: &_String{k}} } -func (ma *_TypeDefn__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeDefn__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -26659,7 +26659,7 @@ func (ma *_TypeDefn__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeDefn__KeyAssembler)(ma) } -func (ma *_TypeDefn__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeDefn__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -26748,10 +26748,10 @@ func (ma *_TypeDefn__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeDefn__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeDefn__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeDefn__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeDefn__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "TypeBool": return _TypeBool__Prototype{} @@ -26784,10 +26784,10 @@ func (ma *_TypeDefn__Assembler) ValuePrototype(k string) ipld.NodePrototype { type _TypeDefn__KeyAssembler _TypeDefn__Assembler -func (_TypeDefn__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeDefn__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.KeyAssembler"}.BeginMap(0) } -func (_TypeDefn__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefn__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.KeyAssembler"}.BeginList(0) } func (na *_TypeDefn__KeyAssembler) AssignNull() error { @@ -26871,28 +26871,28 @@ func (ka *_TypeDefn__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefn", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefn", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_TypeDefn__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.KeyAssembler"}.AssignBytes(nil) } -func (_TypeDefn__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeDefn__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeDefn__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeDefn__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeDefn__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeDefn__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeDefn) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeDefn) Representation() ipld.Node { +func (n TypeDefn) Representation() datamodel.Node { return (*_TypeDefn__Repr)(n) } @@ -26912,91 +26912,91 @@ var ( memberName__TypeDefn_TypeEnum_serial = _String{"enum"} memberName__TypeDefn_TypeCopy_serial = _String{"copy"} ) -var _ ipld.Node = &_TypeDefn__Repr{} +var _ datamodel.Node = &_TypeDefn__Repr{} -func (_TypeDefn__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeDefn__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeDefn__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeDefn__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "bool": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x1.Representation(), nil case "string": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x2.Representation(), nil case "bytes": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x3.Representation(), nil case "int": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x4.Representation(), nil case "float": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x5.Representation(), nil case "map": if n.tag != 6 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x6.Representation(), nil case "list": if n.tag != 7 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x7.Representation(), nil case "link": if n.tag != 8 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x8.Representation(), nil case "union": if n.tag != 9 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x9.Representation(), nil case "struct": if n.tag != 10 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x10.Representation(), nil case "enum": if n.tag != 11 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x11.Representation(), nil case "copy": if n.tag != 12 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x12.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeDefn__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeDefn__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeDefn__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeDefn__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeDefn.Repr"}.LookupByIndex(0) } -func (n _TypeDefn__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeDefn__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeDefn__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeDefn__Repr) MapIterator() datamodel.MapIterator { return &_TypeDefn__ReprMapItr{n, false} } @@ -27005,9 +27005,9 @@ type _TypeDefn__ReprMapItr struct { done bool } -func (itr *_TypeDefn__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeDefn__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -27044,7 +27044,7 @@ func (itr *_TypeDefn__ReprMapItr) Done() bool { return itr.done } -func (_TypeDefn__Repr) ListIterator() ipld.ListIterator { +func (_TypeDefn__Repr) ListIterator() datamodel.ListIterator { return nil } func (_TypeDefn__Repr) Length() int64 { @@ -27071,16 +27071,16 @@ func (_TypeDefn__Repr) AsString() (string, error) { func (_TypeDefn__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeDefn.Repr"}.AsBytes() } -func (_TypeDefn__Repr) AsLink() (ipld.Link, error) { +func (_TypeDefn__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeDefn.Repr"}.AsLink() } -func (_TypeDefn__Repr) Prototype() ipld.NodePrototype { +func (_TypeDefn__Repr) Prototype() datamodel.NodePrototype { return _TypeDefn__ReprPrototype{} } type _TypeDefn__ReprPrototype struct{} -func (_TypeDefn__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeDefn__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeDefn__ReprBuilder nb.Reset() return &nb @@ -27090,7 +27090,7 @@ type _TypeDefn__ReprBuilder struct { _TypeDefn__ReprAssembler } -func (nb *_TypeDefn__ReprBuilder) Build() ipld.Node { +func (nb *_TypeDefn__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -27180,7 +27180,7 @@ func (na *_TypeDefn__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_TypeDefn__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeDefn__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -27193,7 +27193,7 @@ func (na *_TypeDefn__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeDefn__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefn__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefn.Repr"}.BeginList(0) } func (na *_TypeDefn__ReprAssembler) AssignNull() error { @@ -27225,10 +27225,10 @@ func (_TypeDefn__ReprAssembler) AssignString(string) error { func (_TypeDefn__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefn.Repr"}.AssignBytes(nil) } -func (_TypeDefn__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeDefn__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefn.Repr"}.AssignLink(nil) } -func (na *_TypeDefn__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeDefn__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -27248,8 +27248,8 @@ func (na *_TypeDefn__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeDefn.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeDefn.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -27266,7 +27266,7 @@ func (na *_TypeDefn__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeDefn__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeDefn__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeDefn__ReprPrototype{} } func (ma *_TypeDefn__ReprAssembler) valueFinishTidy() bool { @@ -27278,7 +27278,7 @@ func (ma *_TypeDefn__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_TypeDefn__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeDefn__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -27382,9 +27382,9 @@ func (ma *_TypeDefn__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, ma.ca12.m = &ma.cm return &ma.ca12, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefn.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefn.Repr", Key: &_String{k}} } -func (ma *_TypeDefn__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeDefn__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -27402,7 +27402,7 @@ func (ma *_TypeDefn__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeDefn__ReprKeyAssembler)(ma) } -func (ma *_TypeDefn__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeDefn__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -27491,10 +27491,10 @@ func (ma *_TypeDefn__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeDefn__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeDefn__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeDefn__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeDefn__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "TypeBool": return _TypeBool__ReprPrototype{} @@ -27527,10 +27527,10 @@ func (ma *_TypeDefn__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype type _TypeDefn__ReprKeyAssembler _TypeDefn__ReprAssembler -func (_TypeDefn__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeDefn__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeDefn__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefn__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeDefn__ReprKeyAssembler) AssignNull() error { @@ -27614,22 +27614,22 @@ func (ka *_TypeDefn__ReprKeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefn.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefn.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_TypeDefn__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeDefn__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeDefn__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefn.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeDefn__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeDefn__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeDefn__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeDefn__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -27652,12 +27652,12 @@ func (m MaybeTypeDefnInline) IsAbsent() bool { func (m MaybeTypeDefnInline) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeDefnInline) AsNode() ipld.Node { +func (m MaybeTypeDefnInline) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -27675,44 +27675,44 @@ var ( memberName__TypeDefnInline_TypeMap = _String{"TypeMap"} memberName__TypeDefnInline_TypeList = _String{"TypeList"} ) -var _ ipld.Node = (TypeDefnInline)(&_TypeDefnInline{}) +var _ datamodel.Node = (TypeDefnInline)(&_TypeDefnInline{}) var _ schema.TypedNode = (TypeDefnInline)(&_TypeDefnInline{}) -func (TypeDefnInline) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeDefnInline) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeDefnInline) LookupByString(key string) (ipld.Node, error) { +func (n TypeDefnInline) LookupByString(key string) (datamodel.Node, error) { switch key { case "TypeMap": if n2, ok := n.x.(TypeMap); ok { return n2, nil } else { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } case "TypeList": if n2, ok := n.x.(TypeList); ok { return n2, nil } else { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeDefnInline) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeDefnInline) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeDefnInline) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeDefnInline) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeDefnInline"}.LookupByIndex(0) } -func (n TypeDefnInline) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeDefnInline) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeDefnInline) MapIterator() ipld.MapIterator { +func (n TypeDefnInline) MapIterator() datamodel.MapIterator { return &_TypeDefnInline__MapItr{n, false} } @@ -27721,9 +27721,9 @@ type _TypeDefnInline__MapItr struct { done bool } -func (itr *_TypeDefnInline__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeDefnInline__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch n2 := itr.n.x.(type) { case TypeMap: @@ -27740,7 +27740,7 @@ func (itr *_TypeDefnInline__MapItr) Done() bool { return itr.done } -func (TypeDefnInline) ListIterator() ipld.ListIterator { +func (TypeDefnInline) ListIterator() datamodel.ListIterator { return nil } func (TypeDefnInline) Length() int64 { @@ -27767,16 +27767,16 @@ func (TypeDefnInline) AsString() (string, error) { func (TypeDefnInline) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeDefnInline"}.AsBytes() } -func (TypeDefnInline) AsLink() (ipld.Link, error) { +func (TypeDefnInline) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeDefnInline"}.AsLink() } -func (TypeDefnInline) Prototype() ipld.NodePrototype { +func (TypeDefnInline) Prototype() datamodel.NodePrototype { return _TypeDefnInline__Prototype{} } type _TypeDefnInline__Prototype struct{} -func (_TypeDefnInline__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeDefnInline__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeDefnInline__Builder nb.Reset() return &nb @@ -27786,7 +27786,7 @@ type _TypeDefnInline__Builder struct { _TypeDefnInline__Assembler } -func (nb *_TypeDefnInline__Builder) Build() ipld.Node { +func (nb *_TypeDefnInline__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -27826,7 +27826,7 @@ func (na *_TypeDefnInline__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_TypeDefnInline__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeDefnInline__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -27839,7 +27839,7 @@ func (na *_TypeDefnInline__Assembler) BeginMap(int64) (ipld.MapAssembler, error) } return na, nil } -func (_TypeDefnInline__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefnInline__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefnInline"}.BeginList(0) } func (na *_TypeDefnInline__Assembler) AssignNull() error { @@ -27871,10 +27871,10 @@ func (_TypeDefnInline__Assembler) AssignString(string) error { func (_TypeDefnInline__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefnInline"}.AssignBytes(nil) } -func (_TypeDefnInline__Assembler) AssignLink(ipld.Link) error { +func (_TypeDefnInline__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefnInline"}.AssignLink(nil) } -func (na *_TypeDefnInline__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeDefnInline__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -27894,8 +27894,8 @@ func (na *_TypeDefnInline__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeDefnInline", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeDefnInline", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -27912,7 +27912,7 @@ func (na *_TypeDefnInline__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeDefnInline__Assembler) Prototype() ipld.NodePrototype { +func (_TypeDefnInline__Assembler) Prototype() datamodel.NodePrototype { return _TypeDefnInline__Prototype{} } func (ma *_TypeDefnInline__Assembler) valueFinishTidy() bool { @@ -27924,7 +27924,7 @@ func (ma *_TypeDefnInline__Assembler) valueFinishTidy() bool { return false } } -func (ma *_TypeDefnInline__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeDefnInline__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -27966,9 +27966,9 @@ func (ma *_TypeDefnInline__Assembler) AssembleEntry(k string) (ipld.NodeAssemble ma.ca2.m = &ma.cm return ma.ca2, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline", Key: &_String{k}} } -func (ma *_TypeDefnInline__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeDefnInline__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -27986,7 +27986,7 @@ func (ma *_TypeDefnInline__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeDefnInline__KeyAssembler)(ma) } -func (ma *_TypeDefnInline__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeDefnInline__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -28045,10 +28045,10 @@ func (ma *_TypeDefnInline__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeDefnInline__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeDefnInline__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeDefnInline__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeDefnInline__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "TypeMap": return _TypeMap__Prototype{} @@ -28061,10 +28061,10 @@ func (ma *_TypeDefnInline__Assembler) ValuePrototype(k string) ipld.NodePrototyp type _TypeDefnInline__KeyAssembler _TypeDefnInline__Assembler -func (_TypeDefnInline__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeDefnInline__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.KeyAssembler"}.BeginMap(0) } -func (_TypeDefnInline__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefnInline__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.KeyAssembler"}.BeginList(0) } func (na *_TypeDefnInline__KeyAssembler) AssignNull() error { @@ -28096,28 +28096,28 @@ func (ka *_TypeDefnInline__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_TypeDefnInline__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.KeyAssembler"}.AssignBytes(nil) } -func (_TypeDefnInline__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeDefnInline__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeDefnInline__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeDefnInline__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeDefnInline__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeDefnInline__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeDefnInline) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeDefnInline) Representation() ipld.Node { +func (n TypeDefnInline) Representation() datamodel.Node { return (*_TypeDefnInline__Repr)(n) } @@ -28127,43 +28127,43 @@ var ( memberName__TypeDefnInline_TypeMap_serial = _String{"map"} memberName__TypeDefnInline_TypeList_serial = _String{"list"} ) -var _ ipld.Node = &_TypeDefnInline__Repr{} +var _ datamodel.Node = &_TypeDefnInline__Repr{} -func (_TypeDefnInline__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeDefnInline__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeDefnInline__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeDefnInline__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "map": if n2, ok := n.x.(TypeMap); ok { return n2.Representation(), nil } else { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } case "list": if n2, ok := n.x.(TypeList); ok { return n2.Representation(), nil } else { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeDefnInline__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeDefnInline__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeDefnInline__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeDefnInline__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeDefnInline.Repr"}.LookupByIndex(0) } -func (n _TypeDefnInline__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeDefnInline__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeDefnInline__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeDefnInline__Repr) MapIterator() datamodel.MapIterator { return &_TypeDefnInline__ReprMapItr{n, false} } @@ -28172,9 +28172,9 @@ type _TypeDefnInline__ReprMapItr struct { done bool } -func (itr *_TypeDefnInline__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeDefnInline__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch n2 := itr.n.x.(type) { case TypeMap: @@ -28191,7 +28191,7 @@ func (itr *_TypeDefnInline__ReprMapItr) Done() bool { return itr.done } -func (_TypeDefnInline__Repr) ListIterator() ipld.ListIterator { +func (_TypeDefnInline__Repr) ListIterator() datamodel.ListIterator { return nil } func (_TypeDefnInline__Repr) Length() int64 { @@ -28218,16 +28218,16 @@ func (_TypeDefnInline__Repr) AsString() (string, error) { func (_TypeDefnInline__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeDefnInline.Repr"}.AsBytes() } -func (_TypeDefnInline__Repr) AsLink() (ipld.Link, error) { +func (_TypeDefnInline__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeDefnInline.Repr"}.AsLink() } -func (_TypeDefnInline__Repr) Prototype() ipld.NodePrototype { +func (_TypeDefnInline__Repr) Prototype() datamodel.NodePrototype { return _TypeDefnInline__ReprPrototype{} } type _TypeDefnInline__ReprPrototype struct{} -func (_TypeDefnInline__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeDefnInline__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeDefnInline__ReprBuilder nb.Reset() return &nb @@ -28237,7 +28237,7 @@ type _TypeDefnInline__ReprBuilder struct { _TypeDefnInline__ReprAssembler } -func (nb *_TypeDefnInline__ReprBuilder) Build() ipld.Node { +func (nb *_TypeDefnInline__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -28277,7 +28277,7 @@ func (na *_TypeDefnInline__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_TypeDefnInline__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeDefnInline__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -28290,7 +28290,7 @@ func (na *_TypeDefnInline__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, er } return na, nil } -func (_TypeDefnInline__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefnInline__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefnInline.Repr"}.BeginList(0) } func (na *_TypeDefnInline__ReprAssembler) AssignNull() error { @@ -28322,10 +28322,10 @@ func (_TypeDefnInline__ReprAssembler) AssignString(string) error { func (_TypeDefnInline__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefnInline.Repr"}.AssignBytes(nil) } -func (_TypeDefnInline__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeDefnInline__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeDefnInline.Repr"}.AssignLink(nil) } -func (na *_TypeDefnInline__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeDefnInline__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -28345,8 +28345,8 @@ func (na *_TypeDefnInline__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeDefnInline.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeDefnInline.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -28363,7 +28363,7 @@ func (na *_TypeDefnInline__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeDefnInline__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeDefnInline__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeDefnInline__ReprPrototype{} } func (ma *_TypeDefnInline__ReprAssembler) valueFinishTidy() bool { @@ -28375,7 +28375,7 @@ func (ma *_TypeDefnInline__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_TypeDefnInline__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeDefnInline__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -28417,9 +28417,9 @@ func (ma *_TypeDefnInline__ReprAssembler) AssembleEntry(k string) (ipld.NodeAsse ma.ca2.m = &ma.cm return ma.ca2, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline.Repr", Key: &_String{k}} } -func (ma *_TypeDefnInline__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeDefnInline__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -28437,7 +28437,7 @@ func (ma *_TypeDefnInline__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeDefnInline__ReprKeyAssembler)(ma) } -func (ma *_TypeDefnInline__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeDefnInline__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -28496,10 +28496,10 @@ func (ma *_TypeDefnInline__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeDefnInline__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeDefnInline__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeDefnInline__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeDefnInline__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "TypeMap": return _TypeMap__ReprPrototype{} @@ -28512,10 +28512,10 @@ func (ma *_TypeDefnInline__ReprAssembler) ValuePrototype(k string) ipld.NodeProt type _TypeDefnInline__ReprKeyAssembler _TypeDefnInline__ReprAssembler -func (_TypeDefnInline__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeDefnInline__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeDefnInline__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeDefnInline__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeDefnInline__ReprKeyAssembler) AssignNull() error { @@ -28547,22 +28547,22 @@ func (ka *_TypeDefnInline__ReprKeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeDefnInline.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_TypeDefnInline__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeDefnInline__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeDefnInline__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeDefnInline.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeDefnInline__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeDefnInline__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeDefnInline__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeDefnInline__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -28588,12 +28588,12 @@ func (m MaybeTypeEnum) IsAbsent() bool { func (m MaybeTypeEnum) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeEnum) AsNode() ipld.Node { +func (m MaybeTypeEnum) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -28611,36 +28611,36 @@ var ( fieldName__TypeEnum_Members = _String{"members"} fieldName__TypeEnum_Representation = _String{"representation"} ) -var _ ipld.Node = (TypeEnum)(&_TypeEnum{}) +var _ datamodel.Node = (TypeEnum)(&_TypeEnum{}) var _ schema.TypedNode = (TypeEnum)(&_TypeEnum{}) -func (TypeEnum) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeEnum) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeEnum) LookupByString(key string) (ipld.Node, error) { +func (n TypeEnum) LookupByString(key string) (datamodel.Node, error) { switch key { case "members": return &n.members, nil case "representation": return &n.representation, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeEnum) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeEnum) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeEnum) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeEnum) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeEnum"}.LookupByIndex(0) } -func (n TypeEnum) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeEnum) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeEnum) MapIterator() ipld.MapIterator { +func (n TypeEnum) MapIterator() datamodel.MapIterator { return &_TypeEnum__MapItr{n, 0} } @@ -28649,9 +28649,9 @@ type _TypeEnum__MapItr struct { idx int } -func (itr *_TypeEnum__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeEnum__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -28670,7 +28670,7 @@ func (itr *_TypeEnum__MapItr) Done() bool { return itr.idx >= 2 } -func (TypeEnum) ListIterator() ipld.ListIterator { +func (TypeEnum) ListIterator() datamodel.ListIterator { return nil } func (TypeEnum) Length() int64 { @@ -28697,16 +28697,16 @@ func (TypeEnum) AsString() (string, error) { func (TypeEnum) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeEnum"}.AsBytes() } -func (TypeEnum) AsLink() (ipld.Link, error) { +func (TypeEnum) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeEnum"}.AsLink() } -func (TypeEnum) Prototype() ipld.NodePrototype { +func (TypeEnum) Prototype() datamodel.NodePrototype { return _TypeEnum__Prototype{} } type _TypeEnum__Prototype struct{} -func (_TypeEnum__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeEnum__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeEnum__Builder nb.Reset() return &nb @@ -28716,7 +28716,7 @@ type _TypeEnum__Builder struct { _TypeEnum__Assembler } -func (nb *_TypeEnum__Builder) Build() ipld.Node { +func (nb *_TypeEnum__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -28753,7 +28753,7 @@ var ( fieldBits__TypeEnum_sufficient = 0 + 1<<0 + 1<<1 ) -func (na *_TypeEnum__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeEnum__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -28766,7 +28766,7 @@ func (na *_TypeEnum__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeEnum__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeEnum__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeEnum"}.BeginList(0) } func (na *_TypeEnum__Assembler) AssignNull() error { @@ -28798,10 +28798,10 @@ func (_TypeEnum__Assembler) AssignString(string) error { func (_TypeEnum__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeEnum"}.AssignBytes(nil) } -func (_TypeEnum__Assembler) AssignLink(ipld.Link) error { +func (_TypeEnum__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeEnum"}.AssignLink(nil) } -func (na *_TypeEnum__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeEnum__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -28821,8 +28821,8 @@ func (na *_TypeEnum__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeEnum", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeEnum", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -28839,7 +28839,7 @@ func (na *_TypeEnum__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeEnum__Assembler) Prototype() ipld.NodePrototype { +func (_TypeEnum__Assembler) Prototype() datamodel.NodePrototype { return _TypeEnum__Prototype{} } func (ma *_TypeEnum__Assembler) valueFinishTidy() bool { @@ -28868,7 +28868,7 @@ func (ma *_TypeEnum__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeEnum__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeEnum__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -28886,7 +28886,7 @@ func (ma *_TypeEnum__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err switch k { case "members": if ma.s&fieldBit__TypeEnum_Members != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members} } ma.s += fieldBit__TypeEnum_Members ma.state = maState_midValue @@ -28896,7 +28896,7 @@ func (ma *_TypeEnum__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err return &ma.ca_members, nil case "representation": if ma.s&fieldBit__TypeEnum_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation} } ma.s += fieldBit__TypeEnum_Representation ma.state = maState_midValue @@ -28905,9 +28905,9 @@ func (ma *_TypeEnum__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err ma.ca_representation.m = &ma.cm return &ma.ca_representation, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeEnum", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeEnum", Key: &_String{k}} } -func (ma *_TypeEnum__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeEnum__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -28925,7 +28925,7 @@ func (ma *_TypeEnum__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeEnum__KeyAssembler)(ma) } -func (ma *_TypeEnum__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeEnum__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -28968,7 +28968,7 @@ func (ma *_TypeEnum__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeEnum_sufficient != fieldBits__TypeEnum_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeEnum_Members == 0 { err.Missing = append(err.Missing, "members") } @@ -28981,19 +28981,19 @@ func (ma *_TypeEnum__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeEnum__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeEnum__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeEnum__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeEnum__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeEnum__KeyAssembler _TypeEnum__Assembler -func (_TypeEnum__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeEnum__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.KeyAssembler"}.BeginMap(0) } -func (_TypeEnum__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeEnum__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.KeyAssembler"}.BeginList(0) } func (na *_TypeEnum__KeyAssembler) AssignNull() error { @@ -29015,7 +29015,7 @@ func (ka *_TypeEnum__KeyAssembler) AssignString(k string) error { switch k { case "members": if ka.s&fieldBit__TypeEnum_Members != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members} } ka.s += fieldBit__TypeEnum_Members ka.state = maState_expectValue @@ -29023,36 +29023,36 @@ func (ka *_TypeEnum__KeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeEnum_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation} } ka.s += fieldBit__TypeEnum_Representation ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeEnum", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeEnum", Key: &_String{k}} } } func (_TypeEnum__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.KeyAssembler"}.AssignBytes(nil) } -func (_TypeEnum__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeEnum__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeEnum__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeEnum__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeEnum__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeEnum__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeEnum) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeEnum) Representation() ipld.Node { +func (n TypeEnum) Representation() datamodel.Node { return (*_TypeEnum__Repr)(n) } @@ -29062,35 +29062,35 @@ var ( fieldName__TypeEnum_Members_serial = _String{"members"} fieldName__TypeEnum_Representation_serial = _String{"representation"} ) -var _ ipld.Node = &_TypeEnum__Repr{} +var _ datamodel.Node = &_TypeEnum__Repr{} -func (_TypeEnum__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeEnum__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeEnum__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeEnum__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "members": return n.members.Representation(), nil case "representation": return n.representation.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeEnum__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeEnum__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeEnum__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeEnum__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeEnum.Repr"}.LookupByIndex(0) } -func (n _TypeEnum__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeEnum__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeEnum__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeEnum__Repr) MapIterator() datamodel.MapIterator { return &_TypeEnum__ReprMapItr{n, 0} } @@ -29099,9 +29099,9 @@ type _TypeEnum__ReprMapItr struct { idx int } -func (itr *_TypeEnum__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeEnum__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -29119,7 +29119,7 @@ func (itr *_TypeEnum__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_TypeEnum__ReprMapItr) Done() bool { return itr.idx >= 2 } -func (_TypeEnum__Repr) ListIterator() ipld.ListIterator { +func (_TypeEnum__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeEnum__Repr) Length() int64 { @@ -29147,16 +29147,16 @@ func (_TypeEnum__Repr) AsString() (string, error) { func (_TypeEnum__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeEnum.Repr"}.AsBytes() } -func (_TypeEnum__Repr) AsLink() (ipld.Link, error) { +func (_TypeEnum__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeEnum.Repr"}.AsLink() } -func (_TypeEnum__Repr) Prototype() ipld.NodePrototype { +func (_TypeEnum__Repr) Prototype() datamodel.NodePrototype { return _TypeEnum__ReprPrototype{} } type _TypeEnum__ReprPrototype struct{} -func (_TypeEnum__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeEnum__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeEnum__ReprBuilder nb.Reset() return &nb @@ -29166,7 +29166,7 @@ type _TypeEnum__ReprBuilder struct { _TypeEnum__ReprAssembler } -func (nb *_TypeEnum__ReprBuilder) Build() ipld.Node { +func (nb *_TypeEnum__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -29196,7 +29196,7 @@ func (na *_TypeEnum__ReprAssembler) reset() { na.ca_members.reset() na.ca_representation.reset() } -func (na *_TypeEnum__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeEnum__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -29209,7 +29209,7 @@ func (na *_TypeEnum__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeEnum__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeEnum__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeEnum.Repr"}.BeginList(0) } func (na *_TypeEnum__ReprAssembler) AssignNull() error { @@ -29241,10 +29241,10 @@ func (_TypeEnum__ReprAssembler) AssignString(string) error { func (_TypeEnum__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeEnum.Repr"}.AssignBytes(nil) } -func (_TypeEnum__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeEnum__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeEnum.Repr"}.AssignLink(nil) } -func (na *_TypeEnum__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeEnum__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -29264,8 +29264,8 @@ func (na *_TypeEnum__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeEnum.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeEnum.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -29282,7 +29282,7 @@ func (na *_TypeEnum__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeEnum__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeEnum__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeEnum__ReprPrototype{} } func (ma *_TypeEnum__ReprAssembler) valueFinishTidy() bool { @@ -29309,7 +29309,7 @@ func (ma *_TypeEnum__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeEnum__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeEnum__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -29327,7 +29327,7 @@ func (ma *_TypeEnum__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, switch k { case "members": if ma.s&fieldBit__TypeEnum_Members != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members_serial} } ma.s += fieldBit__TypeEnum_Members ma.state = maState_midValue @@ -29337,7 +29337,7 @@ func (ma *_TypeEnum__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_members, nil case "representation": if ma.s&fieldBit__TypeEnum_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation_serial} } ma.s += fieldBit__TypeEnum_Representation ma.state = maState_midValue @@ -29347,9 +29347,9 @@ func (ma *_TypeEnum__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_representation, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeEnum.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeEnum.Repr", Key: &_String{k}} } -func (ma *_TypeEnum__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeEnum__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -29367,7 +29367,7 @@ func (ma *_TypeEnum__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeEnum__ReprKeyAssembler)(ma) } -func (ma *_TypeEnum__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeEnum__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -29410,7 +29410,7 @@ func (ma *_TypeEnum__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeEnum_sufficient != fieldBits__TypeEnum_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeEnum_Members == 0 { err.Missing = append(err.Missing, "members") } @@ -29423,19 +29423,19 @@ func (ma *_TypeEnum__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeEnum__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeEnum__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeEnum__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeEnum__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeEnum__ReprKeyAssembler _TypeEnum__ReprAssembler -func (_TypeEnum__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeEnum__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeEnum__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeEnum__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeEnum__ReprKeyAssembler) AssignNull() error { @@ -29457,7 +29457,7 @@ func (ka *_TypeEnum__ReprKeyAssembler) AssignString(k string) error { switch k { case "members": if ka.s&fieldBit__TypeEnum_Members != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Members_serial} } ka.s += fieldBit__TypeEnum_Members ka.state = maState_expectValue @@ -29465,29 +29465,29 @@ func (ka *_TypeEnum__ReprKeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeEnum_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeEnum_Representation_serial} } ka.s += fieldBit__TypeEnum_Representation ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeEnum.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeEnum.Repr", Key: &_String{k}} } func (_TypeEnum__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeEnum__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeEnum__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeEnum.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeEnum__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeEnum__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeEnum__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeEnum__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -29506,12 +29506,12 @@ func (m MaybeTypeFloat) IsAbsent() bool { func (m MaybeTypeFloat) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeFloat) AsNode() ipld.Node { +func (m MaybeTypeFloat) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -29526,32 +29526,32 @@ func (m MaybeTypeFloat) Must() TypeFloat { } var () -var _ ipld.Node = (TypeFloat)(&_TypeFloat{}) +var _ datamodel.Node = (TypeFloat)(&_TypeFloat{}) var _ schema.TypedNode = (TypeFloat)(&_TypeFloat{}) -func (TypeFloat) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeFloat) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeFloat) LookupByString(key string) (ipld.Node, error) { +func (n TypeFloat) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeFloat) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeFloat) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeFloat) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeFloat) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeFloat"}.LookupByIndex(0) } -func (n TypeFloat) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeFloat) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeFloat) MapIterator() ipld.MapIterator { +func (n TypeFloat) MapIterator() datamodel.MapIterator { return &_TypeFloat__MapItr{n, 0} } @@ -29560,15 +29560,15 @@ type _TypeFloat__MapItr struct { idx int } -func (itr *_TypeFloat__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeFloat__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeFloat__MapItr) Done() bool { return itr.idx >= 0 } -func (TypeFloat) ListIterator() ipld.ListIterator { +func (TypeFloat) ListIterator() datamodel.ListIterator { return nil } func (TypeFloat) Length() int64 { @@ -29595,16 +29595,16 @@ func (TypeFloat) AsString() (string, error) { func (TypeFloat) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeFloat"}.AsBytes() } -func (TypeFloat) AsLink() (ipld.Link, error) { +func (TypeFloat) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeFloat"}.AsLink() } -func (TypeFloat) Prototype() ipld.NodePrototype { +func (TypeFloat) Prototype() datamodel.NodePrototype { return _TypeFloat__Prototype{} } type _TypeFloat__Prototype struct{} -func (_TypeFloat__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeFloat__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeFloat__Builder nb.Reset() return &nb @@ -29614,7 +29614,7 @@ type _TypeFloat__Builder struct { _TypeFloat__Assembler } -func (nb *_TypeFloat__Builder) Build() ipld.Node { +func (nb *_TypeFloat__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -29645,7 +29645,7 @@ var ( fieldBits__TypeFloat_sufficient = 0 ) -func (na *_TypeFloat__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeFloat__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -29658,7 +29658,7 @@ func (na *_TypeFloat__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeFloat__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeFloat__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeFloat"}.BeginList(0) } func (na *_TypeFloat__Assembler) AssignNull() error { @@ -29690,10 +29690,10 @@ func (_TypeFloat__Assembler) AssignString(string) error { func (_TypeFloat__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeFloat"}.AssignBytes(nil) } -func (_TypeFloat__Assembler) AssignLink(ipld.Link) error { +func (_TypeFloat__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeFloat"}.AssignLink(nil) } -func (na *_TypeFloat__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeFloat__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -29713,8 +29713,8 @@ func (na *_TypeFloat__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeFloat", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeFloat", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -29731,7 +29731,7 @@ func (na *_TypeFloat__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeFloat__Assembler) Prototype() ipld.NodePrototype { +func (_TypeFloat__Assembler) Prototype() datamodel.NodePrototype { return _TypeFloat__Prototype{} } func (ma *_TypeFloat__Assembler) valueFinishTidy() bool { @@ -29740,7 +29740,7 @@ func (ma *_TypeFloat__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeFloat__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeFloat__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -29755,9 +29755,9 @@ func (ma *_TypeFloat__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeFloat", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeFloat", Key: &_String{k}} } -func (ma *_TypeFloat__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeFloat__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -29775,7 +29775,7 @@ func (ma *_TypeFloat__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeFloat__KeyAssembler)(ma) } -func (ma *_TypeFloat__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeFloat__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -29810,26 +29810,26 @@ func (ma *_TypeFloat__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeFloat_sufficient != fieldBits__TypeFloat_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeFloat__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeFloat__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeFloat__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeFloat__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeFloat__KeyAssembler _TypeFloat__Assembler -func (_TypeFloat__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeFloat__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.KeyAssembler"}.BeginMap(0) } -func (_TypeFloat__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeFloat__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.KeyAssembler"}.BeginList(0) } func (na *_TypeFloat__KeyAssembler) AssignNull() error { @@ -29850,60 +29850,60 @@ func (ka *_TypeFloat__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeFloat", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeFloat", Key: &_String{k}} } } func (_TypeFloat__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.KeyAssembler"}.AssignBytes(nil) } -func (_TypeFloat__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeFloat__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeFloat__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeFloat__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeFloat__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeFloat__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeFloat) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeFloat) Representation() ipld.Node { +func (n TypeFloat) Representation() datamodel.Node { return (*_TypeFloat__Repr)(n) } type _TypeFloat__Repr _TypeFloat var () -var _ ipld.Node = &_TypeFloat__Repr{} +var _ datamodel.Node = &_TypeFloat__Repr{} -func (_TypeFloat__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeFloat__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeFloat__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeFloat__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeFloat__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeFloat__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeFloat__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeFloat__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeFloat.Repr"}.LookupByIndex(0) } -func (n _TypeFloat__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeFloat__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeFloat__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeFloat__Repr) MapIterator() datamodel.MapIterator { return &_TypeFloat__ReprMapItr{n, 0} } @@ -29912,14 +29912,14 @@ type _TypeFloat__ReprMapItr struct { idx int } -func (itr *_TypeFloat__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeFloat__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeFloat__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_TypeFloat__Repr) ListIterator() ipld.ListIterator { +func (_TypeFloat__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeFloat__Repr) Length() int64 { @@ -29947,16 +29947,16 @@ func (_TypeFloat__Repr) AsString() (string, error) { func (_TypeFloat__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeFloat.Repr"}.AsBytes() } -func (_TypeFloat__Repr) AsLink() (ipld.Link, error) { +func (_TypeFloat__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeFloat.Repr"}.AsLink() } -func (_TypeFloat__Repr) Prototype() ipld.NodePrototype { +func (_TypeFloat__Repr) Prototype() datamodel.NodePrototype { return _TypeFloat__ReprPrototype{} } type _TypeFloat__ReprPrototype struct{} -func (_TypeFloat__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeFloat__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeFloat__ReprBuilder nb.Reset() return &nb @@ -29966,7 +29966,7 @@ type _TypeFloat__ReprBuilder struct { _TypeFloat__ReprAssembler } -func (nb *_TypeFloat__ReprBuilder) Build() ipld.Node { +func (nb *_TypeFloat__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -29992,7 +29992,7 @@ func (na *_TypeFloat__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_TypeFloat__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeFloat__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -30005,7 +30005,7 @@ func (na *_TypeFloat__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) } return na, nil } -func (_TypeFloat__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeFloat__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeFloat.Repr"}.BeginList(0) } func (na *_TypeFloat__ReprAssembler) AssignNull() error { @@ -30037,10 +30037,10 @@ func (_TypeFloat__ReprAssembler) AssignString(string) error { func (_TypeFloat__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeFloat.Repr"}.AssignBytes(nil) } -func (_TypeFloat__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeFloat__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeFloat.Repr"}.AssignLink(nil) } -func (na *_TypeFloat__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeFloat__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -30060,8 +30060,8 @@ func (na *_TypeFloat__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeFloat.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeFloat.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -30078,7 +30078,7 @@ func (na *_TypeFloat__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeFloat__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeFloat__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeFloat__ReprPrototype{} } func (ma *_TypeFloat__ReprAssembler) valueFinishTidy() bool { @@ -30087,7 +30087,7 @@ func (ma *_TypeFloat__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeFloat__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeFloat__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -30102,9 +30102,9 @@ func (ma *_TypeFloat__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeFloat.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeFloat.Repr", Key: &_String{k}} } -func (ma *_TypeFloat__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeFloat__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -30122,7 +30122,7 @@ func (ma *_TypeFloat__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeFloat__ReprKeyAssembler)(ma) } -func (ma *_TypeFloat__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeFloat__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -30157,26 +30157,26 @@ func (ma *_TypeFloat__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeFloat_sufficient != fieldBits__TypeFloat_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeFloat__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeFloat__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeFloat__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeFloat__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeFloat__ReprKeyAssembler _TypeFloat__ReprAssembler -func (_TypeFloat__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeFloat__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeFloat__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeFloat__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeFloat__ReprKeyAssembler) AssignNull() error { @@ -30195,22 +30195,22 @@ func (ka *_TypeFloat__ReprKeyAssembler) AssignString(k string) error { if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeFloat.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeFloat.Repr", Key: &_String{k}} } func (_TypeFloat__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeFloat__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeFloat__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeFloat.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeFloat__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeFloat__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeFloat__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeFloat__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -30229,12 +30229,12 @@ func (m MaybeTypeInt) IsAbsent() bool { func (m MaybeTypeInt) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeInt) AsNode() ipld.Node { +func (m MaybeTypeInt) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -30249,32 +30249,32 @@ func (m MaybeTypeInt) Must() TypeInt { } var () -var _ ipld.Node = (TypeInt)(&_TypeInt{}) +var _ datamodel.Node = (TypeInt)(&_TypeInt{}) var _ schema.TypedNode = (TypeInt)(&_TypeInt{}) -func (TypeInt) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeInt) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeInt) LookupByString(key string) (ipld.Node, error) { +func (n TypeInt) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeInt) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeInt) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeInt) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeInt) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeInt"}.LookupByIndex(0) } -func (n TypeInt) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeInt) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeInt) MapIterator() ipld.MapIterator { +func (n TypeInt) MapIterator() datamodel.MapIterator { return &_TypeInt__MapItr{n, 0} } @@ -30283,15 +30283,15 @@ type _TypeInt__MapItr struct { idx int } -func (itr *_TypeInt__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeInt__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeInt__MapItr) Done() bool { return itr.idx >= 0 } -func (TypeInt) ListIterator() ipld.ListIterator { +func (TypeInt) ListIterator() datamodel.ListIterator { return nil } func (TypeInt) Length() int64 { @@ -30318,16 +30318,16 @@ func (TypeInt) AsString() (string, error) { func (TypeInt) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeInt"}.AsBytes() } -func (TypeInt) AsLink() (ipld.Link, error) { +func (TypeInt) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeInt"}.AsLink() } -func (TypeInt) Prototype() ipld.NodePrototype { +func (TypeInt) Prototype() datamodel.NodePrototype { return _TypeInt__Prototype{} } type _TypeInt__Prototype struct{} -func (_TypeInt__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeInt__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeInt__Builder nb.Reset() return &nb @@ -30337,7 +30337,7 @@ type _TypeInt__Builder struct { _TypeInt__Assembler } -func (nb *_TypeInt__Builder) Build() ipld.Node { +func (nb *_TypeInt__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -30368,7 +30368,7 @@ var ( fieldBits__TypeInt_sufficient = 0 ) -func (na *_TypeInt__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeInt__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -30381,7 +30381,7 @@ func (na *_TypeInt__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeInt__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeInt__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeInt"}.BeginList(0) } func (na *_TypeInt__Assembler) AssignNull() error { @@ -30413,10 +30413,10 @@ func (_TypeInt__Assembler) AssignString(string) error { func (_TypeInt__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeInt"}.AssignBytes(nil) } -func (_TypeInt__Assembler) AssignLink(ipld.Link) error { +func (_TypeInt__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeInt"}.AssignLink(nil) } -func (na *_TypeInt__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeInt__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -30436,8 +30436,8 @@ func (na *_TypeInt__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeInt", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeInt", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -30454,7 +30454,7 @@ func (na *_TypeInt__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeInt__Assembler) Prototype() ipld.NodePrototype { +func (_TypeInt__Assembler) Prototype() datamodel.NodePrototype { return _TypeInt__Prototype{} } func (ma *_TypeInt__Assembler) valueFinishTidy() bool { @@ -30463,7 +30463,7 @@ func (ma *_TypeInt__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeInt__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeInt__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -30478,9 +30478,9 @@ func (ma *_TypeInt__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeInt", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeInt", Key: &_String{k}} } -func (ma *_TypeInt__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeInt__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -30498,7 +30498,7 @@ func (ma *_TypeInt__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeInt__KeyAssembler)(ma) } -func (ma *_TypeInt__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeInt__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -30533,26 +30533,26 @@ func (ma *_TypeInt__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeInt_sufficient != fieldBits__TypeInt_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeInt__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeInt__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeInt__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeInt__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeInt__KeyAssembler _TypeInt__Assembler -func (_TypeInt__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeInt__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.KeyAssembler"}.BeginMap(0) } -func (_TypeInt__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeInt__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.KeyAssembler"}.BeginList(0) } func (na *_TypeInt__KeyAssembler) AssignNull() error { @@ -30573,60 +30573,60 @@ func (ka *_TypeInt__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeInt", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeInt", Key: &_String{k}} } } func (_TypeInt__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.KeyAssembler"}.AssignBytes(nil) } -func (_TypeInt__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeInt__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeInt__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeInt__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeInt__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeInt__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeInt) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeInt) Representation() ipld.Node { +func (n TypeInt) Representation() datamodel.Node { return (*_TypeInt__Repr)(n) } type _TypeInt__Repr _TypeInt var () -var _ ipld.Node = &_TypeInt__Repr{} +var _ datamodel.Node = &_TypeInt__Repr{} -func (_TypeInt__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeInt__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeInt__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeInt__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeInt__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeInt__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeInt__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeInt__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeInt.Repr"}.LookupByIndex(0) } -func (n _TypeInt__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeInt__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeInt__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeInt__Repr) MapIterator() datamodel.MapIterator { return &_TypeInt__ReprMapItr{n, 0} } @@ -30635,14 +30635,14 @@ type _TypeInt__ReprMapItr struct { idx int } -func (itr *_TypeInt__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeInt__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeInt__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_TypeInt__Repr) ListIterator() ipld.ListIterator { +func (_TypeInt__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeInt__Repr) Length() int64 { @@ -30670,16 +30670,16 @@ func (_TypeInt__Repr) AsString() (string, error) { func (_TypeInt__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeInt.Repr"}.AsBytes() } -func (_TypeInt__Repr) AsLink() (ipld.Link, error) { +func (_TypeInt__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeInt.Repr"}.AsLink() } -func (_TypeInt__Repr) Prototype() ipld.NodePrototype { +func (_TypeInt__Repr) Prototype() datamodel.NodePrototype { return _TypeInt__ReprPrototype{} } type _TypeInt__ReprPrototype struct{} -func (_TypeInt__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeInt__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeInt__ReprBuilder nb.Reset() return &nb @@ -30689,7 +30689,7 @@ type _TypeInt__ReprBuilder struct { _TypeInt__ReprAssembler } -func (nb *_TypeInt__ReprBuilder) Build() ipld.Node { +func (nb *_TypeInt__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -30715,7 +30715,7 @@ func (na *_TypeInt__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_TypeInt__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeInt__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -30728,7 +30728,7 @@ func (na *_TypeInt__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeInt__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeInt__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeInt.Repr"}.BeginList(0) } func (na *_TypeInt__ReprAssembler) AssignNull() error { @@ -30760,10 +30760,10 @@ func (_TypeInt__ReprAssembler) AssignString(string) error { func (_TypeInt__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeInt.Repr"}.AssignBytes(nil) } -func (_TypeInt__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeInt__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeInt.Repr"}.AssignLink(nil) } -func (na *_TypeInt__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeInt__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -30783,8 +30783,8 @@ func (na *_TypeInt__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeInt.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeInt.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -30801,7 +30801,7 @@ func (na *_TypeInt__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeInt__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeInt__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeInt__ReprPrototype{} } func (ma *_TypeInt__ReprAssembler) valueFinishTidy() bool { @@ -30810,7 +30810,7 @@ func (ma *_TypeInt__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeInt__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeInt__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -30825,9 +30825,9 @@ func (ma *_TypeInt__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeInt.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeInt.Repr", Key: &_String{k}} } -func (ma *_TypeInt__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeInt__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -30845,7 +30845,7 @@ func (ma *_TypeInt__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeInt__ReprKeyAssembler)(ma) } -func (ma *_TypeInt__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeInt__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -30880,26 +30880,26 @@ func (ma *_TypeInt__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeInt_sufficient != fieldBits__TypeInt_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeInt__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeInt__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeInt__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeInt__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeInt__ReprKeyAssembler _TypeInt__ReprAssembler -func (_TypeInt__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeInt__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeInt__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeInt__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeInt__ReprKeyAssembler) AssignNull() error { @@ -30918,22 +30918,22 @@ func (ka *_TypeInt__ReprKeyAssembler) AssignString(k string) error { if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeInt.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeInt.Repr", Key: &_String{k}} } func (_TypeInt__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeInt__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeInt__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeInt.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeInt__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeInt__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeInt__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeInt__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -30956,12 +30956,12 @@ func (m MaybeTypeLink) IsAbsent() bool { func (m MaybeTypeLink) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeLink) AsNode() ipld.Node { +func (m MaybeTypeLink) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -30978,37 +30978,37 @@ func (m MaybeTypeLink) Must() TypeLink { var ( fieldName__TypeLink_ExpectedType = _String{"expectedType"} ) -var _ ipld.Node = (TypeLink)(&_TypeLink{}) +var _ datamodel.Node = (TypeLink)(&_TypeLink{}) var _ schema.TypedNode = (TypeLink)(&_TypeLink{}) -func (TypeLink) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeLink) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeLink) LookupByString(key string) (ipld.Node, error) { +func (n TypeLink) LookupByString(key string) (datamodel.Node, error) { switch key { case "expectedType": if n.expectedType.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } return &n.expectedType.v, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeLink) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeLink) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeLink) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeLink) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeLink"}.LookupByIndex(0) } -func (n TypeLink) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeLink) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeLink) MapIterator() ipld.MapIterator { +func (n TypeLink) MapIterator() datamodel.MapIterator { return &_TypeLink__MapItr{n, 0} } @@ -31017,15 +31017,15 @@ type _TypeLink__MapItr struct { idx int } -func (itr *_TypeLink__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeLink__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: k = &fieldName__TypeLink_ExpectedType if itr.n.expectedType.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } v = &itr.n.expectedType.v @@ -31039,7 +31039,7 @@ func (itr *_TypeLink__MapItr) Done() bool { return itr.idx >= 1 } -func (TypeLink) ListIterator() ipld.ListIterator { +func (TypeLink) ListIterator() datamodel.ListIterator { return nil } func (TypeLink) Length() int64 { @@ -31066,16 +31066,16 @@ func (TypeLink) AsString() (string, error) { func (TypeLink) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeLink"}.AsBytes() } -func (TypeLink) AsLink() (ipld.Link, error) { +func (TypeLink) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeLink"}.AsLink() } -func (TypeLink) Prototype() ipld.NodePrototype { +func (TypeLink) Prototype() datamodel.NodePrototype { return _TypeLink__Prototype{} } type _TypeLink__Prototype struct{} -func (_TypeLink__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeLink__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeLink__Builder nb.Reset() return &nb @@ -31085,7 +31085,7 @@ type _TypeLink__Builder struct { _TypeLink__Assembler } -func (nb *_TypeLink__Builder) Build() ipld.Node { +func (nb *_TypeLink__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -31119,7 +31119,7 @@ var ( fieldBits__TypeLink_sufficient = 0 ) -func (na *_TypeLink__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeLink__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -31132,7 +31132,7 @@ func (na *_TypeLink__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeLink__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeLink__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeLink"}.BeginList(0) } func (na *_TypeLink__Assembler) AssignNull() error { @@ -31164,10 +31164,10 @@ func (_TypeLink__Assembler) AssignString(string) error { func (_TypeLink__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeLink"}.AssignBytes(nil) } -func (_TypeLink__Assembler) AssignLink(ipld.Link) error { +func (_TypeLink__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeLink"}.AssignLink(nil) } -func (na *_TypeLink__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeLink__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -31187,8 +31187,8 @@ func (na *_TypeLink__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeLink", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeLink", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -31205,7 +31205,7 @@ func (na *_TypeLink__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeLink__Assembler) Prototype() ipld.NodePrototype { +func (_TypeLink__Assembler) Prototype() datamodel.NodePrototype { return _TypeLink__Prototype{} } func (ma *_TypeLink__Assembler) valueFinishTidy() bool { @@ -31222,7 +31222,7 @@ func (ma *_TypeLink__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeLink__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -31240,7 +31240,7 @@ func (ma *_TypeLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err switch k { case "expectedType": if ma.s&fieldBit__TypeLink_ExpectedType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType} } ma.s += fieldBit__TypeLink_ExpectedType ma.state = maState_midValue @@ -31249,9 +31249,9 @@ func (ma *_TypeLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err ma.ca_expectedType.m = &ma.w.expectedType.m return &ma.ca_expectedType, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeLink", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeLink", Key: &_String{k}} } -func (ma *_TypeLink__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeLink__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -31269,7 +31269,7 @@ func (ma *_TypeLink__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeLink__KeyAssembler)(ma) } -func (ma *_TypeLink__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeLink__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -31308,26 +31308,26 @@ func (ma *_TypeLink__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeLink_sufficient != fieldBits__TypeLink_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeLink__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeLink__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeLink__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeLink__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeLink__KeyAssembler _TypeLink__Assembler -func (_TypeLink__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeLink__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.KeyAssembler"}.BeginMap(0) } -func (_TypeLink__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeLink__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.KeyAssembler"}.BeginList(0) } func (na *_TypeLink__KeyAssembler) AssignNull() error { @@ -31349,36 +31349,36 @@ func (ka *_TypeLink__KeyAssembler) AssignString(k string) error { switch k { case "expectedType": if ka.s&fieldBit__TypeLink_ExpectedType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType} } ka.s += fieldBit__TypeLink_ExpectedType ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeLink", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeLink", Key: &_String{k}} } } func (_TypeLink__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.KeyAssembler"}.AssignBytes(nil) } -func (_TypeLink__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeLink__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeLink__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeLink__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeLink__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeLink__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeLink) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeLink) Representation() ipld.Node { +func (n TypeLink) Representation() datamodel.Node { return (*_TypeLink__Repr)(n) } @@ -31387,36 +31387,36 @@ type _TypeLink__Repr _TypeLink var ( fieldName__TypeLink_ExpectedType_serial = _String{"expectedType"} ) -var _ ipld.Node = &_TypeLink__Repr{} +var _ datamodel.Node = &_TypeLink__Repr{} -func (_TypeLink__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeLink__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeLink__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeLink__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "expectedType": if n.expectedType.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.expectedType.v.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeLink__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeLink__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeLink__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeLink__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeLink.Repr"}.LookupByIndex(0) } -func (n _TypeLink__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeLink__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeLink__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeLink__Repr) MapIterator() datamodel.MapIterator { end := 1 if n.expectedType.m == schema.Maybe_Absent { end = 0 @@ -31433,10 +31433,10 @@ type _TypeLink__ReprMapItr struct { end int } -func (itr *_TypeLink__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeLink__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { advance: if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -31455,7 +31455,7 @@ advance: func (itr *_TypeLink__ReprMapItr) Done() bool { return itr.idx >= itr.end } -func (_TypeLink__Repr) ListIterator() ipld.ListIterator { +func (_TypeLink__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeLink__Repr) Length() int64 { @@ -31486,16 +31486,16 @@ func (_TypeLink__Repr) AsString() (string, error) { func (_TypeLink__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeLink.Repr"}.AsBytes() } -func (_TypeLink__Repr) AsLink() (ipld.Link, error) { +func (_TypeLink__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeLink.Repr"}.AsLink() } -func (_TypeLink__Repr) Prototype() ipld.NodePrototype { +func (_TypeLink__Repr) Prototype() datamodel.NodePrototype { return _TypeLink__ReprPrototype{} } type _TypeLink__ReprPrototype struct{} -func (_TypeLink__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeLink__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeLink__ReprBuilder nb.Reset() return &nb @@ -31505,7 +31505,7 @@ type _TypeLink__ReprBuilder struct { _TypeLink__ReprAssembler } -func (nb *_TypeLink__ReprBuilder) Build() ipld.Node { +func (nb *_TypeLink__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -31533,7 +31533,7 @@ func (na *_TypeLink__ReprAssembler) reset() { na.s = 0 na.ca_expectedType.reset() } -func (na *_TypeLink__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeLink__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -31546,7 +31546,7 @@ func (na *_TypeLink__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeLink__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeLink__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeLink.Repr"}.BeginList(0) } func (na *_TypeLink__ReprAssembler) AssignNull() error { @@ -31578,10 +31578,10 @@ func (_TypeLink__ReprAssembler) AssignString(string) error { func (_TypeLink__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeLink.Repr"}.AssignBytes(nil) } -func (_TypeLink__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeLink__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeLink.Repr"}.AssignLink(nil) } -func (na *_TypeLink__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeLink__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -31601,8 +31601,8 @@ func (na *_TypeLink__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeLink.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeLink.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -31619,7 +31619,7 @@ func (na *_TypeLink__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeLink__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeLink__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeLink__ReprPrototype{} } func (ma *_TypeLink__ReprAssembler) valueFinishTidy() bool { @@ -31636,7 +31636,7 @@ func (ma *_TypeLink__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeLink__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -31654,7 +31654,7 @@ func (ma *_TypeLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, switch k { case "expectedType": if ma.s&fieldBit__TypeLink_ExpectedType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType_serial} } ma.s += fieldBit__TypeLink_ExpectedType ma.state = maState_midValue @@ -31665,9 +31665,9 @@ func (ma *_TypeLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_expectedType, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeLink.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeLink.Repr", Key: &_String{k}} } -func (ma *_TypeLink__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeLink__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -31685,7 +31685,7 @@ func (ma *_TypeLink__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeLink__ReprKeyAssembler)(ma) } -func (ma *_TypeLink__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeLink__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -31725,26 +31725,26 @@ func (ma *_TypeLink__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeLink_sufficient != fieldBits__TypeLink_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeLink__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeLink__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeLink__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeLink__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeLink__ReprKeyAssembler _TypeLink__ReprAssembler -func (_TypeLink__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeLink__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeLink__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeLink__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeLink__ReprKeyAssembler) AssignNull() error { @@ -31766,29 +31766,29 @@ func (ka *_TypeLink__ReprKeyAssembler) AssignString(k string) error { switch k { case "expectedType": if ka.s&fieldBit__TypeLink_ExpectedType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeLink_ExpectedType_serial} } ka.s += fieldBit__TypeLink_ExpectedType ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeLink.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeLink.Repr", Key: &_String{k}} } func (_TypeLink__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeLink__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeLink__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeLink.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeLink__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeLink__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeLink__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeLink__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -31817,12 +31817,12 @@ func (m MaybeTypeList) IsAbsent() bool { func (m MaybeTypeList) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeList) AsNode() ipld.Node { +func (m MaybeTypeList) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -31841,13 +31841,13 @@ var ( fieldName__TypeList_ValueNullable = _String{"valueNullable"} fieldName__TypeList_Representation = _String{"representation"} ) -var _ ipld.Node = (TypeList)(&_TypeList{}) +var _ datamodel.Node = (TypeList)(&_TypeList{}) var _ schema.TypedNode = (TypeList)(&_TypeList{}) -func (TypeList) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeList) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeList) LookupByString(key string) (ipld.Node, error) { +func (n TypeList) LookupByString(key string) (datamodel.Node, error) { switch key { case "valueType": return &n.valueType, nil @@ -31856,23 +31856,23 @@ func (n TypeList) LookupByString(key string) (ipld.Node, error) { case "representation": return &n.representation, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeList) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeList) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeList) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeList) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeList"}.LookupByIndex(0) } -func (n TypeList) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeList) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeList) MapIterator() ipld.MapIterator { +func (n TypeList) MapIterator() datamodel.MapIterator { return &_TypeList__MapItr{n, 0} } @@ -31881,9 +31881,9 @@ type _TypeList__MapItr struct { idx int } -func (itr *_TypeList__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeList__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -31905,7 +31905,7 @@ func (itr *_TypeList__MapItr) Done() bool { return itr.idx >= 3 } -func (TypeList) ListIterator() ipld.ListIterator { +func (TypeList) ListIterator() datamodel.ListIterator { return nil } func (TypeList) Length() int64 { @@ -31932,16 +31932,16 @@ func (TypeList) AsString() (string, error) { func (TypeList) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeList"}.AsBytes() } -func (TypeList) AsLink() (ipld.Link, error) { +func (TypeList) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeList"}.AsLink() } -func (TypeList) Prototype() ipld.NodePrototype { +func (TypeList) Prototype() datamodel.NodePrototype { return _TypeList__Prototype{} } type _TypeList__Prototype struct{} -func (_TypeList__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeList__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeList__Builder nb.Reset() return &nb @@ -31951,7 +31951,7 @@ type _TypeList__Builder struct { _TypeList__Assembler } -func (nb *_TypeList__Builder) Build() ipld.Node { +func (nb *_TypeList__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -31991,7 +31991,7 @@ var ( fieldBits__TypeList_sufficient = 0 + 1<<0 + 1<<1 + 1<<2 ) -func (na *_TypeList__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeList__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -32004,7 +32004,7 @@ func (na *_TypeList__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeList__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeList__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeList"}.BeginList(0) } func (na *_TypeList__Assembler) AssignNull() error { @@ -32036,10 +32036,10 @@ func (_TypeList__Assembler) AssignString(string) error { func (_TypeList__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeList"}.AssignBytes(nil) } -func (_TypeList__Assembler) AssignLink(ipld.Link) error { +func (_TypeList__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeList"}.AssignLink(nil) } -func (na *_TypeList__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeList__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -32059,8 +32059,8 @@ func (na *_TypeList__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeList", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeList", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -32077,7 +32077,7 @@ func (na *_TypeList__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeList__Assembler) Prototype() ipld.NodePrototype { +func (_TypeList__Assembler) Prototype() datamodel.NodePrototype { return _TypeList__Prototype{} } func (ma *_TypeList__Assembler) valueFinishTidy() bool { @@ -32116,7 +32116,7 @@ func (ma *_TypeList__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeList__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeList__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -32134,7 +32134,7 @@ func (ma *_TypeList__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err switch k { case "valueType": if ma.s&fieldBit__TypeList_ValueType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType} } ma.s += fieldBit__TypeList_ValueType ma.state = maState_midValue @@ -32144,7 +32144,7 @@ func (ma *_TypeList__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err return &ma.ca_valueType, nil case "valueNullable": if ma.s&fieldBit__TypeList_ValueNullable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable} } ma.s += fieldBit__TypeList_ValueNullable ma.state = maState_midValue @@ -32154,7 +32154,7 @@ func (ma *_TypeList__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err return &ma.ca_valueNullable, nil case "representation": if ma.s&fieldBit__TypeList_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation} } ma.s += fieldBit__TypeList_Representation ma.state = maState_midValue @@ -32163,9 +32163,9 @@ func (ma *_TypeList__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, err ma.ca_representation.m = &ma.cm return &ma.ca_representation, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeList", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeList", Key: &_String{k}} } -func (ma *_TypeList__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeList__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -32183,7 +32183,7 @@ func (ma *_TypeList__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeList__KeyAssembler)(ma) } -func (ma *_TypeList__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeList__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -32230,7 +32230,7 @@ func (ma *_TypeList__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeList_sufficient != fieldBits__TypeList_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeList_ValueType == 0 { err.Missing = append(err.Missing, "valueType") } @@ -32246,19 +32246,19 @@ func (ma *_TypeList__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeList__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeList__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeList__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeList__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeList__KeyAssembler _TypeList__Assembler -func (_TypeList__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeList__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.KeyAssembler"}.BeginMap(0) } -func (_TypeList__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeList__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.KeyAssembler"}.BeginList(0) } func (na *_TypeList__KeyAssembler) AssignNull() error { @@ -32280,7 +32280,7 @@ func (ka *_TypeList__KeyAssembler) AssignString(k string) error { switch k { case "valueType": if ka.s&fieldBit__TypeList_ValueType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType} } ka.s += fieldBit__TypeList_ValueType ka.state = maState_expectValue @@ -32288,7 +32288,7 @@ func (ka *_TypeList__KeyAssembler) AssignString(k string) error { return nil case "valueNullable": if ka.s&fieldBit__TypeList_ValueNullable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable} } ka.s += fieldBit__TypeList_ValueNullable ka.state = maState_expectValue @@ -32296,36 +32296,36 @@ func (ka *_TypeList__KeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeList_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation} } ka.s += fieldBit__TypeList_Representation ka.state = maState_expectValue ka.f = 2 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeList", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeList", Key: &_String{k}} } } func (_TypeList__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.KeyAssembler"}.AssignBytes(nil) } -func (_TypeList__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeList__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeList__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeList__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeList__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeList__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeList) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeList) Representation() ipld.Node { +func (n TypeList) Representation() datamodel.Node { return (*_TypeList__Repr)(n) } @@ -32336,12 +32336,12 @@ var ( fieldName__TypeList_ValueNullable_serial = _String{"valueNullable"} fieldName__TypeList_Representation_serial = _String{"representation"} ) -var _ ipld.Node = &_TypeList__Repr{} +var _ datamodel.Node = &_TypeList__Repr{} -func (_TypeList__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeList__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeList__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeList__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "valueType": return n.valueType.Representation(), nil @@ -32350,23 +32350,23 @@ func (n *_TypeList__Repr) LookupByString(key string) (ipld.Node, error) { case "representation": return n.representation.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeList__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeList__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeList__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeList__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeList.Repr"}.LookupByIndex(0) } -func (n _TypeList__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeList__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeList__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeList__Repr) MapIterator() datamodel.MapIterator { return &_TypeList__ReprMapItr{n, 0} } @@ -32375,9 +32375,9 @@ type _TypeList__ReprMapItr struct { idx int } -func (itr *_TypeList__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeList__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -32398,7 +32398,7 @@ func (itr *_TypeList__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_TypeList__ReprMapItr) Done() bool { return itr.idx >= 3 } -func (_TypeList__Repr) ListIterator() ipld.ListIterator { +func (_TypeList__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeList__Repr) Length() int64 { @@ -32426,16 +32426,16 @@ func (_TypeList__Repr) AsString() (string, error) { func (_TypeList__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeList.Repr"}.AsBytes() } -func (_TypeList__Repr) AsLink() (ipld.Link, error) { +func (_TypeList__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeList.Repr"}.AsLink() } -func (_TypeList__Repr) Prototype() ipld.NodePrototype { +func (_TypeList__Repr) Prototype() datamodel.NodePrototype { return _TypeList__ReprPrototype{} } type _TypeList__ReprPrototype struct{} -func (_TypeList__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeList__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeList__ReprBuilder nb.Reset() return &nb @@ -32445,7 +32445,7 @@ type _TypeList__ReprBuilder struct { _TypeList__ReprAssembler } -func (nb *_TypeList__ReprBuilder) Build() ipld.Node { +func (nb *_TypeList__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -32477,7 +32477,7 @@ func (na *_TypeList__ReprAssembler) reset() { na.ca_valueNullable.reset() na.ca_representation.reset() } -func (na *_TypeList__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeList__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -32490,7 +32490,7 @@ func (na *_TypeList__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeList__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeList__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeList.Repr"}.BeginList(0) } func (na *_TypeList__ReprAssembler) AssignNull() error { @@ -32522,10 +32522,10 @@ func (_TypeList__ReprAssembler) AssignString(string) error { func (_TypeList__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeList.Repr"}.AssignBytes(nil) } -func (_TypeList__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeList__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeList.Repr"}.AssignLink(nil) } -func (na *_TypeList__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeList__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -32545,8 +32545,8 @@ func (na *_TypeList__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeList.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeList.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -32563,7 +32563,7 @@ func (na *_TypeList__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeList__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeList__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeList__ReprPrototype{} } func (ma *_TypeList__ReprAssembler) valueFinishTidy() bool { @@ -32599,7 +32599,7 @@ func (ma *_TypeList__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeList__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeList__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -32617,7 +32617,7 @@ func (ma *_TypeList__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, switch k { case "valueType": if ma.s&fieldBit__TypeList_ValueType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType_serial} } ma.s += fieldBit__TypeList_ValueType ma.state = maState_midValue @@ -32627,7 +32627,7 @@ func (ma *_TypeList__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_valueType, nil case "valueNullable": if ma.s&fieldBit__TypeList_ValueNullable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable_serial} } ma.s += fieldBit__TypeList_ValueNullable ma.state = maState_midValue @@ -32637,7 +32637,7 @@ func (ma *_TypeList__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_valueNullable, nil case "representation": if ma.s&fieldBit__TypeList_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation_serial} } ma.s += fieldBit__TypeList_Representation ma.state = maState_midValue @@ -32647,9 +32647,9 @@ func (ma *_TypeList__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_representation, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeList.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeList.Repr", Key: &_String{k}} } -func (ma *_TypeList__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeList__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -32667,7 +32667,7 @@ func (ma *_TypeList__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeList__ReprKeyAssembler)(ma) } -func (ma *_TypeList__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeList__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -32714,7 +32714,7 @@ func (ma *_TypeList__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeList_sufficient != fieldBits__TypeList_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeList_ValueType == 0 { err.Missing = append(err.Missing, "valueType") } @@ -32730,19 +32730,19 @@ func (ma *_TypeList__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeList__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeList__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeList__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeList__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeList__ReprKeyAssembler _TypeList__ReprAssembler -func (_TypeList__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeList__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeList__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeList__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeList__ReprKeyAssembler) AssignNull() error { @@ -32764,7 +32764,7 @@ func (ka *_TypeList__ReprKeyAssembler) AssignString(k string) error { switch k { case "valueType": if ka.s&fieldBit__TypeList_ValueType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueType_serial} } ka.s += fieldBit__TypeList_ValueType ka.state = maState_expectValue @@ -32772,7 +32772,7 @@ func (ka *_TypeList__ReprKeyAssembler) AssignString(k string) error { return nil case "valueNullable": if ka.s&fieldBit__TypeList_ValueNullable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_ValueNullable_serial} } ka.s += fieldBit__TypeList_ValueNullable ka.state = maState_expectValue @@ -32780,29 +32780,29 @@ func (ka *_TypeList__ReprKeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeList_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeList_Representation_serial} } ka.s += fieldBit__TypeList_Representation ka.state = maState_expectValue ka.f = 2 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeList.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeList.Repr", Key: &_String{k}} } func (_TypeList__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeList__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeList__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeList.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeList__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeList__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeList__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeList__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -32834,12 +32834,12 @@ func (m MaybeTypeMap) IsAbsent() bool { func (m MaybeTypeMap) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeMap) AsNode() ipld.Node { +func (m MaybeTypeMap) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -32859,13 +32859,13 @@ var ( fieldName__TypeMap_ValueNullable = _String{"valueNullable"} fieldName__TypeMap_Representation = _String{"representation"} ) -var _ ipld.Node = (TypeMap)(&_TypeMap{}) +var _ datamodel.Node = (TypeMap)(&_TypeMap{}) var _ schema.TypedNode = (TypeMap)(&_TypeMap{}) -func (TypeMap) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeMap) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeMap) LookupByString(key string) (ipld.Node, error) { +func (n TypeMap) LookupByString(key string) (datamodel.Node, error) { switch key { case "keyType": return &n.keyType, nil @@ -32876,23 +32876,23 @@ func (n TypeMap) LookupByString(key string) (ipld.Node, error) { case "representation": return &n.representation, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeMap) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeMap) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeMap) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeMap) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeMap"}.LookupByIndex(0) } -func (n TypeMap) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeMap) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeMap) MapIterator() ipld.MapIterator { +func (n TypeMap) MapIterator() datamodel.MapIterator { return &_TypeMap__MapItr{n, 0} } @@ -32901,9 +32901,9 @@ type _TypeMap__MapItr struct { idx int } -func (itr *_TypeMap__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeMap__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 4 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -32928,7 +32928,7 @@ func (itr *_TypeMap__MapItr) Done() bool { return itr.idx >= 4 } -func (TypeMap) ListIterator() ipld.ListIterator { +func (TypeMap) ListIterator() datamodel.ListIterator { return nil } func (TypeMap) Length() int64 { @@ -32955,16 +32955,16 @@ func (TypeMap) AsString() (string, error) { func (TypeMap) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeMap"}.AsBytes() } -func (TypeMap) AsLink() (ipld.Link, error) { +func (TypeMap) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeMap"}.AsLink() } -func (TypeMap) Prototype() ipld.NodePrototype { +func (TypeMap) Prototype() datamodel.NodePrototype { return _TypeMap__Prototype{} } type _TypeMap__Prototype struct{} -func (_TypeMap__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeMap__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeMap__Builder nb.Reset() return &nb @@ -32974,7 +32974,7 @@ type _TypeMap__Builder struct { _TypeMap__Assembler } -func (nb *_TypeMap__Builder) Build() ipld.Node { +func (nb *_TypeMap__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -33017,7 +33017,7 @@ var ( fieldBits__TypeMap_sufficient = 0 + 1<<0 + 1<<1 + 1<<2 + 1<<3 ) -func (na *_TypeMap__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeMap__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -33030,7 +33030,7 @@ func (na *_TypeMap__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeMap__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeMap__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeMap"}.BeginList(0) } func (na *_TypeMap__Assembler) AssignNull() error { @@ -33062,10 +33062,10 @@ func (_TypeMap__Assembler) AssignString(string) error { func (_TypeMap__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeMap"}.AssignBytes(nil) } -func (_TypeMap__Assembler) AssignLink(ipld.Link) error { +func (_TypeMap__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeMap"}.AssignLink(nil) } -func (na *_TypeMap__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeMap__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -33085,8 +33085,8 @@ func (na *_TypeMap__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeMap", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeMap", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -33103,7 +33103,7 @@ func (na *_TypeMap__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeMap__Assembler) Prototype() ipld.NodePrototype { +func (_TypeMap__Assembler) Prototype() datamodel.NodePrototype { return _TypeMap__Prototype{} } func (ma *_TypeMap__Assembler) valueFinishTidy() bool { @@ -33152,7 +33152,7 @@ func (ma *_TypeMap__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeMap__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -33170,7 +33170,7 @@ func (ma *_TypeMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro switch k { case "keyType": if ma.s&fieldBit__TypeMap_KeyType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType} } ma.s += fieldBit__TypeMap_KeyType ma.state = maState_midValue @@ -33180,7 +33180,7 @@ func (ma *_TypeMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro return &ma.ca_keyType, nil case "valueType": if ma.s&fieldBit__TypeMap_ValueType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType} } ma.s += fieldBit__TypeMap_ValueType ma.state = maState_midValue @@ -33190,7 +33190,7 @@ func (ma *_TypeMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro return &ma.ca_valueType, nil case "valueNullable": if ma.s&fieldBit__TypeMap_ValueNullable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable} } ma.s += fieldBit__TypeMap_ValueNullable ma.state = maState_midValue @@ -33200,7 +33200,7 @@ func (ma *_TypeMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro return &ma.ca_valueNullable, nil case "representation": if ma.s&fieldBit__TypeMap_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation} } ma.s += fieldBit__TypeMap_Representation ma.state = maState_midValue @@ -33209,9 +33209,9 @@ func (ma *_TypeMap__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, erro ma.ca_representation.m = &ma.cm return &ma.ca_representation, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeMap", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeMap", Key: &_String{k}} } -func (ma *_TypeMap__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeMap__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -33229,7 +33229,7 @@ func (ma *_TypeMap__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeMap__KeyAssembler)(ma) } -func (ma *_TypeMap__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeMap__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -33280,7 +33280,7 @@ func (ma *_TypeMap__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeMap_sufficient != fieldBits__TypeMap_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeMap_KeyType == 0 { err.Missing = append(err.Missing, "keyType") } @@ -33299,19 +33299,19 @@ func (ma *_TypeMap__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeMap__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeMap__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeMap__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeMap__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeMap__KeyAssembler _TypeMap__Assembler -func (_TypeMap__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeMap__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.KeyAssembler"}.BeginMap(0) } -func (_TypeMap__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeMap__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.KeyAssembler"}.BeginList(0) } func (na *_TypeMap__KeyAssembler) AssignNull() error { @@ -33333,7 +33333,7 @@ func (ka *_TypeMap__KeyAssembler) AssignString(k string) error { switch k { case "keyType": if ka.s&fieldBit__TypeMap_KeyType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType} } ka.s += fieldBit__TypeMap_KeyType ka.state = maState_expectValue @@ -33341,7 +33341,7 @@ func (ka *_TypeMap__KeyAssembler) AssignString(k string) error { return nil case "valueType": if ka.s&fieldBit__TypeMap_ValueType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType} } ka.s += fieldBit__TypeMap_ValueType ka.state = maState_expectValue @@ -33349,7 +33349,7 @@ func (ka *_TypeMap__KeyAssembler) AssignString(k string) error { return nil case "valueNullable": if ka.s&fieldBit__TypeMap_ValueNullable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable} } ka.s += fieldBit__TypeMap_ValueNullable ka.state = maState_expectValue @@ -33357,36 +33357,36 @@ func (ka *_TypeMap__KeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeMap_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation} } ka.s += fieldBit__TypeMap_Representation ka.state = maState_expectValue ka.f = 3 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeMap", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeMap", Key: &_String{k}} } } func (_TypeMap__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.KeyAssembler"}.AssignBytes(nil) } -func (_TypeMap__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeMap__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeMap__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeMap__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeMap__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeMap__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeMap) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeMap) Representation() ipld.Node { +func (n TypeMap) Representation() datamodel.Node { return (*_TypeMap__Repr)(n) } @@ -33398,12 +33398,12 @@ var ( fieldName__TypeMap_ValueNullable_serial = _String{"valueNullable"} fieldName__TypeMap_Representation_serial = _String{"representation"} ) -var _ ipld.Node = &_TypeMap__Repr{} +var _ datamodel.Node = &_TypeMap__Repr{} -func (_TypeMap__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeMap__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeMap__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeMap__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "keyType": return n.keyType.Representation(), nil @@ -33414,23 +33414,23 @@ func (n *_TypeMap__Repr) LookupByString(key string) (ipld.Node, error) { case "representation": return n.representation.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeMap__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeMap__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeMap__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeMap__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeMap.Repr"}.LookupByIndex(0) } -func (n _TypeMap__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeMap__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeMap__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeMap__Repr) MapIterator() datamodel.MapIterator { return &_TypeMap__ReprMapItr{n, 0} } @@ -33439,9 +33439,9 @@ type _TypeMap__ReprMapItr struct { idx int } -func (itr *_TypeMap__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeMap__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 4 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -33465,7 +33465,7 @@ func (itr *_TypeMap__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_TypeMap__ReprMapItr) Done() bool { return itr.idx >= 4 } -func (_TypeMap__Repr) ListIterator() ipld.ListIterator { +func (_TypeMap__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeMap__Repr) Length() int64 { @@ -33493,16 +33493,16 @@ func (_TypeMap__Repr) AsString() (string, error) { func (_TypeMap__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeMap.Repr"}.AsBytes() } -func (_TypeMap__Repr) AsLink() (ipld.Link, error) { +func (_TypeMap__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeMap.Repr"}.AsLink() } -func (_TypeMap__Repr) Prototype() ipld.NodePrototype { +func (_TypeMap__Repr) Prototype() datamodel.NodePrototype { return _TypeMap__ReprPrototype{} } type _TypeMap__ReprPrototype struct{} -func (_TypeMap__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeMap__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeMap__ReprBuilder nb.Reset() return &nb @@ -33512,7 +33512,7 @@ type _TypeMap__ReprBuilder struct { _TypeMap__ReprAssembler } -func (nb *_TypeMap__ReprBuilder) Build() ipld.Node { +func (nb *_TypeMap__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -33546,7 +33546,7 @@ func (na *_TypeMap__ReprAssembler) reset() { na.ca_valueNullable.reset() na.ca_representation.reset() } -func (na *_TypeMap__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeMap__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -33559,7 +33559,7 @@ func (na *_TypeMap__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeMap__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeMap__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeMap.Repr"}.BeginList(0) } func (na *_TypeMap__ReprAssembler) AssignNull() error { @@ -33591,10 +33591,10 @@ func (_TypeMap__ReprAssembler) AssignString(string) error { func (_TypeMap__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeMap.Repr"}.AssignBytes(nil) } -func (_TypeMap__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeMap__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeMap.Repr"}.AssignLink(nil) } -func (na *_TypeMap__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeMap__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -33614,8 +33614,8 @@ func (na *_TypeMap__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeMap.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeMap.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -33632,7 +33632,7 @@ func (na *_TypeMap__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeMap__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeMap__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeMap__ReprPrototype{} } func (ma *_TypeMap__ReprAssembler) valueFinishTidy() bool { @@ -33677,7 +33677,7 @@ func (ma *_TypeMap__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -33695,7 +33695,7 @@ func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, switch k { case "keyType": if ma.s&fieldBit__TypeMap_KeyType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType_serial} } ma.s += fieldBit__TypeMap_KeyType ma.state = maState_midValue @@ -33705,7 +33705,7 @@ func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_keyType, nil case "valueType": if ma.s&fieldBit__TypeMap_ValueType != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType_serial} } ma.s += fieldBit__TypeMap_ValueType ma.state = maState_midValue @@ -33715,7 +33715,7 @@ func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_valueType, nil case "valueNullable": if ma.s&fieldBit__TypeMap_ValueNullable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable_serial} } ma.s += fieldBit__TypeMap_ValueNullable ma.state = maState_midValue @@ -33725,7 +33725,7 @@ func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_valueNullable, nil case "representation": if ma.s&fieldBit__TypeMap_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation_serial} } ma.s += fieldBit__TypeMap_Representation ma.state = maState_midValue @@ -33735,9 +33735,9 @@ func (ma *_TypeMap__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, return &ma.ca_representation, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeMap.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeMap.Repr", Key: &_String{k}} } -func (ma *_TypeMap__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeMap__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -33755,7 +33755,7 @@ func (ma *_TypeMap__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeMap__ReprKeyAssembler)(ma) } -func (ma *_TypeMap__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeMap__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -33806,7 +33806,7 @@ func (ma *_TypeMap__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeMap_sufficient != fieldBits__TypeMap_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeMap_KeyType == 0 { err.Missing = append(err.Missing, "keyType") } @@ -33825,19 +33825,19 @@ func (ma *_TypeMap__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeMap__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeMap__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeMap__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeMap__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeMap__ReprKeyAssembler _TypeMap__ReprAssembler -func (_TypeMap__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeMap__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeMap__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeMap__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeMap__ReprKeyAssembler) AssignNull() error { @@ -33859,7 +33859,7 @@ func (ka *_TypeMap__ReprKeyAssembler) AssignString(k string) error { switch k { case "keyType": if ka.s&fieldBit__TypeMap_KeyType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_KeyType_serial} } ka.s += fieldBit__TypeMap_KeyType ka.state = maState_expectValue @@ -33867,7 +33867,7 @@ func (ka *_TypeMap__ReprKeyAssembler) AssignString(k string) error { return nil case "valueType": if ka.s&fieldBit__TypeMap_ValueType != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueType_serial} } ka.s += fieldBit__TypeMap_ValueType ka.state = maState_expectValue @@ -33875,7 +33875,7 @@ func (ka *_TypeMap__ReprKeyAssembler) AssignString(k string) error { return nil case "valueNullable": if ka.s&fieldBit__TypeMap_ValueNullable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_ValueNullable_serial} } ka.s += fieldBit__TypeMap_ValueNullable ka.state = maState_expectValue @@ -33883,29 +33883,29 @@ func (ka *_TypeMap__ReprKeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeMap_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeMap_Representation_serial} } ka.s += fieldBit__TypeMap_Representation ka.state = maState_expectValue ka.f = 3 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeMap.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeMap.Repr", Key: &_String{k}} } func (_TypeMap__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeMap__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeMap__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeMap.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeMap__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeMap__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeMap__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeMap__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -33936,12 +33936,12 @@ func (m MaybeTypeName) IsAbsent() bool { func (m MaybeTypeName) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeName) AsNode() ipld.Node { +func (m MaybeTypeName) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -33955,28 +33955,28 @@ func (m MaybeTypeName) Must() TypeName { return &m.v } -var _ ipld.Node = (TypeName)(&_TypeName{}) +var _ datamodel.Node = (TypeName)(&_TypeName{}) var _ schema.TypedNode = (TypeName)(&_TypeName{}) -func (TypeName) Kind() ipld.Kind { - return ipld.Kind_String +func (TypeName) Kind() datamodel.Kind { + return datamodel.Kind_String } -func (TypeName) LookupByString(string) (ipld.Node, error) { +func (TypeName) LookupByString(string) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.TypeName"}.LookupByString("") } -func (TypeName) LookupByNode(ipld.Node) (ipld.Node, error) { +func (TypeName) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.TypeName"}.LookupByNode(nil) } -func (TypeName) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeName) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.TypeName"}.LookupByIndex(0) } -func (TypeName) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (TypeName) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.String{TypeName: "schemadmt.TypeName"}.LookupBySegment(seg) } -func (TypeName) MapIterator() ipld.MapIterator { +func (TypeName) MapIterator() datamodel.MapIterator { return nil } -func (TypeName) ListIterator() ipld.ListIterator { +func (TypeName) ListIterator() datamodel.ListIterator { return nil } func (TypeName) Length() int64 { @@ -34003,16 +34003,16 @@ func (n TypeName) AsString() (string, error) { func (TypeName) AsBytes() ([]byte, error) { return mixins.String{TypeName: "schemadmt.TypeName"}.AsBytes() } -func (TypeName) AsLink() (ipld.Link, error) { +func (TypeName) AsLink() (datamodel.Link, error) { return mixins.String{TypeName: "schemadmt.TypeName"}.AsLink() } -func (TypeName) Prototype() ipld.NodePrototype { +func (TypeName) Prototype() datamodel.NodePrototype { return _TypeName__Prototype{} } type _TypeName__Prototype struct{} -func (_TypeName__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeName__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeName__Builder nb.Reset() return &nb @@ -34022,7 +34022,7 @@ type _TypeName__Builder struct { _TypeName__Assembler } -func (nb *_TypeName__Builder) Build() ipld.Node { +func (nb *_TypeName__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -34040,10 +34040,10 @@ type _TypeName__Assembler struct { } func (na *_TypeName__Assembler) reset() {} -func (_TypeName__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeName__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeName"}.BeginMap(0) } -func (_TypeName__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeName__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeName"}.BeginList(0) } func (na *_TypeName__Assembler) AssignNull() error { @@ -34079,10 +34079,10 @@ func (na *_TypeName__Assembler) AssignString(v string) error { func (_TypeName__Assembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeName"}.AssignBytes(nil) } -func (_TypeName__Assembler) AssignLink(ipld.Link) error { +func (_TypeName__Assembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeName"}.AssignLink(nil) } -func (na *_TypeName__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeName__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -34101,19 +34101,19 @@ func (na *_TypeName__Assembler) AssignNode(v ipld.Node) error { return na.AssignString(v2) } } -func (_TypeName__Assembler) Prototype() ipld.NodePrototype { +func (_TypeName__Assembler) Prototype() datamodel.NodePrototype { return _TypeName__Prototype{} } func (TypeName) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeName) Representation() ipld.Node { +func (n TypeName) Representation() datamodel.Node { return (*_TypeName__Repr)(n) } type _TypeName__Repr = _TypeName -var _ ipld.Node = &_TypeName__Repr{} +var _ datamodel.Node = &_TypeName__Repr{} type _TypeName__ReprPrototype = _TypeName__Prototype type _TypeName__ReprAssembler = _TypeName__Assembler @@ -34144,12 +34144,12 @@ func (m MaybeTypeNameOrInlineDefn) IsAbsent() bool { func (m MaybeTypeNameOrInlineDefn) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeNameOrInlineDefn) AsNode() ipld.Node { +func (m MaybeTypeNameOrInlineDefn) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -34167,42 +34167,42 @@ var ( memberName__TypeNameOrInlineDefn_TypeName = _String{"TypeName"} memberName__TypeNameOrInlineDefn_TypeDefnInline = _String{"TypeDefnInline"} ) -var _ ipld.Node = (TypeNameOrInlineDefn)(&_TypeNameOrInlineDefn{}) +var _ datamodel.Node = (TypeNameOrInlineDefn)(&_TypeNameOrInlineDefn{}) var _ schema.TypedNode = (TypeNameOrInlineDefn)(&_TypeNameOrInlineDefn{}) -func (TypeNameOrInlineDefn) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeNameOrInlineDefn) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeNameOrInlineDefn) LookupByString(key string) (ipld.Node, error) { +func (n TypeNameOrInlineDefn) LookupByString(key string) (datamodel.Node, error) { switch key { case "TypeName": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "TypeDefnInline": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeNameOrInlineDefn) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeNameOrInlineDefn) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeNameOrInlineDefn) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeNameOrInlineDefn) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeNameOrInlineDefn"}.LookupByIndex(0) } -func (n TypeNameOrInlineDefn) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeNameOrInlineDefn) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeNameOrInlineDefn) MapIterator() ipld.MapIterator { +func (n TypeNameOrInlineDefn) MapIterator() datamodel.MapIterator { return &_TypeNameOrInlineDefn__MapItr{n, false} } @@ -34211,9 +34211,9 @@ type _TypeNameOrInlineDefn__MapItr struct { done bool } -func (itr *_TypeNameOrInlineDefn__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeNameOrInlineDefn__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -34230,7 +34230,7 @@ func (itr *_TypeNameOrInlineDefn__MapItr) Done() bool { return itr.done } -func (TypeNameOrInlineDefn) ListIterator() ipld.ListIterator { +func (TypeNameOrInlineDefn) ListIterator() datamodel.ListIterator { return nil } func (TypeNameOrInlineDefn) Length() int64 { @@ -34257,16 +34257,16 @@ func (TypeNameOrInlineDefn) AsString() (string, error) { func (TypeNameOrInlineDefn) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeNameOrInlineDefn"}.AsBytes() } -func (TypeNameOrInlineDefn) AsLink() (ipld.Link, error) { +func (TypeNameOrInlineDefn) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeNameOrInlineDefn"}.AsLink() } -func (TypeNameOrInlineDefn) Prototype() ipld.NodePrototype { +func (TypeNameOrInlineDefn) Prototype() datamodel.NodePrototype { return _TypeNameOrInlineDefn__Prototype{} } type _TypeNameOrInlineDefn__Prototype struct{} -func (_TypeNameOrInlineDefn__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeNameOrInlineDefn__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeNameOrInlineDefn__Builder nb.Reset() return &nb @@ -34276,7 +34276,7 @@ type _TypeNameOrInlineDefn__Builder struct { _TypeNameOrInlineDefn__Assembler } -func (nb *_TypeNameOrInlineDefn__Builder) Build() ipld.Node { +func (nb *_TypeNameOrInlineDefn__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -34316,7 +34316,7 @@ func (na *_TypeNameOrInlineDefn__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_TypeNameOrInlineDefn__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeNameOrInlineDefn__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -34329,7 +34329,7 @@ func (na *_TypeNameOrInlineDefn__Assembler) BeginMap(int64) (ipld.MapAssembler, } return na, nil } -func (_TypeNameOrInlineDefn__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeNameOrInlineDefn__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn"}.BeginList(0) } func (na *_TypeNameOrInlineDefn__Assembler) AssignNull() error { @@ -34361,10 +34361,10 @@ func (_TypeNameOrInlineDefn__Assembler) AssignString(string) error { func (_TypeNameOrInlineDefn__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn"}.AssignBytes(nil) } -func (_TypeNameOrInlineDefn__Assembler) AssignLink(ipld.Link) error { +func (_TypeNameOrInlineDefn__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn"}.AssignLink(nil) } -func (na *_TypeNameOrInlineDefn__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeNameOrInlineDefn__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -34384,8 +34384,8 @@ func (na *_TypeNameOrInlineDefn__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -34402,7 +34402,7 @@ func (na *_TypeNameOrInlineDefn__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeNameOrInlineDefn__Assembler) Prototype() ipld.NodePrototype { +func (_TypeNameOrInlineDefn__Assembler) Prototype() datamodel.NodePrototype { return _TypeNameOrInlineDefn__Prototype{} } func (ma *_TypeNameOrInlineDefn__Assembler) valueFinishTidy() bool { @@ -34414,7 +34414,7 @@ func (ma *_TypeNameOrInlineDefn__Assembler) valueFinishTidy() bool { return false } } -func (ma *_TypeNameOrInlineDefn__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeNameOrInlineDefn__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -34448,9 +34448,9 @@ func (ma *_TypeNameOrInlineDefn__Assembler) AssembleEntry(k string) (ipld.NodeAs ma.ca2.m = &ma.cm return &ma.ca2, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeNameOrInlineDefn", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeNameOrInlineDefn", Key: &_String{k}} } -func (ma *_TypeNameOrInlineDefn__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeNameOrInlineDefn__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -34468,7 +34468,7 @@ func (ma *_TypeNameOrInlineDefn__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeNameOrInlineDefn__KeyAssembler)(ma) } -func (ma *_TypeNameOrInlineDefn__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeNameOrInlineDefn__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -34517,10 +34517,10 @@ func (ma *_TypeNameOrInlineDefn__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeNameOrInlineDefn__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeNameOrInlineDefn__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeNameOrInlineDefn__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeNameOrInlineDefn__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "TypeName": return _TypeName__Prototype{} @@ -34533,10 +34533,10 @@ func (ma *_TypeNameOrInlineDefn__Assembler) ValuePrototype(k string) ipld.NodePr type _TypeNameOrInlineDefn__KeyAssembler _TypeNameOrInlineDefn__Assembler -func (_TypeNameOrInlineDefn__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeNameOrInlineDefn__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn.KeyAssembler"}.BeginMap(0) } -func (_TypeNameOrInlineDefn__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeNameOrInlineDefn__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn.KeyAssembler"}.BeginList(0) } func (na *_TypeNameOrInlineDefn__KeyAssembler) AssignNull() error { @@ -34570,73 +34570,73 @@ func (ka *_TypeNameOrInlineDefn__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeNameOrInlineDefn", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeNameOrInlineDefn", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_TypeNameOrInlineDefn__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn.KeyAssembler"}.AssignBytes(nil) } -func (_TypeNameOrInlineDefn__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeNameOrInlineDefn__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeNameOrInlineDefn.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeNameOrInlineDefn__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeNameOrInlineDefn__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeNameOrInlineDefn__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeNameOrInlineDefn__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeNameOrInlineDefn) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeNameOrInlineDefn) Representation() ipld.Node { +func (n TypeNameOrInlineDefn) Representation() datamodel.Node { return (*_TypeNameOrInlineDefn__Repr)(n) } type _TypeNameOrInlineDefn__Repr _TypeNameOrInlineDefn -var _ ipld.Node = &_TypeNameOrInlineDefn__Repr{} +var _ datamodel.Node = &_TypeNameOrInlineDefn__Repr{} -func (n *_TypeNameOrInlineDefn__Repr) Kind() ipld.Kind { +func (n *_TypeNameOrInlineDefn__Repr) Kind() datamodel.Kind { switch n.tag { case 1: - return ipld.Kind_String + return datamodel.Kind_String case 2: - return ipld.Kind_Map + return datamodel.Kind_Map default: panic("unreachable") } } -func (n *_TypeNameOrInlineDefn__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeNameOrInlineDefn__Repr) LookupByString(key string) (datamodel.Node, error) { switch n.tag { case 2: return n.x2.Representation().LookupByString(key) default: - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: n.Kind()} + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupByString", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: n.Kind()} } } -func (n *_TypeNameOrInlineDefn__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeNameOrInlineDefn__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { switch n.tag { case 2: return n.x2.Representation().LookupByNode(key) default: - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_Recursive, ActualKind: n.Kind()} + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupByNode", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: n.Kind()} } } -func (n *_TypeNameOrInlineDefn__Repr) LookupByIndex(idx int64) (ipld.Node, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: n.Kind()} +func (n *_TypeNameOrInlineDefn__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupByIndex", AppropriateKind: datamodel.KindSet_JustList, ActualKind: n.Kind()} } -func (n *_TypeNameOrInlineDefn__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n *_TypeNameOrInlineDefn__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { switch n.tag { case 2: return n.x2.Representation().LookupBySegment(seg) default: - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: n.Kind()} + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "LookupBySegment", AppropriateKind: datamodel.KindSet_Recursive, ActualKind: n.Kind()} } } -func (n *_TypeNameOrInlineDefn__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeNameOrInlineDefn__Repr) MapIterator() datamodel.MapIterator { switch n.tag { case 2: return n.x2.Representation().MapIterator() @@ -34644,7 +34644,7 @@ func (n *_TypeNameOrInlineDefn__Repr) MapIterator() ipld.MapIterator { return nil } } -func (n *_TypeNameOrInlineDefn__Repr) ListIterator() ipld.ListIterator { +func (n *_TypeNameOrInlineDefn__Repr) ListIterator() datamodel.ListIterator { return nil } func (n *_TypeNameOrInlineDefn__Repr) Length() int64 { @@ -34662,35 +34662,35 @@ func (n *_TypeNameOrInlineDefn__Repr) IsNull() bool { return false } func (n *_TypeNameOrInlineDefn__Repr) AsBool() (bool, error) { - return false, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: n.Kind()} + return false, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsBool", AppropriateKind: datamodel.KindSet_JustBool, ActualKind: n.Kind()} } func (n *_TypeNameOrInlineDefn__Repr) AsInt() (int64, error) { - return 0, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: n.Kind()} + return 0, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsInt", AppropriateKind: datamodel.KindSet_JustInt, ActualKind: n.Kind()} } func (n *_TypeNameOrInlineDefn__Repr) AsFloat() (float64, error) { - return 0, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: n.Kind()} + return 0, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsFloat", AppropriateKind: datamodel.KindSet_JustFloat, ActualKind: n.Kind()} } func (n *_TypeNameOrInlineDefn__Repr) AsString() (string, error) { switch n.tag { case 1: return n.x1.Representation().AsString() default: - return "", ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: n.Kind()} + return "", datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsString", AppropriateKind: datamodel.KindSet_JustString, ActualKind: n.Kind()} } } func (n *_TypeNameOrInlineDefn__Repr) AsBytes() ([]byte, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: n.Kind()} + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsBytes", AppropriateKind: datamodel.KindSet_JustBytes, ActualKind: n.Kind()} } -func (n *_TypeNameOrInlineDefn__Repr) AsLink() (ipld.Link, error) { - return nil, ipld.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: n.Kind()} +func (n *_TypeNameOrInlineDefn__Repr) AsLink() (datamodel.Link, error) { + return nil, datamodel.ErrWrongKind{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", MethodName: "AsLink", AppropriateKind: datamodel.KindSet_JustLink, ActualKind: n.Kind()} } -func (_TypeNameOrInlineDefn__Repr) Prototype() ipld.NodePrototype { +func (_TypeNameOrInlineDefn__Repr) Prototype() datamodel.NodePrototype { return _TypeNameOrInlineDefn__ReprPrototype{} } type _TypeNameOrInlineDefn__ReprPrototype struct{} -func (_TypeNameOrInlineDefn__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeNameOrInlineDefn__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeNameOrInlineDefn__ReprBuilder nb.Reset() return &nb @@ -34700,7 +34700,7 @@ type _TypeNameOrInlineDefn__ReprBuilder struct { _TypeNameOrInlineDefn__ReprAssembler } -func (nb *_TypeNameOrInlineDefn__ReprBuilder) Build() ipld.Node { +func (nb *_TypeNameOrInlineDefn__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -34733,7 +34733,7 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) reset() { } na.ca = 0 } -func (na *_TypeNameOrInlineDefn__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_TypeNameOrInlineDefn__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -34749,7 +34749,7 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) BeginMap(sizeHint int64) (ipld.M na.ca2.m = na.m return na.ca2.BeginMap(sizeHint) } -func (na *_TypeNameOrInlineDefn__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (na *_TypeNameOrInlineDefn__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -34819,7 +34819,7 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignBytes(v []byte) error { } return schema.ErrNotUnionStructure{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", Detail: "AssignBytes called but is not valid for any of the kinds that are valid members of this union"} } -func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignLink(v ipld.Link) error { +func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignLink(v datamodel.Link) error { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -34828,7 +34828,7 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignLink(v ipld.Link) error { } return schema.ErrNotUnionStructure{TypeName: "schemadmt.TypeNameOrInlineDefn.Repr", Detail: "AssignLink called but is not valid for any of the kinds that are valid members of this union"} } -func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -34849,22 +34849,22 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignNode(v ipld.Node) error { return nil } switch v.Kind() { - case ipld.Kind_Bool: + case datamodel.Kind_Bool: v2, _ := v.AsBool() return na.AssignBool(v2) - case ipld.Kind_Int: + case datamodel.Kind_Int: v2, _ := v.AsInt() return na.AssignInt(v2) - case ipld.Kind_Float: + case datamodel.Kind_Float: v2, _ := v.AsFloat() return na.AssignFloat(v2) - case ipld.Kind_String: + case datamodel.Kind_String: v2, _ := v.AsString() return na.AssignString(v2) - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: v2, _ := v.AsBytes() return na.AssignBytes(v2) - case ipld.Kind_Map: + case datamodel.Kind_Map: na, err := na.BeginMap(v.Length()) if err != nil { return err @@ -34883,7 +34883,7 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignNode(v ipld.Node) error { } } return na.Finish() - case ipld.Kind_List: + case datamodel.Kind_List: na, err := na.BeginList(v.Length()) if err != nil { return err @@ -34899,14 +34899,14 @@ func (na *_TypeNameOrInlineDefn__ReprAssembler) AssignNode(v ipld.Node) error { } } return na.Finish() - case ipld.Kind_Link: + case datamodel.Kind_Link: v2, _ := v.AsLink() return na.AssignLink(v2) default: panic("unreachable") } } -func (na *_TypeNameOrInlineDefn__ReprAssembler) Prototype() ipld.NodePrototype { +func (na *_TypeNameOrInlineDefn__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeNameOrInlineDefn__ReprPrototype{} } @@ -34925,12 +34925,12 @@ func (m MaybeTypeString) IsAbsent() bool { func (m MaybeTypeString) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeString) AsNode() ipld.Node { +func (m MaybeTypeString) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -34945,32 +34945,32 @@ func (m MaybeTypeString) Must() TypeString { } var () -var _ ipld.Node = (TypeString)(&_TypeString{}) +var _ datamodel.Node = (TypeString)(&_TypeString{}) var _ schema.TypedNode = (TypeString)(&_TypeString{}) -func (TypeString) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeString) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeString) LookupByString(key string) (ipld.Node, error) { +func (n TypeString) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeString) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeString) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeString) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeString) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeString"}.LookupByIndex(0) } -func (n TypeString) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeString) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeString) MapIterator() ipld.MapIterator { +func (n TypeString) MapIterator() datamodel.MapIterator { return &_TypeString__MapItr{n, 0} } @@ -34979,15 +34979,15 @@ type _TypeString__MapItr struct { idx int } -func (itr *_TypeString__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeString__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeString__MapItr) Done() bool { return itr.idx >= 0 } -func (TypeString) ListIterator() ipld.ListIterator { +func (TypeString) ListIterator() datamodel.ListIterator { return nil } func (TypeString) Length() int64 { @@ -35014,16 +35014,16 @@ func (TypeString) AsString() (string, error) { func (TypeString) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeString"}.AsBytes() } -func (TypeString) AsLink() (ipld.Link, error) { +func (TypeString) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeString"}.AsLink() } -func (TypeString) Prototype() ipld.NodePrototype { +func (TypeString) Prototype() datamodel.NodePrototype { return _TypeString__Prototype{} } type _TypeString__Prototype struct{} -func (_TypeString__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeString__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeString__Builder nb.Reset() return &nb @@ -35033,7 +35033,7 @@ type _TypeString__Builder struct { _TypeString__Assembler } -func (nb *_TypeString__Builder) Build() ipld.Node { +func (nb *_TypeString__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -35064,7 +35064,7 @@ var ( fieldBits__TypeString_sufficient = 0 ) -func (na *_TypeString__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeString__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -35077,7 +35077,7 @@ func (na *_TypeString__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeString__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeString__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeString"}.BeginList(0) } func (na *_TypeString__Assembler) AssignNull() error { @@ -35109,10 +35109,10 @@ func (_TypeString__Assembler) AssignString(string) error { func (_TypeString__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeString"}.AssignBytes(nil) } -func (_TypeString__Assembler) AssignLink(ipld.Link) error { +func (_TypeString__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeString"}.AssignLink(nil) } -func (na *_TypeString__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeString__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -35132,8 +35132,8 @@ func (na *_TypeString__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeString", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeString", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -35150,7 +35150,7 @@ func (na *_TypeString__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeString__Assembler) Prototype() ipld.NodePrototype { +func (_TypeString__Assembler) Prototype() datamodel.NodePrototype { return _TypeString__Prototype{} } func (ma *_TypeString__Assembler) valueFinishTidy() bool { @@ -35159,7 +35159,7 @@ func (ma *_TypeString__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeString__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeString__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -35174,9 +35174,9 @@ func (ma *_TypeString__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, e case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeString", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeString", Key: &_String{k}} } -func (ma *_TypeString__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeString__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -35194,7 +35194,7 @@ func (ma *_TypeString__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeString__KeyAssembler)(ma) } -func (ma *_TypeString__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeString__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -35229,26 +35229,26 @@ func (ma *_TypeString__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeString_sufficient != fieldBits__TypeString_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeString__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeString__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeString__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeString__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeString__KeyAssembler _TypeString__Assembler -func (_TypeString__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeString__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.KeyAssembler"}.BeginMap(0) } -func (_TypeString__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeString__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.KeyAssembler"}.BeginList(0) } func (na *_TypeString__KeyAssembler) AssignNull() error { @@ -35269,60 +35269,60 @@ func (ka *_TypeString__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeString", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeString", Key: &_String{k}} } } func (_TypeString__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.KeyAssembler"}.AssignBytes(nil) } -func (_TypeString__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeString__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeString__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeString__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeString__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeString__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeString) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeString) Representation() ipld.Node { +func (n TypeString) Representation() datamodel.Node { return (*_TypeString__Repr)(n) } type _TypeString__Repr _TypeString var () -var _ ipld.Node = &_TypeString__Repr{} +var _ datamodel.Node = &_TypeString__Repr{} -func (_TypeString__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeString__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeString__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeString__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeString__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeString__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeString__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeString__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeString.Repr"}.LookupByIndex(0) } -func (n _TypeString__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeString__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeString__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeString__Repr) MapIterator() datamodel.MapIterator { return &_TypeString__ReprMapItr{n, 0} } @@ -35331,14 +35331,14 @@ type _TypeString__ReprMapItr struct { idx int } -func (itr *_TypeString__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_TypeString__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_TypeString__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_TypeString__Repr) ListIterator() ipld.ListIterator { +func (_TypeString__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeString__Repr) Length() int64 { @@ -35366,16 +35366,16 @@ func (_TypeString__Repr) AsString() (string, error) { func (_TypeString__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeString.Repr"}.AsBytes() } -func (_TypeString__Repr) AsLink() (ipld.Link, error) { +func (_TypeString__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeString.Repr"}.AsLink() } -func (_TypeString__Repr) Prototype() ipld.NodePrototype { +func (_TypeString__Repr) Prototype() datamodel.NodePrototype { return _TypeString__ReprPrototype{} } type _TypeString__ReprPrototype struct{} -func (_TypeString__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeString__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeString__ReprBuilder nb.Reset() return &nb @@ -35385,7 +35385,7 @@ type _TypeString__ReprBuilder struct { _TypeString__ReprAssembler } -func (nb *_TypeString__ReprBuilder) Build() ipld.Node { +func (nb *_TypeString__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -35411,7 +35411,7 @@ func (na *_TypeString__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_TypeString__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeString__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -35424,7 +35424,7 @@ func (na *_TypeString__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) } return na, nil } -func (_TypeString__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeString__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeString.Repr"}.BeginList(0) } func (na *_TypeString__ReprAssembler) AssignNull() error { @@ -35456,10 +35456,10 @@ func (_TypeString__ReprAssembler) AssignString(string) error { func (_TypeString__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeString.Repr"}.AssignBytes(nil) } -func (_TypeString__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeString__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeString.Repr"}.AssignLink(nil) } -func (na *_TypeString__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeString__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -35479,8 +35479,8 @@ func (na *_TypeString__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeString.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeString.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -35497,7 +35497,7 @@ func (na *_TypeString__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeString__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeString__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeString__ReprPrototype{} } func (ma *_TypeString__ReprAssembler) valueFinishTidy() bool { @@ -35506,7 +35506,7 @@ func (ma *_TypeString__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeString__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeString__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -35521,9 +35521,9 @@ func (ma *_TypeString__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssemble case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeString.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeString.Repr", Key: &_String{k}} } -func (ma *_TypeString__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeString__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -35541,7 +35541,7 @@ func (ma *_TypeString__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeString__ReprKeyAssembler)(ma) } -func (ma *_TypeString__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeString__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -35576,26 +35576,26 @@ func (ma *_TypeString__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeString_sufficient != fieldBits__TypeString_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeString__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeString__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeString__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeString__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeString__ReprKeyAssembler _TypeString__ReprAssembler -func (_TypeString__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeString__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeString__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeString__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeString__ReprKeyAssembler) AssignNull() error { @@ -35614,22 +35614,22 @@ func (ka *_TypeString__ReprKeyAssembler) AssignString(k string) error { if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeString.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeString.Repr", Key: &_String{k}} } func (_TypeString__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeString__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeString__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeString.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeString__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeString__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeString__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeString__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -35655,12 +35655,12 @@ func (m MaybeTypeStruct) IsAbsent() bool { func (m MaybeTypeStruct) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeStruct) AsNode() ipld.Node { +func (m MaybeTypeStruct) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -35678,36 +35678,36 @@ var ( fieldName__TypeStruct_Fields = _String{"fields"} fieldName__TypeStruct_Representation = _String{"representation"} ) -var _ ipld.Node = (TypeStruct)(&_TypeStruct{}) +var _ datamodel.Node = (TypeStruct)(&_TypeStruct{}) var _ schema.TypedNode = (TypeStruct)(&_TypeStruct{}) -func (TypeStruct) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeStruct) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeStruct) LookupByString(key string) (ipld.Node, error) { +func (n TypeStruct) LookupByString(key string) (datamodel.Node, error) { switch key { case "fields": return &n.fields, nil case "representation": return &n.representation, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeStruct) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeStruct) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeStruct) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeStruct) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeStruct"}.LookupByIndex(0) } -func (n TypeStruct) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeStruct) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeStruct) MapIterator() ipld.MapIterator { +func (n TypeStruct) MapIterator() datamodel.MapIterator { return &_TypeStruct__MapItr{n, 0} } @@ -35716,9 +35716,9 @@ type _TypeStruct__MapItr struct { idx int } -func (itr *_TypeStruct__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeStruct__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -35737,7 +35737,7 @@ func (itr *_TypeStruct__MapItr) Done() bool { return itr.idx >= 2 } -func (TypeStruct) ListIterator() ipld.ListIterator { +func (TypeStruct) ListIterator() datamodel.ListIterator { return nil } func (TypeStruct) Length() int64 { @@ -35764,16 +35764,16 @@ func (TypeStruct) AsString() (string, error) { func (TypeStruct) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeStruct"}.AsBytes() } -func (TypeStruct) AsLink() (ipld.Link, error) { +func (TypeStruct) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeStruct"}.AsLink() } -func (TypeStruct) Prototype() ipld.NodePrototype { +func (TypeStruct) Prototype() datamodel.NodePrototype { return _TypeStruct__Prototype{} } type _TypeStruct__Prototype struct{} -func (_TypeStruct__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeStruct__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeStruct__Builder nb.Reset() return &nb @@ -35783,7 +35783,7 @@ type _TypeStruct__Builder struct { _TypeStruct__Assembler } -func (nb *_TypeStruct__Builder) Build() ipld.Node { +func (nb *_TypeStruct__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -35820,7 +35820,7 @@ var ( fieldBits__TypeStruct_sufficient = 0 + 1<<0 + 1<<1 ) -func (na *_TypeStruct__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeStruct__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -35833,7 +35833,7 @@ func (na *_TypeStruct__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeStruct__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeStruct__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeStruct"}.BeginList(0) } func (na *_TypeStruct__Assembler) AssignNull() error { @@ -35865,10 +35865,10 @@ func (_TypeStruct__Assembler) AssignString(string) error { func (_TypeStruct__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeStruct"}.AssignBytes(nil) } -func (_TypeStruct__Assembler) AssignLink(ipld.Link) error { +func (_TypeStruct__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeStruct"}.AssignLink(nil) } -func (na *_TypeStruct__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeStruct__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -35888,8 +35888,8 @@ func (na *_TypeStruct__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeStruct", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeStruct", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -35906,7 +35906,7 @@ func (na *_TypeStruct__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeStruct__Assembler) Prototype() ipld.NodePrototype { +func (_TypeStruct__Assembler) Prototype() datamodel.NodePrototype { return _TypeStruct__Prototype{} } func (ma *_TypeStruct__Assembler) valueFinishTidy() bool { @@ -35935,7 +35935,7 @@ func (ma *_TypeStruct__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeStruct__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeStruct__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -35953,7 +35953,7 @@ func (ma *_TypeStruct__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, e switch k { case "fields": if ma.s&fieldBit__TypeStruct_Fields != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields} } ma.s += fieldBit__TypeStruct_Fields ma.state = maState_midValue @@ -35963,7 +35963,7 @@ func (ma *_TypeStruct__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, e return &ma.ca_fields, nil case "representation": if ma.s&fieldBit__TypeStruct_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation} } ma.s += fieldBit__TypeStruct_Representation ma.state = maState_midValue @@ -35972,9 +35972,9 @@ func (ma *_TypeStruct__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, e ma.ca_representation.m = &ma.cm return &ma.ca_representation, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeStruct", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeStruct", Key: &_String{k}} } -func (ma *_TypeStruct__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeStruct__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -35992,7 +35992,7 @@ func (ma *_TypeStruct__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeStruct__KeyAssembler)(ma) } -func (ma *_TypeStruct__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeStruct__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -36035,7 +36035,7 @@ func (ma *_TypeStruct__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeStruct_sufficient != fieldBits__TypeStruct_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeStruct_Fields == 0 { err.Missing = append(err.Missing, "fields") } @@ -36048,19 +36048,19 @@ func (ma *_TypeStruct__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeStruct__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeStruct__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeStruct__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeStruct__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeStruct__KeyAssembler _TypeStruct__Assembler -func (_TypeStruct__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeStruct__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.KeyAssembler"}.BeginMap(0) } -func (_TypeStruct__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeStruct__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.KeyAssembler"}.BeginList(0) } func (na *_TypeStruct__KeyAssembler) AssignNull() error { @@ -36082,7 +36082,7 @@ func (ka *_TypeStruct__KeyAssembler) AssignString(k string) error { switch k { case "fields": if ka.s&fieldBit__TypeStruct_Fields != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields} } ka.s += fieldBit__TypeStruct_Fields ka.state = maState_expectValue @@ -36090,36 +36090,36 @@ func (ka *_TypeStruct__KeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeStruct_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation} } ka.s += fieldBit__TypeStruct_Representation ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeStruct", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeStruct", Key: &_String{k}} } } func (_TypeStruct__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.KeyAssembler"}.AssignBytes(nil) } -func (_TypeStruct__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeStruct__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeStruct__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeStruct__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeStruct__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeStruct__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeStruct) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeStruct) Representation() ipld.Node { +func (n TypeStruct) Representation() datamodel.Node { return (*_TypeStruct__Repr)(n) } @@ -36129,35 +36129,35 @@ var ( fieldName__TypeStruct_Fields_serial = _String{"fields"} fieldName__TypeStruct_Representation_serial = _String{"representation"} ) -var _ ipld.Node = &_TypeStruct__Repr{} +var _ datamodel.Node = &_TypeStruct__Repr{} -func (_TypeStruct__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeStruct__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeStruct__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeStruct__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "fields": return n.fields.Representation(), nil case "representation": return n.representation.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeStruct__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeStruct__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeStruct__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeStruct__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeStruct.Repr"}.LookupByIndex(0) } -func (n _TypeStruct__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeStruct__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeStruct__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeStruct__Repr) MapIterator() datamodel.MapIterator { return &_TypeStruct__ReprMapItr{n, 0} } @@ -36166,9 +36166,9 @@ type _TypeStruct__ReprMapItr struct { idx int } -func (itr *_TypeStruct__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeStruct__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -36186,7 +36186,7 @@ func (itr *_TypeStruct__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_TypeStruct__ReprMapItr) Done() bool { return itr.idx >= 2 } -func (_TypeStruct__Repr) ListIterator() ipld.ListIterator { +func (_TypeStruct__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeStruct__Repr) Length() int64 { @@ -36214,16 +36214,16 @@ func (_TypeStruct__Repr) AsString() (string, error) { func (_TypeStruct__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeStruct.Repr"}.AsBytes() } -func (_TypeStruct__Repr) AsLink() (ipld.Link, error) { +func (_TypeStruct__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeStruct.Repr"}.AsLink() } -func (_TypeStruct__Repr) Prototype() ipld.NodePrototype { +func (_TypeStruct__Repr) Prototype() datamodel.NodePrototype { return _TypeStruct__ReprPrototype{} } type _TypeStruct__ReprPrototype struct{} -func (_TypeStruct__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeStruct__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeStruct__ReprBuilder nb.Reset() return &nb @@ -36233,7 +36233,7 @@ type _TypeStruct__ReprBuilder struct { _TypeStruct__ReprAssembler } -func (nb *_TypeStruct__ReprBuilder) Build() ipld.Node { +func (nb *_TypeStruct__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -36263,7 +36263,7 @@ func (na *_TypeStruct__ReprAssembler) reset() { na.ca_fields.reset() na.ca_representation.reset() } -func (na *_TypeStruct__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeStruct__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -36276,7 +36276,7 @@ func (na *_TypeStruct__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) } return na, nil } -func (_TypeStruct__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeStruct__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeStruct.Repr"}.BeginList(0) } func (na *_TypeStruct__ReprAssembler) AssignNull() error { @@ -36308,10 +36308,10 @@ func (_TypeStruct__ReprAssembler) AssignString(string) error { func (_TypeStruct__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeStruct.Repr"}.AssignBytes(nil) } -func (_TypeStruct__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeStruct__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeStruct.Repr"}.AssignLink(nil) } -func (na *_TypeStruct__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeStruct__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -36331,8 +36331,8 @@ func (na *_TypeStruct__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeStruct.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeStruct.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -36349,7 +36349,7 @@ func (na *_TypeStruct__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeStruct__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeStruct__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeStruct__ReprPrototype{} } func (ma *_TypeStruct__ReprAssembler) valueFinishTidy() bool { @@ -36376,7 +36376,7 @@ func (ma *_TypeStruct__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeStruct__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeStruct__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -36394,7 +36394,7 @@ func (ma *_TypeStruct__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssemble switch k { case "fields": if ma.s&fieldBit__TypeStruct_Fields != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields_serial} } ma.s += fieldBit__TypeStruct_Fields ma.state = maState_midValue @@ -36404,7 +36404,7 @@ func (ma *_TypeStruct__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssemble return &ma.ca_fields, nil case "representation": if ma.s&fieldBit__TypeStruct_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation_serial} } ma.s += fieldBit__TypeStruct_Representation ma.state = maState_midValue @@ -36414,9 +36414,9 @@ func (ma *_TypeStruct__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssemble return &ma.ca_representation, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeStruct.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeStruct.Repr", Key: &_String{k}} } -func (ma *_TypeStruct__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeStruct__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -36434,7 +36434,7 @@ func (ma *_TypeStruct__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeStruct__ReprKeyAssembler)(ma) } -func (ma *_TypeStruct__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeStruct__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -36477,7 +36477,7 @@ func (ma *_TypeStruct__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeStruct_sufficient != fieldBits__TypeStruct_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeStruct_Fields == 0 { err.Missing = append(err.Missing, "fields") } @@ -36490,19 +36490,19 @@ func (ma *_TypeStruct__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeStruct__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeStruct__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeStruct__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeStruct__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeStruct__ReprKeyAssembler _TypeStruct__ReprAssembler -func (_TypeStruct__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeStruct__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeStruct__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeStruct__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeStruct__ReprKeyAssembler) AssignNull() error { @@ -36524,7 +36524,7 @@ func (ka *_TypeStruct__ReprKeyAssembler) AssignString(k string) error { switch k { case "fields": if ka.s&fieldBit__TypeStruct_Fields != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Fields_serial} } ka.s += fieldBit__TypeStruct_Fields ka.state = maState_expectValue @@ -36532,29 +36532,29 @@ func (ka *_TypeStruct__ReprKeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeStruct_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeStruct_Representation_serial} } ka.s += fieldBit__TypeStruct_Representation ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeStruct.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeStruct.Repr", Key: &_String{k}} } func (_TypeStruct__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeStruct__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeStruct__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeStruct.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeStruct__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeStruct__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeStruct__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeStruct__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -36580,12 +36580,12 @@ func (m MaybeTypeUnion) IsAbsent() bool { func (m MaybeTypeUnion) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeTypeUnion) AsNode() ipld.Node { +func (m MaybeTypeUnion) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -36603,36 +36603,36 @@ var ( fieldName__TypeUnion_Members = _String{"members"} fieldName__TypeUnion_Representation = _String{"representation"} ) -var _ ipld.Node = (TypeUnion)(&_TypeUnion{}) +var _ datamodel.Node = (TypeUnion)(&_TypeUnion{}) var _ schema.TypedNode = (TypeUnion)(&_TypeUnion{}) -func (TypeUnion) Kind() ipld.Kind { - return ipld.Kind_Map +func (TypeUnion) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n TypeUnion) LookupByString(key string) (ipld.Node, error) { +func (n TypeUnion) LookupByString(key string) (datamodel.Node, error) { switch key { case "members": return &n.members, nil case "representation": return &n.representation, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n TypeUnion) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n TypeUnion) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (TypeUnion) LookupByIndex(idx int64) (ipld.Node, error) { +func (TypeUnion) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeUnion"}.LookupByIndex(0) } -func (n TypeUnion) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n TypeUnion) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n TypeUnion) MapIterator() ipld.MapIterator { +func (n TypeUnion) MapIterator() datamodel.MapIterator { return &_TypeUnion__MapItr{n, 0} } @@ -36641,9 +36641,9 @@ type _TypeUnion__MapItr struct { idx int } -func (itr *_TypeUnion__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeUnion__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -36662,7 +36662,7 @@ func (itr *_TypeUnion__MapItr) Done() bool { return itr.idx >= 2 } -func (TypeUnion) ListIterator() ipld.ListIterator { +func (TypeUnion) ListIterator() datamodel.ListIterator { return nil } func (TypeUnion) Length() int64 { @@ -36689,16 +36689,16 @@ func (TypeUnion) AsString() (string, error) { func (TypeUnion) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeUnion"}.AsBytes() } -func (TypeUnion) AsLink() (ipld.Link, error) { +func (TypeUnion) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeUnion"}.AsLink() } -func (TypeUnion) Prototype() ipld.NodePrototype { +func (TypeUnion) Prototype() datamodel.NodePrototype { return _TypeUnion__Prototype{} } type _TypeUnion__Prototype struct{} -func (_TypeUnion__Prototype) NewBuilder() ipld.NodeBuilder { +func (_TypeUnion__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeUnion__Builder nb.Reset() return &nb @@ -36708,7 +36708,7 @@ type _TypeUnion__Builder struct { _TypeUnion__Assembler } -func (nb *_TypeUnion__Builder) Build() ipld.Node { +func (nb *_TypeUnion__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -36745,7 +36745,7 @@ var ( fieldBits__TypeUnion_sufficient = 0 + 1<<0 + 1<<1 ) -func (na *_TypeUnion__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeUnion__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -36758,7 +36758,7 @@ func (na *_TypeUnion__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_TypeUnion__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeUnion__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeUnion"}.BeginList(0) } func (na *_TypeUnion__Assembler) AssignNull() error { @@ -36790,10 +36790,10 @@ func (_TypeUnion__Assembler) AssignString(string) error { func (_TypeUnion__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeUnion"}.AssignBytes(nil) } -func (_TypeUnion__Assembler) AssignLink(ipld.Link) error { +func (_TypeUnion__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeUnion"}.AssignLink(nil) } -func (na *_TypeUnion__Assembler) AssignNode(v ipld.Node) error { +func (na *_TypeUnion__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -36813,8 +36813,8 @@ func (na *_TypeUnion__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeUnion", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeUnion", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -36831,7 +36831,7 @@ func (na *_TypeUnion__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeUnion__Assembler) Prototype() ipld.NodePrototype { +func (_TypeUnion__Assembler) Prototype() datamodel.NodePrototype { return _TypeUnion__Prototype{} } func (ma *_TypeUnion__Assembler) valueFinishTidy() bool { @@ -36860,7 +36860,7 @@ func (ma *_TypeUnion__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeUnion__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeUnion__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -36878,7 +36878,7 @@ func (ma *_TypeUnion__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er switch k { case "members": if ma.s&fieldBit__TypeUnion_Members != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members} } ma.s += fieldBit__TypeUnion_Members ma.state = maState_midValue @@ -36888,7 +36888,7 @@ func (ma *_TypeUnion__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er return &ma.ca_members, nil case "representation": if ma.s&fieldBit__TypeUnion_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation} } ma.s += fieldBit__TypeUnion_Representation ma.state = maState_midValue @@ -36897,9 +36897,9 @@ func (ma *_TypeUnion__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, er ma.ca_representation.m = &ma.cm return &ma.ca_representation, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeUnion", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeUnion", Key: &_String{k}} } -func (ma *_TypeUnion__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeUnion__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -36917,7 +36917,7 @@ func (ma *_TypeUnion__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeUnion__KeyAssembler)(ma) } -func (ma *_TypeUnion__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeUnion__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -36960,7 +36960,7 @@ func (ma *_TypeUnion__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeUnion_sufficient != fieldBits__TypeUnion_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeUnion_Members == 0 { err.Missing = append(err.Missing, "members") } @@ -36973,19 +36973,19 @@ func (ma *_TypeUnion__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeUnion__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeUnion__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeUnion__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeUnion__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _TypeUnion__KeyAssembler _TypeUnion__Assembler -func (_TypeUnion__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeUnion__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.KeyAssembler"}.BeginMap(0) } -func (_TypeUnion__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeUnion__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.KeyAssembler"}.BeginList(0) } func (na *_TypeUnion__KeyAssembler) AssignNull() error { @@ -37007,7 +37007,7 @@ func (ka *_TypeUnion__KeyAssembler) AssignString(k string) error { switch k { case "members": if ka.s&fieldBit__TypeUnion_Members != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members} } ka.s += fieldBit__TypeUnion_Members ka.state = maState_expectValue @@ -37015,36 +37015,36 @@ func (ka *_TypeUnion__KeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeUnion_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation} } ka.s += fieldBit__TypeUnion_Representation ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeUnion", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeUnion", Key: &_String{k}} } } func (_TypeUnion__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.KeyAssembler"}.AssignBytes(nil) } -func (_TypeUnion__KeyAssembler) AssignLink(ipld.Link) error { +func (_TypeUnion__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeUnion__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeUnion__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeUnion__KeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeUnion__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (TypeUnion) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n TypeUnion) Representation() ipld.Node { +func (n TypeUnion) Representation() datamodel.Node { return (*_TypeUnion__Repr)(n) } @@ -37054,35 +37054,35 @@ var ( fieldName__TypeUnion_Members_serial = _String{"members"} fieldName__TypeUnion_Representation_serial = _String{"representation"} ) -var _ ipld.Node = &_TypeUnion__Repr{} +var _ datamodel.Node = &_TypeUnion__Repr{} -func (_TypeUnion__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_TypeUnion__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_TypeUnion__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_TypeUnion__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "members": return n.members.Representation(), nil case "representation": return n.representation.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_TypeUnion__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_TypeUnion__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_TypeUnion__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_TypeUnion__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.TypeUnion.Repr"}.LookupByIndex(0) } -func (n _TypeUnion__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _TypeUnion__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_TypeUnion__Repr) MapIterator() ipld.MapIterator { +func (n *_TypeUnion__Repr) MapIterator() datamodel.MapIterator { return &_TypeUnion__ReprMapItr{n, 0} } @@ -37091,9 +37091,9 @@ type _TypeUnion__ReprMapItr struct { idx int } -func (itr *_TypeUnion__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_TypeUnion__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -37111,7 +37111,7 @@ func (itr *_TypeUnion__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { func (itr *_TypeUnion__ReprMapItr) Done() bool { return itr.idx >= 2 } -func (_TypeUnion__Repr) ListIterator() ipld.ListIterator { +func (_TypeUnion__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_TypeUnion__Repr) Length() int64 { @@ -37139,16 +37139,16 @@ func (_TypeUnion__Repr) AsString() (string, error) { func (_TypeUnion__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.TypeUnion.Repr"}.AsBytes() } -func (_TypeUnion__Repr) AsLink() (ipld.Link, error) { +func (_TypeUnion__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.TypeUnion.Repr"}.AsLink() } -func (_TypeUnion__Repr) Prototype() ipld.NodePrototype { +func (_TypeUnion__Repr) Prototype() datamodel.NodePrototype { return _TypeUnion__ReprPrototype{} } type _TypeUnion__ReprPrototype struct{} -func (_TypeUnion__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_TypeUnion__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _TypeUnion__ReprBuilder nb.Reset() return &nb @@ -37158,7 +37158,7 @@ type _TypeUnion__ReprBuilder struct { _TypeUnion__ReprAssembler } -func (nb *_TypeUnion__ReprBuilder) Build() ipld.Node { +func (nb *_TypeUnion__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -37188,7 +37188,7 @@ func (na *_TypeUnion__ReprAssembler) reset() { na.ca_members.reset() na.ca_representation.reset() } -func (na *_TypeUnion__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_TypeUnion__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -37201,7 +37201,7 @@ func (na *_TypeUnion__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) } return na, nil } -func (_TypeUnion__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeUnion__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.TypeUnion.Repr"}.BeginList(0) } func (na *_TypeUnion__ReprAssembler) AssignNull() error { @@ -37233,10 +37233,10 @@ func (_TypeUnion__ReprAssembler) AssignString(string) error { func (_TypeUnion__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeUnion.Repr"}.AssignBytes(nil) } -func (_TypeUnion__ReprAssembler) AssignLink(ipld.Link) error { +func (_TypeUnion__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.TypeUnion.Repr"}.AssignLink(nil) } -func (na *_TypeUnion__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_TypeUnion__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -37256,8 +37256,8 @@ func (na *_TypeUnion__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.TypeUnion.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.TypeUnion.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -37274,7 +37274,7 @@ func (na *_TypeUnion__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_TypeUnion__ReprAssembler) Prototype() ipld.NodePrototype { +func (_TypeUnion__ReprAssembler) Prototype() datamodel.NodePrototype { return _TypeUnion__ReprPrototype{} } func (ma *_TypeUnion__ReprAssembler) valueFinishTidy() bool { @@ -37301,7 +37301,7 @@ func (ma *_TypeUnion__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_TypeUnion__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_TypeUnion__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -37319,7 +37319,7 @@ func (ma *_TypeUnion__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler switch k { case "members": if ma.s&fieldBit__TypeUnion_Members != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members_serial} } ma.s += fieldBit__TypeUnion_Members ma.state = maState_midValue @@ -37329,7 +37329,7 @@ func (ma *_TypeUnion__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler return &ma.ca_members, nil case "representation": if ma.s&fieldBit__TypeUnion_Representation != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation_serial} } ma.s += fieldBit__TypeUnion_Representation ma.state = maState_midValue @@ -37339,9 +37339,9 @@ func (ma *_TypeUnion__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler return &ma.ca_representation, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.TypeUnion.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.TypeUnion.Repr", Key: &_String{k}} } -func (ma *_TypeUnion__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_TypeUnion__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -37359,7 +37359,7 @@ func (ma *_TypeUnion__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_TypeUnion__ReprKeyAssembler)(ma) } -func (ma *_TypeUnion__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_TypeUnion__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -37402,7 +37402,7 @@ func (ma *_TypeUnion__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__TypeUnion_sufficient != fieldBits__TypeUnion_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__TypeUnion_Members == 0 { err.Missing = append(err.Missing, "members") } @@ -37415,19 +37415,19 @@ func (ma *_TypeUnion__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_TypeUnion__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_TypeUnion__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_TypeUnion__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_TypeUnion__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _TypeUnion__ReprKeyAssembler _TypeUnion__ReprAssembler -func (_TypeUnion__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_TypeUnion__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.Repr.KeyAssembler"}.BeginMap(0) } -func (_TypeUnion__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_TypeUnion__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.Repr.KeyAssembler"}.BeginList(0) } func (na *_TypeUnion__ReprKeyAssembler) AssignNull() error { @@ -37449,7 +37449,7 @@ func (ka *_TypeUnion__ReprKeyAssembler) AssignString(k string) error { switch k { case "members": if ka.s&fieldBit__TypeUnion_Members != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Members_serial} } ka.s += fieldBit__TypeUnion_Members ka.state = maState_expectValue @@ -37457,29 +37457,29 @@ func (ka *_TypeUnion__ReprKeyAssembler) AssignString(k string) error { return nil case "representation": if ka.s&fieldBit__TypeUnion_Representation != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__TypeUnion_Representation_serial} } ka.s += fieldBit__TypeUnion_Representation ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.TypeUnion.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.TypeUnion.Repr", Key: &_String{k}} } func (_TypeUnion__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_TypeUnion__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_TypeUnion__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.TypeUnion.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_TypeUnion__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_TypeUnion__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_TypeUnion__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_TypeUnion__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -37517,12 +37517,12 @@ func (m MaybeUnionRepresentation) IsAbsent() bool { func (m MaybeUnionRepresentation) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation) AsNode() ipld.Node { +func (m MaybeUnionRepresentation) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -37544,62 +37544,62 @@ var ( memberName__UnionRepresentation_UnionRepresentation_StringPrefix = _String{"UnionRepresentation_StringPrefix"} memberName__UnionRepresentation_UnionRepresentation_BytePrefix = _String{"UnionRepresentation_BytePrefix"} ) -var _ ipld.Node = (UnionRepresentation)(&_UnionRepresentation{}) +var _ datamodel.Node = (UnionRepresentation)(&_UnionRepresentation{}) var _ schema.TypedNode = (UnionRepresentation)(&_UnionRepresentation{}) -func (UnionRepresentation) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation) LookupByString(key string) (ipld.Node, error) { +func (n UnionRepresentation) LookupByString(key string) (datamodel.Node, error) { switch key { case "UnionRepresentation_Kinded": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x1, nil case "UnionRepresentation_Keyed": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x2, nil case "UnionRepresentation_Envelope": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x3, nil case "UnionRepresentation_Inline": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x4, nil case "UnionRepresentation_StringPrefix": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x5, nil case "UnionRepresentation_BytePrefix": if n.tag != 6 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x6, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n UnionRepresentation) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (UnionRepresentation) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation"}.LookupByIndex(0) } -func (n UnionRepresentation) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation) MapIterator() ipld.MapIterator { +func (n UnionRepresentation) MapIterator() datamodel.MapIterator { return &_UnionRepresentation__MapItr{n, false} } @@ -37608,9 +37608,9 @@ type _UnionRepresentation__MapItr struct { done bool } -func (itr *_UnionRepresentation__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -37635,7 +37635,7 @@ func (itr *_UnionRepresentation__MapItr) Done() bool { return itr.done } -func (UnionRepresentation) ListIterator() ipld.ListIterator { +func (UnionRepresentation) ListIterator() datamodel.ListIterator { return nil } func (UnionRepresentation) Length() int64 { @@ -37662,16 +37662,16 @@ func (UnionRepresentation) AsString() (string, error) { func (UnionRepresentation) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation"}.AsBytes() } -func (UnionRepresentation) AsLink() (ipld.Link, error) { +func (UnionRepresentation) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation"}.AsLink() } -func (UnionRepresentation) Prototype() ipld.NodePrototype { +func (UnionRepresentation) Prototype() datamodel.NodePrototype { return _UnionRepresentation__Prototype{} } type _UnionRepresentation__Prototype struct{} -func (_UnionRepresentation__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation__Builder nb.Reset() return &nb @@ -37681,7 +37681,7 @@ type _UnionRepresentation__Builder struct { _UnionRepresentation__Assembler } -func (nb *_UnionRepresentation__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -37741,7 +37741,7 @@ func (na *_UnionRepresentation__Assembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_UnionRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -37754,7 +37754,7 @@ func (na *_UnionRepresentation__Assembler) BeginMap(int64) (ipld.MapAssembler, e } return na, nil } -func (_UnionRepresentation__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation"}.BeginList(0) } func (na *_UnionRepresentation__Assembler) AssignNull() error { @@ -37786,10 +37786,10 @@ func (_UnionRepresentation__Assembler) AssignString(string) error { func (_UnionRepresentation__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation"}.AssignBytes(nil) } -func (_UnionRepresentation__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation"}.AssignLink(nil) } -func (na *_UnionRepresentation__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -37809,8 +37809,8 @@ func (na *_UnionRepresentation__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -37827,7 +37827,7 @@ func (na *_UnionRepresentation__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_UnionRepresentation__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation__Prototype{} } func (ma *_UnionRepresentation__Assembler) valueFinishTidy() bool { @@ -37839,7 +37839,7 @@ func (ma *_UnionRepresentation__Assembler) valueFinishTidy() bool { return false } } -func (ma *_UnionRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -37901,9 +37901,9 @@ func (ma *_UnionRepresentation__Assembler) AssembleEntry(k string) (ipld.NodeAss ma.ca6.m = &ma.cm return &ma.ca6, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation", Key: &_String{k}} } -func (ma *_UnionRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -37921,7 +37921,7 @@ func (ma *_UnionRepresentation__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_UnionRepresentation__KeyAssembler)(ma) } -func (ma *_UnionRepresentation__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -37986,10 +37986,10 @@ func (ma *_UnionRepresentation__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "UnionRepresentation_Kinded": return _UnionRepresentation_Kinded__Prototype{} @@ -38010,10 +38010,10 @@ func (ma *_UnionRepresentation__Assembler) ValuePrototype(k string) ipld.NodePro type _UnionRepresentation__KeyAssembler _UnionRepresentation__Assembler -func (_UnionRepresentation__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation__KeyAssembler) AssignNull() error { @@ -38067,28 +38067,28 @@ func (ka *_UnionRepresentation__KeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_UnionRepresentation__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation__KeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation__KeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (UnionRepresentation) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation) Representation() ipld.Node { +func (n UnionRepresentation) Representation() datamodel.Node { return (*_UnionRepresentation__Repr)(n) } @@ -38102,61 +38102,61 @@ var ( memberName__UnionRepresentation_UnionRepresentation_StringPrefix_serial = _String{"stringprefix"} memberName__UnionRepresentation_UnionRepresentation_BytePrefix_serial = _String{"byteprefix"} ) -var _ ipld.Node = &_UnionRepresentation__Repr{} +var _ datamodel.Node = &_UnionRepresentation__Repr{} -func (_UnionRepresentation__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_UnionRepresentation__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_UnionRepresentation__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "kinded": if n.tag != 1 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x1.Representation(), nil case "keyed": if n.tag != 2 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x2.Representation(), nil case "envelope": if n.tag != 3 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x3.Representation(), nil case "inline": if n.tag != 4 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x4.Representation(), nil case "stringprefix": if n.tag != 5 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x5.Representation(), nil case "byteprefix": if n.tag != 6 { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x6.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_UnionRepresentation__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_UnionRepresentation__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_UnionRepresentation__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_UnionRepresentation__Repr) MapIterator() ipld.MapIterator { +func (n *_UnionRepresentation__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation__ReprMapItr{n, false} } @@ -38165,9 +38165,9 @@ type _UnionRepresentation__ReprMapItr struct { done bool } -func (itr *_UnionRepresentation__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.n.tag { case 1: @@ -38192,7 +38192,7 @@ func (itr *_UnionRepresentation__ReprMapItr) Done() bool { return itr.done } -func (_UnionRepresentation__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation__Repr) ListIterator() datamodel.ListIterator { return nil } func (_UnionRepresentation__Repr) Length() int64 { @@ -38219,16 +38219,16 @@ func (_UnionRepresentation__Repr) AsString() (string, error) { func (_UnionRepresentation__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation.Repr"}.AsBytes() } -func (_UnionRepresentation__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation.Repr"}.AsLink() } -func (_UnionRepresentation__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation__ReprPrototype{} } type _UnionRepresentation__ReprPrototype struct{} -func (_UnionRepresentation__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation__ReprBuilder nb.Reset() return &nb @@ -38238,7 +38238,7 @@ type _UnionRepresentation__ReprBuilder struct { _UnionRepresentation__ReprAssembler } -func (nb *_UnionRepresentation__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -38298,7 +38298,7 @@ func (na *_UnionRepresentation__ReprAssembler) reset() { na.ca = 0 na.cm = schema.Maybe_Absent } -func (na *_UnionRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -38311,7 +38311,7 @@ func (na *_UnionRepresentation__ReprAssembler) BeginMap(int64) (ipld.MapAssemble } return na, nil } -func (_UnionRepresentation__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation.Repr"}.BeginList(0) } func (na *_UnionRepresentation__ReprAssembler) AssignNull() error { @@ -38343,10 +38343,10 @@ func (_UnionRepresentation__ReprAssembler) AssignString(string) error { func (_UnionRepresentation__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -38366,8 +38366,8 @@ func (na *_UnionRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -38384,7 +38384,7 @@ func (na *_UnionRepresentation__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_UnionRepresentation__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation__ReprPrototype{} } func (ma *_UnionRepresentation__ReprAssembler) valueFinishTidy() bool { @@ -38396,7 +38396,7 @@ func (ma *_UnionRepresentation__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_UnionRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -38458,9 +38458,9 @@ func (ma *_UnionRepresentation__ReprAssembler) AssembleEntry(k string) (ipld.Nod ma.ca6.m = &ma.cm return &ma.ca6, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation.Repr", Key: &_String{k}} } -func (ma *_UnionRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -38478,7 +38478,7 @@ func (ma *_UnionRepresentation__ReprAssembler) AssembleKey() ipld.NodeAssembler ma.state = maState_midKey return (*_UnionRepresentation__ReprKeyAssembler)(ma) } -func (ma *_UnionRepresentation__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -38543,10 +38543,10 @@ func (ma *_UnionRepresentation__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { case "UnionRepresentation_Kinded": return _UnionRepresentation_Kinded__ReprPrototype{} @@ -38567,10 +38567,10 @@ func (ma *_UnionRepresentation__ReprAssembler) ValuePrototype(k string) ipld.Nod type _UnionRepresentation__ReprKeyAssembler _UnionRepresentation__ReprAssembler -func (_UnionRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.Repr.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.Repr.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation__ReprKeyAssembler) AssignNull() error { @@ -38624,22 +38624,22 @@ func (ka *_UnionRepresentation__ReprKeyAssembler) AssignString(k string) error { ka.state = maState_expectValue return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation.Repr", Key: &_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } func (_UnionRepresentation__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -38662,12 +38662,12 @@ func (m MaybeUnionRepresentation_BytePrefix) IsAbsent() bool { func (m MaybeUnionRepresentation_BytePrefix) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation_BytePrefix) AsNode() ipld.Node { +func (m MaybeUnionRepresentation_BytePrefix) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -38684,34 +38684,34 @@ func (m MaybeUnionRepresentation_BytePrefix) Must() UnionRepresentation_BytePref var ( fieldName__UnionRepresentation_BytePrefix_DiscriminantTable = _String{"discriminantTable"} ) -var _ ipld.Node = (UnionRepresentation_BytePrefix)(&_UnionRepresentation_BytePrefix{}) +var _ datamodel.Node = (UnionRepresentation_BytePrefix)(&_UnionRepresentation_BytePrefix{}) var _ schema.TypedNode = (UnionRepresentation_BytePrefix)(&_UnionRepresentation_BytePrefix{}) -func (UnionRepresentation_BytePrefix) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation_BytePrefix) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation_BytePrefix) LookupByString(key string) (ipld.Node, error) { +func (n UnionRepresentation_BytePrefix) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantTable": return &n.discriminantTable, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n UnionRepresentation_BytePrefix) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation_BytePrefix) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (UnionRepresentation_BytePrefix) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation_BytePrefix) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_BytePrefix"}.LookupByIndex(0) } -func (n UnionRepresentation_BytePrefix) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation_BytePrefix) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation_BytePrefix) MapIterator() ipld.MapIterator { +func (n UnionRepresentation_BytePrefix) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_BytePrefix__MapItr{n, 0} } @@ -38720,9 +38720,9 @@ type _UnionRepresentation_BytePrefix__MapItr struct { idx int } -func (itr *_UnionRepresentation_BytePrefix__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_BytePrefix__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -38738,7 +38738,7 @@ func (itr *_UnionRepresentation_BytePrefix__MapItr) Done() bool { return itr.idx >= 1 } -func (UnionRepresentation_BytePrefix) ListIterator() ipld.ListIterator { +func (UnionRepresentation_BytePrefix) ListIterator() datamodel.ListIterator { return nil } func (UnionRepresentation_BytePrefix) Length() int64 { @@ -38765,16 +38765,16 @@ func (UnionRepresentation_BytePrefix) AsString() (string, error) { func (UnionRepresentation_BytePrefix) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_BytePrefix"}.AsBytes() } -func (UnionRepresentation_BytePrefix) AsLink() (ipld.Link, error) { +func (UnionRepresentation_BytePrefix) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_BytePrefix"}.AsLink() } -func (UnionRepresentation_BytePrefix) Prototype() ipld.NodePrototype { +func (UnionRepresentation_BytePrefix) Prototype() datamodel.NodePrototype { return _UnionRepresentation_BytePrefix__Prototype{} } type _UnionRepresentation_BytePrefix__Prototype struct{} -func (_UnionRepresentation_BytePrefix__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_BytePrefix__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_BytePrefix__Builder nb.Reset() return &nb @@ -38784,7 +38784,7 @@ type _UnionRepresentation_BytePrefix__Builder struct { _UnionRepresentation_BytePrefix__Assembler } -func (nb *_UnionRepresentation_BytePrefix__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation_BytePrefix__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -38818,7 +38818,7 @@ var ( fieldBits__UnionRepresentation_BytePrefix_sufficient = 0 + 1<<0 ) -func (na *_UnionRepresentation_BytePrefix__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_BytePrefix__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -38831,7 +38831,7 @@ func (na *_UnionRepresentation_BytePrefix__Assembler) BeginMap(int64) (ipld.MapA } return na, nil } -func (_UnionRepresentation_BytePrefix__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_BytePrefix__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix"}.BeginList(0) } func (na *_UnionRepresentation_BytePrefix__Assembler) AssignNull() error { @@ -38863,10 +38863,10 @@ func (_UnionRepresentation_BytePrefix__Assembler) AssignString(string) error { func (_UnionRepresentation_BytePrefix__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix"}.AssignBytes(nil) } -func (_UnionRepresentation_BytePrefix__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_BytePrefix__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix"}.AssignLink(nil) } -func (na *_UnionRepresentation_BytePrefix__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_BytePrefix__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -38886,8 +38886,8 @@ func (na *_UnionRepresentation_BytePrefix__Assembler) AssignNode(v ipld.Node) er *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_BytePrefix", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_BytePrefix", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -38904,7 +38904,7 @@ func (na *_UnionRepresentation_BytePrefix__Assembler) AssignNode(v ipld.Node) er } return na.Finish() } -func (_UnionRepresentation_BytePrefix__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_BytePrefix__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_BytePrefix__Prototype{} } func (ma *_UnionRepresentation_BytePrefix__Assembler) valueFinishTidy() bool { @@ -38923,7 +38923,7 @@ func (ma *_UnionRepresentation_BytePrefix__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -38941,7 +38941,7 @@ func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleEntry(k string) (i switch k { case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable} } ma.s += fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable ma.state = maState_midValue @@ -38950,9 +38950,9 @@ func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleEntry(k string) (i ma.ca_discriminantTable.m = &ma.cm return &ma.ca_discriminantTable, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix", Key: &_String{k}} } -func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -38970,7 +38970,7 @@ func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleKey() ipld.NodeAss ma.state = maState_midKey return (*_UnionRepresentation_BytePrefix__KeyAssembler)(ma) } -func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_BytePrefix__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -39009,7 +39009,7 @@ func (ma *_UnionRepresentation_BytePrefix__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_BytePrefix_sufficient != fieldBits__UnionRepresentation_BytePrefix_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable == 0 { err.Missing = append(err.Missing, "discriminantTable") } @@ -39019,19 +39019,19 @@ func (ma *_UnionRepresentation_BytePrefix__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_BytePrefix__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_BytePrefix__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_BytePrefix__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_BytePrefix__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _UnionRepresentation_BytePrefix__KeyAssembler _UnionRepresentation_BytePrefix__Assembler -func (_UnionRepresentation_BytePrefix__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_BytePrefix__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_BytePrefix__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_BytePrefix__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_BytePrefix__KeyAssembler) AssignNull() error { @@ -39053,36 +39053,36 @@ func (ka *_UnionRepresentation_BytePrefix__KeyAssembler) AssignString(k string) switch k { case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable} } ka.s += fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix", Key: &_String{k}} } } func (_UnionRepresentation_BytePrefix__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_BytePrefix__KeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_BytePrefix__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_BytePrefix__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_BytePrefix__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_BytePrefix__KeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_BytePrefix__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (UnionRepresentation_BytePrefix) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation_BytePrefix) Representation() ipld.Node { +func (n UnionRepresentation_BytePrefix) Representation() datamodel.Node { return (*_UnionRepresentation_BytePrefix__Repr)(n) } @@ -39091,33 +39091,33 @@ type _UnionRepresentation_BytePrefix__Repr _UnionRepresentation_BytePrefix var ( fieldName__UnionRepresentation_BytePrefix_DiscriminantTable_serial = _String{"discriminantTable"} ) -var _ ipld.Node = &_UnionRepresentation_BytePrefix__Repr{} +var _ datamodel.Node = &_UnionRepresentation_BytePrefix__Repr{} -func (_UnionRepresentation_BytePrefix__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation_BytePrefix__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_UnionRepresentation_BytePrefix__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_UnionRepresentation_BytePrefix__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantTable": return n.discriminantTable.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_UnionRepresentation_BytePrefix__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_UnionRepresentation_BytePrefix__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_UnionRepresentation_BytePrefix__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation_BytePrefix__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation_BytePrefix__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation_BytePrefix__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_UnionRepresentation_BytePrefix__Repr) MapIterator() ipld.MapIterator { +func (n *_UnionRepresentation_BytePrefix__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_BytePrefix__ReprMapItr{n, 0} } @@ -39126,9 +39126,9 @@ type _UnionRepresentation_BytePrefix__ReprMapItr struct { idx int } -func (itr *_UnionRepresentation_BytePrefix__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_BytePrefix__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -39143,7 +39143,7 @@ func (itr *_UnionRepresentation_BytePrefix__ReprMapItr) Next() (k ipld.Node, v i func (itr *_UnionRepresentation_BytePrefix__ReprMapItr) Done() bool { return itr.idx >= 1 } -func (_UnionRepresentation_BytePrefix__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation_BytePrefix__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_UnionRepresentation_BytePrefix__Repr) Length() int64 { @@ -39171,16 +39171,16 @@ func (_UnionRepresentation_BytePrefix__Repr) AsString() (string, error) { func (_UnionRepresentation_BytePrefix__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr"}.AsBytes() } -func (_UnionRepresentation_BytePrefix__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation_BytePrefix__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr"}.AsLink() } -func (_UnionRepresentation_BytePrefix__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_BytePrefix__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation_BytePrefix__ReprPrototype{} } type _UnionRepresentation_BytePrefix__ReprPrototype struct{} -func (_UnionRepresentation_BytePrefix__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_BytePrefix__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_BytePrefix__ReprBuilder nb.Reset() return &nb @@ -39190,7 +39190,7 @@ type _UnionRepresentation_BytePrefix__ReprBuilder struct { _UnionRepresentation_BytePrefix__ReprAssembler } -func (nb *_UnionRepresentation_BytePrefix__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation_BytePrefix__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -39218,7 +39218,7 @@ func (na *_UnionRepresentation_BytePrefix__ReprAssembler) reset() { na.s = 0 na.ca_discriminantTable.reset() } -func (na *_UnionRepresentation_BytePrefix__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_BytePrefix__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -39231,7 +39231,7 @@ func (na *_UnionRepresentation_BytePrefix__ReprAssembler) BeginMap(int64) (ipld. } return na, nil } -func (_UnionRepresentation_BytePrefix__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_BytePrefix__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr"}.BeginList(0) } func (na *_UnionRepresentation_BytePrefix__ReprAssembler) AssignNull() error { @@ -39263,10 +39263,10 @@ func (_UnionRepresentation_BytePrefix__ReprAssembler) AssignString(string) error func (_UnionRepresentation_BytePrefix__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation_BytePrefix__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_BytePrefix__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation_BytePrefix__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_BytePrefix__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -39286,8 +39286,8 @@ func (na *_UnionRepresentation_BytePrefix__ReprAssembler) AssignNode(v ipld.Node *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -39304,7 +39304,7 @@ func (na *_UnionRepresentation_BytePrefix__ReprAssembler) AssignNode(v ipld.Node } return na.Finish() } -func (_UnionRepresentation_BytePrefix__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_BytePrefix__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_BytePrefix__ReprPrototype{} } func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) valueFinishTidy() bool { @@ -39322,7 +39322,7 @@ func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) valueFinishTidy() bool panic("unreachable") } } -func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -39340,7 +39340,7 @@ func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleEntry(k string switch k { case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable_serial} } ma.s += fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable ma.state = maState_midValue @@ -39350,9 +39350,9 @@ func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleEntry(k string return &ma.ca_discriminantTable, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr", Key: &_String{k}} } -func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -39370,7 +39370,7 @@ func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleKey() ipld.Nod ma.state = maState_midKey return (*_UnionRepresentation_BytePrefix__ReprKeyAssembler)(ma) } -func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -39409,7 +39409,7 @@ func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_BytePrefix_sufficient != fieldBits__UnionRepresentation_BytePrefix_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable == 0 { err.Missing = append(err.Missing, "discriminantTable") } @@ -39419,19 +39419,19 @@ func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_BytePrefix__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _UnionRepresentation_BytePrefix__ReprKeyAssembler _UnionRepresentation_BytePrefix__ReprAssembler -func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignNull() error { @@ -39453,29 +39453,29 @@ func (ka *_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignString(k stri switch k { case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_BytePrefix_DiscriminantTable_serial} } ka.s += fieldBit__UnionRepresentation_BytePrefix_DiscriminantTable ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr", Key: &_String{k}} } func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_BytePrefix.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_BytePrefix__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_BytePrefix__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -39504,12 +39504,12 @@ func (m MaybeUnionRepresentation_Envelope) IsAbsent() bool { func (m MaybeUnionRepresentation_Envelope) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation_Envelope) AsNode() ipld.Node { +func (m MaybeUnionRepresentation_Envelope) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -39528,13 +39528,13 @@ var ( fieldName__UnionRepresentation_Envelope_ContentKey = _String{"contentKey"} fieldName__UnionRepresentation_Envelope_DiscriminantTable = _String{"discriminantTable"} ) -var _ ipld.Node = (UnionRepresentation_Envelope)(&_UnionRepresentation_Envelope{}) +var _ datamodel.Node = (UnionRepresentation_Envelope)(&_UnionRepresentation_Envelope{}) var _ schema.TypedNode = (UnionRepresentation_Envelope)(&_UnionRepresentation_Envelope{}) -func (UnionRepresentation_Envelope) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation_Envelope) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation_Envelope) LookupByString(key string) (ipld.Node, error) { +func (n UnionRepresentation_Envelope) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantKey": return &n.discriminantKey, nil @@ -39543,23 +39543,23 @@ func (n UnionRepresentation_Envelope) LookupByString(key string) (ipld.Node, err case "discriminantTable": return &n.discriminantTable, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n UnionRepresentation_Envelope) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation_Envelope) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (UnionRepresentation_Envelope) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation_Envelope) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Envelope"}.LookupByIndex(0) } -func (n UnionRepresentation_Envelope) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation_Envelope) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation_Envelope) MapIterator() ipld.MapIterator { +func (n UnionRepresentation_Envelope) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Envelope__MapItr{n, 0} } @@ -39568,9 +39568,9 @@ type _UnionRepresentation_Envelope__MapItr struct { idx int } -func (itr *_UnionRepresentation_Envelope__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_Envelope__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -39592,7 +39592,7 @@ func (itr *_UnionRepresentation_Envelope__MapItr) Done() bool { return itr.idx >= 3 } -func (UnionRepresentation_Envelope) ListIterator() ipld.ListIterator { +func (UnionRepresentation_Envelope) ListIterator() datamodel.ListIterator { return nil } func (UnionRepresentation_Envelope) Length() int64 { @@ -39619,16 +39619,16 @@ func (UnionRepresentation_Envelope) AsString() (string, error) { func (UnionRepresentation_Envelope) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Envelope"}.AsBytes() } -func (UnionRepresentation_Envelope) AsLink() (ipld.Link, error) { +func (UnionRepresentation_Envelope) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Envelope"}.AsLink() } -func (UnionRepresentation_Envelope) Prototype() ipld.NodePrototype { +func (UnionRepresentation_Envelope) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Envelope__Prototype{} } type _UnionRepresentation_Envelope__Prototype struct{} -func (_UnionRepresentation_Envelope__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Envelope__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Envelope__Builder nb.Reset() return &nb @@ -39638,7 +39638,7 @@ type _UnionRepresentation_Envelope__Builder struct { _UnionRepresentation_Envelope__Assembler } -func (nb *_UnionRepresentation_Envelope__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation_Envelope__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -39678,7 +39678,7 @@ var ( fieldBits__UnionRepresentation_Envelope_sufficient = 0 + 1<<0 + 1<<1 + 1<<2 ) -func (na *_UnionRepresentation_Envelope__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Envelope__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -39691,7 +39691,7 @@ func (na *_UnionRepresentation_Envelope__Assembler) BeginMap(int64) (ipld.MapAss } return na, nil } -func (_UnionRepresentation_Envelope__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Envelope__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope"}.BeginList(0) } func (na *_UnionRepresentation_Envelope__Assembler) AssignNull() error { @@ -39723,10 +39723,10 @@ func (_UnionRepresentation_Envelope__Assembler) AssignString(string) error { func (_UnionRepresentation_Envelope__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope"}.AssignBytes(nil) } -func (_UnionRepresentation_Envelope__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Envelope__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope"}.AssignLink(nil) } -func (na *_UnionRepresentation_Envelope__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Envelope__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -39746,8 +39746,8 @@ func (na *_UnionRepresentation_Envelope__Assembler) AssignNode(v ipld.Node) erro *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Envelope", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Envelope", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -39764,7 +39764,7 @@ func (na *_UnionRepresentation_Envelope__Assembler) AssignNode(v ipld.Node) erro } return na.Finish() } -func (_UnionRepresentation_Envelope__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Envelope__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Envelope__Prototype{} } func (ma *_UnionRepresentation_Envelope__Assembler) valueFinishTidy() bool { @@ -39803,7 +39803,7 @@ func (ma *_UnionRepresentation_Envelope__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_UnionRepresentation_Envelope__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Envelope__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -39821,7 +39821,7 @@ func (ma *_UnionRepresentation_Envelope__Assembler) AssembleEntry(k string) (ipl switch k { case "discriminantKey": if ma.s&fieldBit__UnionRepresentation_Envelope_DiscriminantKey != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey} } ma.s += fieldBit__UnionRepresentation_Envelope_DiscriminantKey ma.state = maState_midValue @@ -39831,7 +39831,7 @@ func (ma *_UnionRepresentation_Envelope__Assembler) AssembleEntry(k string) (ipl return &ma.ca_discriminantKey, nil case "contentKey": if ma.s&fieldBit__UnionRepresentation_Envelope_ContentKey != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey} } ma.s += fieldBit__UnionRepresentation_Envelope_ContentKey ma.state = maState_midValue @@ -39841,7 +39841,7 @@ func (ma *_UnionRepresentation_Envelope__Assembler) AssembleEntry(k string) (ipl return &ma.ca_contentKey, nil case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_Envelope_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable} } ma.s += fieldBit__UnionRepresentation_Envelope_DiscriminantTable ma.state = maState_midValue @@ -39850,9 +39850,9 @@ func (ma *_UnionRepresentation_Envelope__Assembler) AssembleEntry(k string) (ipl ma.ca_discriminantTable.m = &ma.cm return &ma.ca_discriminantTable, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope", Key: &_String{k}} } -func (ma *_UnionRepresentation_Envelope__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Envelope__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -39870,7 +39870,7 @@ func (ma *_UnionRepresentation_Envelope__Assembler) AssembleKey() ipld.NodeAssem ma.state = maState_midKey return (*_UnionRepresentation_Envelope__KeyAssembler)(ma) } -func (ma *_UnionRepresentation_Envelope__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Envelope__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -39917,7 +39917,7 @@ func (ma *_UnionRepresentation_Envelope__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_Envelope_sufficient != fieldBits__UnionRepresentation_Envelope_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_Envelope_DiscriminantKey == 0 { err.Missing = append(err.Missing, "discriminantKey") } @@ -39933,19 +39933,19 @@ func (ma *_UnionRepresentation_Envelope__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Envelope__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Envelope__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_Envelope__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Envelope__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _UnionRepresentation_Envelope__KeyAssembler _UnionRepresentation_Envelope__Assembler -func (_UnionRepresentation_Envelope__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_Envelope__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_Envelope__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Envelope__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_Envelope__KeyAssembler) AssignNull() error { @@ -39967,7 +39967,7 @@ func (ka *_UnionRepresentation_Envelope__KeyAssembler) AssignString(k string) er switch k { case "discriminantKey": if ka.s&fieldBit__UnionRepresentation_Envelope_DiscriminantKey != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey} } ka.s += fieldBit__UnionRepresentation_Envelope_DiscriminantKey ka.state = maState_expectValue @@ -39975,7 +39975,7 @@ func (ka *_UnionRepresentation_Envelope__KeyAssembler) AssignString(k string) er return nil case "contentKey": if ka.s&fieldBit__UnionRepresentation_Envelope_ContentKey != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey} } ka.s += fieldBit__UnionRepresentation_Envelope_ContentKey ka.state = maState_expectValue @@ -39983,36 +39983,36 @@ func (ka *_UnionRepresentation_Envelope__KeyAssembler) AssignString(k string) er return nil case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_Envelope_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable} } ka.s += fieldBit__UnionRepresentation_Envelope_DiscriminantTable ka.state = maState_expectValue ka.f = 2 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope", Key: &_String{k}} } } func (_UnionRepresentation_Envelope__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_Envelope__KeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Envelope__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_Envelope__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_Envelope__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_Envelope__KeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Envelope__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (UnionRepresentation_Envelope) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation_Envelope) Representation() ipld.Node { +func (n UnionRepresentation_Envelope) Representation() datamodel.Node { return (*_UnionRepresentation_Envelope__Repr)(n) } @@ -40023,12 +40023,12 @@ var ( fieldName__UnionRepresentation_Envelope_ContentKey_serial = _String{"contentKey"} fieldName__UnionRepresentation_Envelope_DiscriminantTable_serial = _String{"discriminantTable"} ) -var _ ipld.Node = &_UnionRepresentation_Envelope__Repr{} +var _ datamodel.Node = &_UnionRepresentation_Envelope__Repr{} -func (_UnionRepresentation_Envelope__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation_Envelope__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_UnionRepresentation_Envelope__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_UnionRepresentation_Envelope__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantKey": return n.discriminantKey.Representation(), nil @@ -40037,23 +40037,23 @@ func (n *_UnionRepresentation_Envelope__Repr) LookupByString(key string) (ipld.N case "discriminantTable": return n.discriminantTable.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_UnionRepresentation_Envelope__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_UnionRepresentation_Envelope__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_UnionRepresentation_Envelope__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation_Envelope__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation_Envelope__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation_Envelope__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_UnionRepresentation_Envelope__Repr) MapIterator() ipld.MapIterator { +func (n *_UnionRepresentation_Envelope__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Envelope__ReprMapItr{n, 0} } @@ -40062,9 +40062,9 @@ type _UnionRepresentation_Envelope__ReprMapItr struct { idx int } -func (itr *_UnionRepresentation_Envelope__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_Envelope__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 3 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -40085,7 +40085,7 @@ func (itr *_UnionRepresentation_Envelope__ReprMapItr) Next() (k ipld.Node, v ipl func (itr *_UnionRepresentation_Envelope__ReprMapItr) Done() bool { return itr.idx >= 3 } -func (_UnionRepresentation_Envelope__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation_Envelope__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_UnionRepresentation_Envelope__Repr) Length() int64 { @@ -40113,16 +40113,16 @@ func (_UnionRepresentation_Envelope__Repr) AsString() (string, error) { func (_UnionRepresentation_Envelope__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr"}.AsBytes() } -func (_UnionRepresentation_Envelope__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation_Envelope__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr"}.AsLink() } -func (_UnionRepresentation_Envelope__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Envelope__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Envelope__ReprPrototype{} } type _UnionRepresentation_Envelope__ReprPrototype struct{} -func (_UnionRepresentation_Envelope__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Envelope__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Envelope__ReprBuilder nb.Reset() return &nb @@ -40132,7 +40132,7 @@ type _UnionRepresentation_Envelope__ReprBuilder struct { _UnionRepresentation_Envelope__ReprAssembler } -func (nb *_UnionRepresentation_Envelope__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation_Envelope__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -40164,7 +40164,7 @@ func (na *_UnionRepresentation_Envelope__ReprAssembler) reset() { na.ca_contentKey.reset() na.ca_discriminantTable.reset() } -func (na *_UnionRepresentation_Envelope__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Envelope__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -40177,7 +40177,7 @@ func (na *_UnionRepresentation_Envelope__ReprAssembler) BeginMap(int64) (ipld.Ma } return na, nil } -func (_UnionRepresentation_Envelope__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Envelope__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr"}.BeginList(0) } func (na *_UnionRepresentation_Envelope__ReprAssembler) AssignNull() error { @@ -40209,10 +40209,10 @@ func (_UnionRepresentation_Envelope__ReprAssembler) AssignString(string) error { func (_UnionRepresentation_Envelope__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation_Envelope__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Envelope__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation_Envelope__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Envelope__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -40232,8 +40232,8 @@ func (na *_UnionRepresentation_Envelope__ReprAssembler) AssignNode(v ipld.Node) *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -40250,7 +40250,7 @@ func (na *_UnionRepresentation_Envelope__ReprAssembler) AssignNode(v ipld.Node) } return na.Finish() } -func (_UnionRepresentation_Envelope__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Envelope__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Envelope__ReprPrototype{} } func (ma *_UnionRepresentation_Envelope__ReprAssembler) valueFinishTidy() bool { @@ -40286,7 +40286,7 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -40304,7 +40304,7 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleEntry(k string) switch k { case "discriminantKey": if ma.s&fieldBit__UnionRepresentation_Envelope_DiscriminantKey != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey_serial} } ma.s += fieldBit__UnionRepresentation_Envelope_DiscriminantKey ma.state = maState_midValue @@ -40314,7 +40314,7 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleEntry(k string) return &ma.ca_discriminantKey, nil case "contentKey": if ma.s&fieldBit__UnionRepresentation_Envelope_ContentKey != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey_serial} } ma.s += fieldBit__UnionRepresentation_Envelope_ContentKey ma.state = maState_midValue @@ -40324,7 +40324,7 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleEntry(k string) return &ma.ca_contentKey, nil case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_Envelope_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable_serial} } ma.s += fieldBit__UnionRepresentation_Envelope_DiscriminantTable ma.state = maState_midValue @@ -40334,9 +40334,9 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleEntry(k string) return &ma.ca_discriminantTable, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr", Key: &_String{k}} } -func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -40354,7 +40354,7 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleKey() ipld.NodeA ma.state = maState_midKey return (*_UnionRepresentation_Envelope__ReprKeyAssembler)(ma) } -func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Envelope__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -40401,7 +40401,7 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_Envelope_sufficient != fieldBits__UnionRepresentation_Envelope_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_Envelope_DiscriminantKey == 0 { err.Missing = append(err.Missing, "discriminantKey") } @@ -40417,19 +40417,19 @@ func (ma *_UnionRepresentation_Envelope__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Envelope__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Envelope__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_Envelope__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Envelope__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _UnionRepresentation_Envelope__ReprKeyAssembler _UnionRepresentation_Envelope__ReprAssembler -func (_UnionRepresentation_Envelope__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_Envelope__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_Envelope__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Envelope__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_Envelope__ReprKeyAssembler) AssignNull() error { @@ -40451,7 +40451,7 @@ func (ka *_UnionRepresentation_Envelope__ReprKeyAssembler) AssignString(k string switch k { case "discriminantKey": if ka.s&fieldBit__UnionRepresentation_Envelope_DiscriminantKey != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantKey_serial} } ka.s += fieldBit__UnionRepresentation_Envelope_DiscriminantKey ka.state = maState_expectValue @@ -40459,7 +40459,7 @@ func (ka *_UnionRepresentation_Envelope__ReprKeyAssembler) AssignString(k string return nil case "contentKey": if ka.s&fieldBit__UnionRepresentation_Envelope_ContentKey != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_ContentKey_serial} } ka.s += fieldBit__UnionRepresentation_Envelope_ContentKey ka.state = maState_expectValue @@ -40467,29 +40467,29 @@ func (ka *_UnionRepresentation_Envelope__ReprKeyAssembler) AssignString(k string return nil case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_Envelope_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Envelope_DiscriminantTable_serial} } ka.s += fieldBit__UnionRepresentation_Envelope_DiscriminantTable ka.state = maState_expectValue ka.f = 2 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr", Key: &_String{k}} } func (_UnionRepresentation_Envelope__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_Envelope__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Envelope__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Envelope.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_Envelope__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_Envelope__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_Envelope__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Envelope__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -40515,12 +40515,12 @@ func (m MaybeUnionRepresentation_Inline) IsAbsent() bool { func (m MaybeUnionRepresentation_Inline) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation_Inline) AsNode() ipld.Node { +func (m MaybeUnionRepresentation_Inline) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -40538,36 +40538,36 @@ var ( fieldName__UnionRepresentation_Inline_DiscriminantKey = _String{"discriminantKey"} fieldName__UnionRepresentation_Inline_DiscriminantTable = _String{"discriminantTable"} ) -var _ ipld.Node = (UnionRepresentation_Inline)(&_UnionRepresentation_Inline{}) +var _ datamodel.Node = (UnionRepresentation_Inline)(&_UnionRepresentation_Inline{}) var _ schema.TypedNode = (UnionRepresentation_Inline)(&_UnionRepresentation_Inline{}) -func (UnionRepresentation_Inline) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation_Inline) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation_Inline) LookupByString(key string) (ipld.Node, error) { +func (n UnionRepresentation_Inline) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantKey": return &n.discriminantKey, nil case "discriminantTable": return &n.discriminantTable, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n UnionRepresentation_Inline) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation_Inline) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (UnionRepresentation_Inline) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation_Inline) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Inline"}.LookupByIndex(0) } -func (n UnionRepresentation_Inline) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation_Inline) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation_Inline) MapIterator() ipld.MapIterator { +func (n UnionRepresentation_Inline) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Inline__MapItr{n, 0} } @@ -40576,9 +40576,9 @@ type _UnionRepresentation_Inline__MapItr struct { idx int } -func (itr *_UnionRepresentation_Inline__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_Inline__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -40597,7 +40597,7 @@ func (itr *_UnionRepresentation_Inline__MapItr) Done() bool { return itr.idx >= 2 } -func (UnionRepresentation_Inline) ListIterator() ipld.ListIterator { +func (UnionRepresentation_Inline) ListIterator() datamodel.ListIterator { return nil } func (UnionRepresentation_Inline) Length() int64 { @@ -40624,16 +40624,16 @@ func (UnionRepresentation_Inline) AsString() (string, error) { func (UnionRepresentation_Inline) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Inline"}.AsBytes() } -func (UnionRepresentation_Inline) AsLink() (ipld.Link, error) { +func (UnionRepresentation_Inline) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Inline"}.AsLink() } -func (UnionRepresentation_Inline) Prototype() ipld.NodePrototype { +func (UnionRepresentation_Inline) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Inline__Prototype{} } type _UnionRepresentation_Inline__Prototype struct{} -func (_UnionRepresentation_Inline__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Inline__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Inline__Builder nb.Reset() return &nb @@ -40643,7 +40643,7 @@ type _UnionRepresentation_Inline__Builder struct { _UnionRepresentation_Inline__Assembler } -func (nb *_UnionRepresentation_Inline__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation_Inline__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -40680,7 +40680,7 @@ var ( fieldBits__UnionRepresentation_Inline_sufficient = 0 + 1<<0 + 1<<1 ) -func (na *_UnionRepresentation_Inline__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Inline__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -40693,7 +40693,7 @@ func (na *_UnionRepresentation_Inline__Assembler) BeginMap(int64) (ipld.MapAssem } return na, nil } -func (_UnionRepresentation_Inline__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Inline__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Inline"}.BeginList(0) } func (na *_UnionRepresentation_Inline__Assembler) AssignNull() error { @@ -40725,10 +40725,10 @@ func (_UnionRepresentation_Inline__Assembler) AssignString(string) error { func (_UnionRepresentation_Inline__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Inline"}.AssignBytes(nil) } -func (_UnionRepresentation_Inline__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Inline__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Inline"}.AssignLink(nil) } -func (na *_UnionRepresentation_Inline__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Inline__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -40748,8 +40748,8 @@ func (na *_UnionRepresentation_Inline__Assembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Inline", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Inline", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -40766,7 +40766,7 @@ func (na *_UnionRepresentation_Inline__Assembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_UnionRepresentation_Inline__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Inline__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Inline__Prototype{} } func (ma *_UnionRepresentation_Inline__Assembler) valueFinishTidy() bool { @@ -40795,7 +40795,7 @@ func (ma *_UnionRepresentation_Inline__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_UnionRepresentation_Inline__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Inline__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -40813,7 +40813,7 @@ func (ma *_UnionRepresentation_Inline__Assembler) AssembleEntry(k string) (ipld. switch k { case "discriminantKey": if ma.s&fieldBit__UnionRepresentation_Inline_DiscriminantKey != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey} } ma.s += fieldBit__UnionRepresentation_Inline_DiscriminantKey ma.state = maState_midValue @@ -40823,7 +40823,7 @@ func (ma *_UnionRepresentation_Inline__Assembler) AssembleEntry(k string) (ipld. return &ma.ca_discriminantKey, nil case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_Inline_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable} } ma.s += fieldBit__UnionRepresentation_Inline_DiscriminantTable ma.state = maState_midValue @@ -40832,9 +40832,9 @@ func (ma *_UnionRepresentation_Inline__Assembler) AssembleEntry(k string) (ipld. ma.ca_discriminantTable.m = &ma.cm return &ma.ca_discriminantTable, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline", Key: &_String{k}} } -func (ma *_UnionRepresentation_Inline__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Inline__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -40852,7 +40852,7 @@ func (ma *_UnionRepresentation_Inline__Assembler) AssembleKey() ipld.NodeAssembl ma.state = maState_midKey return (*_UnionRepresentation_Inline__KeyAssembler)(ma) } -func (ma *_UnionRepresentation_Inline__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Inline__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -40895,7 +40895,7 @@ func (ma *_UnionRepresentation_Inline__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_Inline_sufficient != fieldBits__UnionRepresentation_Inline_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_Inline_DiscriminantKey == 0 { err.Missing = append(err.Missing, "discriminantKey") } @@ -40908,19 +40908,19 @@ func (ma *_UnionRepresentation_Inline__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Inline__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Inline__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_Inline__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Inline__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _UnionRepresentation_Inline__KeyAssembler _UnionRepresentation_Inline__Assembler -func (_UnionRepresentation_Inline__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_Inline__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_Inline__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Inline__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_Inline__KeyAssembler) AssignNull() error { @@ -40942,7 +40942,7 @@ func (ka *_UnionRepresentation_Inline__KeyAssembler) AssignString(k string) erro switch k { case "discriminantKey": if ka.s&fieldBit__UnionRepresentation_Inline_DiscriminantKey != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey} } ka.s += fieldBit__UnionRepresentation_Inline_DiscriminantKey ka.state = maState_expectValue @@ -40950,36 +40950,36 @@ func (ka *_UnionRepresentation_Inline__KeyAssembler) AssignString(k string) erro return nil case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_Inline_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable} } ka.s += fieldBit__UnionRepresentation_Inline_DiscriminantTable ka.state = maState_expectValue ka.f = 1 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline", Key: &_String{k}} } } func (_UnionRepresentation_Inline__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_Inline__KeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Inline__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_Inline__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_Inline__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_Inline__KeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Inline__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (UnionRepresentation_Inline) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation_Inline) Representation() ipld.Node { +func (n UnionRepresentation_Inline) Representation() datamodel.Node { return (*_UnionRepresentation_Inline__Repr)(n) } @@ -40989,35 +40989,35 @@ var ( fieldName__UnionRepresentation_Inline_DiscriminantKey_serial = _String{"discriminantKey"} fieldName__UnionRepresentation_Inline_DiscriminantTable_serial = _String{"discriminantTable"} ) -var _ ipld.Node = &_UnionRepresentation_Inline__Repr{} +var _ datamodel.Node = &_UnionRepresentation_Inline__Repr{} -func (_UnionRepresentation_Inline__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation_Inline__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_UnionRepresentation_Inline__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_UnionRepresentation_Inline__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantKey": return n.discriminantKey.Representation(), nil case "discriminantTable": return n.discriminantTable.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_UnionRepresentation_Inline__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_UnionRepresentation_Inline__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_UnionRepresentation_Inline__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation_Inline__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Inline.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation_Inline__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation_Inline__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_UnionRepresentation_Inline__Repr) MapIterator() ipld.MapIterator { +func (n *_UnionRepresentation_Inline__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Inline__ReprMapItr{n, 0} } @@ -41026,9 +41026,9 @@ type _UnionRepresentation_Inline__ReprMapItr struct { idx int } -func (itr *_UnionRepresentation_Inline__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_Inline__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 2 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -41046,7 +41046,7 @@ func (itr *_UnionRepresentation_Inline__ReprMapItr) Next() (k ipld.Node, v ipld. func (itr *_UnionRepresentation_Inline__ReprMapItr) Done() bool { return itr.idx >= 2 } -func (_UnionRepresentation_Inline__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation_Inline__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_UnionRepresentation_Inline__Repr) Length() int64 { @@ -41074,16 +41074,16 @@ func (_UnionRepresentation_Inline__Repr) AsString() (string, error) { func (_UnionRepresentation_Inline__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Inline.Repr"}.AsBytes() } -func (_UnionRepresentation_Inline__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation_Inline__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Inline.Repr"}.AsLink() } -func (_UnionRepresentation_Inline__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Inline__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Inline__ReprPrototype{} } type _UnionRepresentation_Inline__ReprPrototype struct{} -func (_UnionRepresentation_Inline__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Inline__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Inline__ReprBuilder nb.Reset() return &nb @@ -41093,7 +41093,7 @@ type _UnionRepresentation_Inline__ReprBuilder struct { _UnionRepresentation_Inline__ReprAssembler } -func (nb *_UnionRepresentation_Inline__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation_Inline__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -41123,7 +41123,7 @@ func (na *_UnionRepresentation_Inline__ReprAssembler) reset() { na.ca_discriminantKey.reset() na.ca_discriminantTable.reset() } -func (na *_UnionRepresentation_Inline__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Inline__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -41136,7 +41136,7 @@ func (na *_UnionRepresentation_Inline__ReprAssembler) BeginMap(int64) (ipld.MapA } return na, nil } -func (_UnionRepresentation_Inline__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Inline__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr"}.BeginList(0) } func (na *_UnionRepresentation_Inline__ReprAssembler) AssignNull() error { @@ -41168,10 +41168,10 @@ func (_UnionRepresentation_Inline__ReprAssembler) AssignString(string) error { func (_UnionRepresentation_Inline__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation_Inline__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Inline__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation_Inline__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Inline__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -41191,8 +41191,8 @@ func (na *_UnionRepresentation_Inline__ReprAssembler) AssignNode(v ipld.Node) er *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Inline.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Inline.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -41209,7 +41209,7 @@ func (na *_UnionRepresentation_Inline__ReprAssembler) AssignNode(v ipld.Node) er } return na.Finish() } -func (_UnionRepresentation_Inline__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Inline__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Inline__ReprPrototype{} } func (ma *_UnionRepresentation_Inline__ReprAssembler) valueFinishTidy() bool { @@ -41236,7 +41236,7 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -41254,7 +41254,7 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleEntry(k string) (i switch k { case "discriminantKey": if ma.s&fieldBit__UnionRepresentation_Inline_DiscriminantKey != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey_serial} } ma.s += fieldBit__UnionRepresentation_Inline_DiscriminantKey ma.state = maState_midValue @@ -41264,7 +41264,7 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleEntry(k string) (i return &ma.ca_discriminantKey, nil case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_Inline_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable_serial} } ma.s += fieldBit__UnionRepresentation_Inline_DiscriminantTable ma.state = maState_midValue @@ -41274,9 +41274,9 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleEntry(k string) (i return &ma.ca_discriminantTable, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline.Repr", Key: &_String{k}} } -func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -41294,7 +41294,7 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleKey() ipld.NodeAss ma.state = maState_midKey return (*_UnionRepresentation_Inline__ReprKeyAssembler)(ma) } -func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Inline__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -41337,7 +41337,7 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_Inline_sufficient != fieldBits__UnionRepresentation_Inline_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_Inline_DiscriminantKey == 0 { err.Missing = append(err.Missing, "discriminantKey") } @@ -41350,19 +41350,19 @@ func (ma *_UnionRepresentation_Inline__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Inline__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Inline__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_Inline__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Inline__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _UnionRepresentation_Inline__ReprKeyAssembler _UnionRepresentation_Inline__ReprAssembler -func (_UnionRepresentation_Inline__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_Inline__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_Inline__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Inline__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_Inline__ReprKeyAssembler) AssignNull() error { @@ -41384,7 +41384,7 @@ func (ka *_UnionRepresentation_Inline__ReprKeyAssembler) AssignString(k string) switch k { case "discriminantKey": if ka.s&fieldBit__UnionRepresentation_Inline_DiscriminantKey != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantKey_serial} } ka.s += fieldBit__UnionRepresentation_Inline_DiscriminantKey ka.state = maState_expectValue @@ -41392,29 +41392,29 @@ func (ka *_UnionRepresentation_Inline__ReprKeyAssembler) AssignString(k string) return nil case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_Inline_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_Inline_DiscriminantTable_serial} } ka.s += fieldBit__UnionRepresentation_Inline_DiscriminantTable ka.state = maState_expectValue ka.f = 1 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_Inline.Repr", Key: &_String{k}} } func (_UnionRepresentation_Inline__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_Inline__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Inline__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_Inline.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_Inline__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_Inline__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_Inline__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Inline__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -41476,12 +41476,12 @@ func (m MaybeUnionRepresentation_Keyed) IsAbsent() bool { func (m MaybeUnionRepresentation_Keyed) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation_Keyed) AsNode() ipld.Node { +func (m MaybeUnionRepresentation_Keyed) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -41495,42 +41495,42 @@ func (m MaybeUnionRepresentation_Keyed) Must() UnionRepresentation_Keyed { return &m.v } -var _ ipld.Node = (UnionRepresentation_Keyed)(&_UnionRepresentation_Keyed{}) +var _ datamodel.Node = (UnionRepresentation_Keyed)(&_UnionRepresentation_Keyed{}) var _ schema.TypedNode = (UnionRepresentation_Keyed)(&_UnionRepresentation_Keyed{}) -func (UnionRepresentation_Keyed) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation_Keyed) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation_Keyed) LookupByString(k string) (ipld.Node, error) { +func (n UnionRepresentation_Keyed) LookupByString(k string) (datamodel.Node, error) { var k2 _String if err := (_String__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n UnionRepresentation_Keyed) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation_Keyed) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(String) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.UnionRepresentation_Keyed", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.UnionRepresentation_Keyed", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (UnionRepresentation_Keyed) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation_Keyed) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Keyed"}.LookupByIndex(0) } -func (n UnionRepresentation_Keyed) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation_Keyed) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation_Keyed) MapIterator() ipld.MapIterator { +func (n UnionRepresentation_Keyed) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Keyed__MapItr{n, 0} } @@ -41539,9 +41539,9 @@ type _UnionRepresentation_Keyed__MapItr struct { idx int } -func (itr *_UnionRepresentation_Keyed__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_Keyed__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -41553,7 +41553,7 @@ func (itr *_UnionRepresentation_Keyed__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (UnionRepresentation_Keyed) ListIterator() ipld.ListIterator { +func (UnionRepresentation_Keyed) ListIterator() datamodel.ListIterator { return nil } func (n UnionRepresentation_Keyed) Length() int64 { @@ -41580,16 +41580,16 @@ func (UnionRepresentation_Keyed) AsString() (string, error) { func (UnionRepresentation_Keyed) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Keyed"}.AsBytes() } -func (UnionRepresentation_Keyed) AsLink() (ipld.Link, error) { +func (UnionRepresentation_Keyed) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Keyed"}.AsLink() } -func (UnionRepresentation_Keyed) Prototype() ipld.NodePrototype { +func (UnionRepresentation_Keyed) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Keyed__Prototype{} } type _UnionRepresentation_Keyed__Prototype struct{} -func (_UnionRepresentation_Keyed__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Keyed__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Keyed__Builder nb.Reset() return &nb @@ -41599,7 +41599,7 @@ type _UnionRepresentation_Keyed__Builder struct { _UnionRepresentation_Keyed__Assembler } -func (nb *_UnionRepresentation_Keyed__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation_Keyed__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -41626,7 +41626,7 @@ func (na *_UnionRepresentation_Keyed__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_UnionRepresentation_Keyed__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Keyed__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -41641,7 +41641,7 @@ func (na *_UnionRepresentation_Keyed__Assembler) BeginMap(sizeHint int64) (ipld. na.w.t = make([]_UnionRepresentation_Keyed__entry, 0, sizeHint) return na, nil } -func (_UnionRepresentation_Keyed__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Keyed__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Keyed"}.BeginList(0) } func (na *_UnionRepresentation_Keyed__Assembler) AssignNull() error { @@ -41673,10 +41673,10 @@ func (_UnionRepresentation_Keyed__Assembler) AssignString(string) error { func (_UnionRepresentation_Keyed__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Keyed"}.AssignBytes(nil) } -func (_UnionRepresentation_Keyed__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Keyed__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Keyed"}.AssignLink(nil) } -func (na *_UnionRepresentation_Keyed__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Keyed__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -41691,8 +41691,8 @@ func (na *_UnionRepresentation_Keyed__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Keyed", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Keyed", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -41709,7 +41709,7 @@ func (na *_UnionRepresentation_Keyed__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_UnionRepresentation_Keyed__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Keyed__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Keyed__Prototype{} } func (ma *_UnionRepresentation_Keyed__Assembler) keyFinishTidy() bool { @@ -41740,7 +41740,7 @@ func (ma *_UnionRepresentation_Keyed__Assembler) valueFinishTidy() bool { return false } } -func (ma *_UnionRepresentation_Keyed__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Keyed__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -41761,7 +41761,7 @@ func (ma *_UnionRepresentation_Keyed__Assembler) AssembleEntry(k string) (ipld.N return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _UnionRepresentation_Keyed__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -41772,7 +41772,7 @@ func (ma *_UnionRepresentation_Keyed__Assembler) AssembleEntry(k string) (ipld.N ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_UnionRepresentation_Keyed__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Keyed__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -41793,7 +41793,7 @@ func (ma *_UnionRepresentation_Keyed__Assembler) AssembleKey() ipld.NodeAssemble ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_UnionRepresentation_Keyed__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Keyed__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -41830,55 +41830,55 @@ func (ma *_UnionRepresentation_Keyed__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Keyed__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Keyed__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_Keyed__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Keyed__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeName__Prototype{} } func (UnionRepresentation_Keyed) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation_Keyed) Representation() ipld.Node { +func (n UnionRepresentation_Keyed) Representation() datamodel.Node { return (*_UnionRepresentation_Keyed__Repr)(n) } type _UnionRepresentation_Keyed__Repr _UnionRepresentation_Keyed -var _ ipld.Node = &_UnionRepresentation_Keyed__Repr{} +var _ datamodel.Node = &_UnionRepresentation_Keyed__Repr{} -func (_UnionRepresentation_Keyed__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation_Keyed__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_UnionRepresentation_Keyed__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_UnionRepresentation_Keyed__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (UnionRepresentation_Keyed)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (nr *_UnionRepresentation_Keyed__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_UnionRepresentation_Keyed__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (UnionRepresentation_Keyed)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (_UnionRepresentation_Keyed__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation_Keyed__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation_Keyed__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation_Keyed__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_UnionRepresentation_Keyed__Repr) MapIterator() ipld.MapIterator { +func (nr *_UnionRepresentation_Keyed__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Keyed__ReprMapItr{(UnionRepresentation_Keyed)(nr), 0} } type _UnionRepresentation_Keyed__ReprMapItr _UnionRepresentation_Keyed__MapItr -func (itr *_UnionRepresentation_Keyed__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_UnionRepresentation_Keyed__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_UnionRepresentation_Keyed__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(TypeName).Representation(), nil @@ -41887,7 +41887,7 @@ func (itr *_UnionRepresentation_Keyed__ReprMapItr) Done() bool { return (*_UnionRepresentation_Keyed__MapItr)(itr).Done() } -func (_UnionRepresentation_Keyed__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation_Keyed__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_UnionRepresentation_Keyed__Repr) Length() int64 { @@ -41914,16 +41914,16 @@ func (_UnionRepresentation_Keyed__Repr) AsString() (string, error) { func (_UnionRepresentation_Keyed__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr"}.AsBytes() } -func (_UnionRepresentation_Keyed__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation_Keyed__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr"}.AsLink() } -func (_UnionRepresentation_Keyed__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Keyed__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Keyed__ReprPrototype{} } type _UnionRepresentation_Keyed__ReprPrototype struct{} -func (_UnionRepresentation_Keyed__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Keyed__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Keyed__ReprBuilder nb.Reset() return &nb @@ -41933,7 +41933,7 @@ type _UnionRepresentation_Keyed__ReprBuilder struct { _UnionRepresentation_Keyed__ReprAssembler } -func (nb *_UnionRepresentation_Keyed__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation_Keyed__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -41960,7 +41960,7 @@ func (na *_UnionRepresentation_Keyed__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_UnionRepresentation_Keyed__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Keyed__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -41975,7 +41975,7 @@ func (na *_UnionRepresentation_Keyed__ReprAssembler) BeginMap(sizeHint int64) (i na.w.t = make([]_UnionRepresentation_Keyed__entry, 0, sizeHint) return na, nil } -func (_UnionRepresentation_Keyed__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Keyed__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr"}.BeginList(0) } func (na *_UnionRepresentation_Keyed__ReprAssembler) AssignNull() error { @@ -42007,10 +42007,10 @@ func (_UnionRepresentation_Keyed__ReprAssembler) AssignString(string) error { func (_UnionRepresentation_Keyed__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation_Keyed__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Keyed__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation_Keyed__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Keyed__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -42025,8 +42025,8 @@ func (na *_UnionRepresentation_Keyed__ReprAssembler) AssignNode(v ipld.Node) err *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Keyed.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -42043,7 +42043,7 @@ func (na *_UnionRepresentation_Keyed__ReprAssembler) AssignNode(v ipld.Node) err } return na.Finish() } -func (_UnionRepresentation_Keyed__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Keyed__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Keyed__ReprPrototype{} } func (ma *_UnionRepresentation_Keyed__ReprAssembler) keyFinishTidy() bool { @@ -42074,7 +42074,7 @@ func (ma *_UnionRepresentation_Keyed__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -42095,7 +42095,7 @@ func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleEntry(k string) (ip return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _UnionRepresentation_Keyed__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -42106,7 +42106,7 @@ func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleEntry(k string) (ip ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -42127,7 +42127,7 @@ func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleKey() ipld.NodeAsse ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Keyed__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -42164,10 +42164,10 @@ func (ma *_UnionRepresentation_Keyed__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Keyed__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Keyed__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__ReprPrototype{} } -func (ma *_UnionRepresentation_Keyed__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Keyed__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeName__ReprPrototype{} } @@ -42229,12 +42229,12 @@ func (m MaybeUnionRepresentation_Kinded) IsAbsent() bool { func (m MaybeUnionRepresentation_Kinded) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation_Kinded) AsNode() ipld.Node { +func (m MaybeUnionRepresentation_Kinded) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return &m.v default: @@ -42248,42 +42248,42 @@ func (m MaybeUnionRepresentation_Kinded) Must() UnionRepresentation_Kinded { return &m.v } -var _ ipld.Node = (UnionRepresentation_Kinded)(&_UnionRepresentation_Kinded{}) +var _ datamodel.Node = (UnionRepresentation_Kinded)(&_UnionRepresentation_Kinded{}) var _ schema.TypedNode = (UnionRepresentation_Kinded)(&_UnionRepresentation_Kinded{}) -func (UnionRepresentation_Kinded) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation_Kinded) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation_Kinded) LookupByString(k string) (ipld.Node, error) { +func (n UnionRepresentation_Kinded) LookupByString(k string) (datamodel.Node, error) { var k2 _RepresentationKind if err := (_RepresentationKind__Prototype{}).fromString(&k2, k); err != nil { return nil, err // TODO wrap in some kind of ErrInvalidKey } v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } return v, nil } -func (n UnionRepresentation_Kinded) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation_Kinded) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.(RepresentationKind) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"schemadmt.UnionRepresentation_Kinded", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"schemadmt.UnionRepresentation_Kinded", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } return v, nil } -func (UnionRepresentation_Kinded) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation_Kinded) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Kinded"}.LookupByIndex(0) } -func (n UnionRepresentation_Kinded) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation_Kinded) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation_Kinded) MapIterator() ipld.MapIterator { +func (n UnionRepresentation_Kinded) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Kinded__MapItr{n, 0} } @@ -42292,9 +42292,9 @@ type _UnionRepresentation_Kinded__MapItr struct { idx int } -func (itr *_UnionRepresentation_Kinded__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_Kinded__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k @@ -42306,7 +42306,7 @@ func (itr *_UnionRepresentation_Kinded__MapItr) Done() bool { return itr.idx >= len(itr.n.t) } -func (UnionRepresentation_Kinded) ListIterator() ipld.ListIterator { +func (UnionRepresentation_Kinded) ListIterator() datamodel.ListIterator { return nil } func (n UnionRepresentation_Kinded) Length() int64 { @@ -42333,16 +42333,16 @@ func (UnionRepresentation_Kinded) AsString() (string, error) { func (UnionRepresentation_Kinded) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Kinded"}.AsBytes() } -func (UnionRepresentation_Kinded) AsLink() (ipld.Link, error) { +func (UnionRepresentation_Kinded) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Kinded"}.AsLink() } -func (UnionRepresentation_Kinded) Prototype() ipld.NodePrototype { +func (UnionRepresentation_Kinded) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Kinded__Prototype{} } type _UnionRepresentation_Kinded__Prototype struct{} -func (_UnionRepresentation_Kinded__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Kinded__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Kinded__Builder nb.Reset() return &nb @@ -42352,7 +42352,7 @@ type _UnionRepresentation_Kinded__Builder struct { _UnionRepresentation_Kinded__Assembler } -func (nb *_UnionRepresentation_Kinded__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation_Kinded__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -42379,7 +42379,7 @@ func (na *_UnionRepresentation_Kinded__Assembler) reset() { na.ka.reset() na.va.reset() } -func (na *_UnionRepresentation_Kinded__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Kinded__Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -42394,7 +42394,7 @@ func (na *_UnionRepresentation_Kinded__Assembler) BeginMap(sizeHint int64) (ipld na.w.t = make([]_UnionRepresentation_Kinded__entry, 0, sizeHint) return na, nil } -func (_UnionRepresentation_Kinded__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Kinded__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Kinded"}.BeginList(0) } func (na *_UnionRepresentation_Kinded__Assembler) AssignNull() error { @@ -42426,10 +42426,10 @@ func (_UnionRepresentation_Kinded__Assembler) AssignString(string) error { func (_UnionRepresentation_Kinded__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Kinded"}.AssignBytes(nil) } -func (_UnionRepresentation_Kinded__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Kinded__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Kinded"}.AssignLink(nil) } -func (na *_UnionRepresentation_Kinded__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Kinded__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -42444,8 +42444,8 @@ func (na *_UnionRepresentation_Kinded__Assembler) AssignNode(v ipld.Node) error *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Kinded", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Kinded", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -42462,7 +42462,7 @@ func (na *_UnionRepresentation_Kinded__Assembler) AssignNode(v ipld.Node) error } return na.Finish() } -func (_UnionRepresentation_Kinded__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Kinded__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Kinded__Prototype{} } func (ma *_UnionRepresentation_Kinded__Assembler) keyFinishTidy() bool { @@ -42493,7 +42493,7 @@ func (ma *_UnionRepresentation_Kinded__Assembler) valueFinishTidy() bool { return false } } -func (ma *_UnionRepresentation_Kinded__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Kinded__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -42514,7 +42514,7 @@ func (ma *_UnionRepresentation_Kinded__Assembler) AssembleEntry(k string) (ipld. return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _UnionRepresentation_Kinded__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -42525,7 +42525,7 @@ func (ma *_UnionRepresentation_Kinded__Assembler) AssembleEntry(k string) (ipld. ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_UnionRepresentation_Kinded__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Kinded__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -42546,7 +42546,7 @@ func (ma *_UnionRepresentation_Kinded__Assembler) AssembleKey() ipld.NodeAssembl ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_UnionRepresentation_Kinded__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Kinded__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -42583,55 +42583,55 @@ func (ma *_UnionRepresentation_Kinded__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Kinded__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Kinded__Assembler) KeyPrototype() datamodel.NodePrototype { return _RepresentationKind__Prototype{} } -func (ma *_UnionRepresentation_Kinded__Assembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Kinded__Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeName__Prototype{} } func (UnionRepresentation_Kinded) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation_Kinded) Representation() ipld.Node { +func (n UnionRepresentation_Kinded) Representation() datamodel.Node { return (*_UnionRepresentation_Kinded__Repr)(n) } type _UnionRepresentation_Kinded__Repr _UnionRepresentation_Kinded -var _ ipld.Node = &_UnionRepresentation_Kinded__Repr{} +var _ datamodel.Node = &_UnionRepresentation_Kinded__Repr{} -func (_UnionRepresentation_Kinded__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation_Kinded__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (nr *_UnionRepresentation_Kinded__Repr) LookupByString(k string) (ipld.Node, error) { +func (nr *_UnionRepresentation_Kinded__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := (UnionRepresentation_Kinded)(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (nr *_UnionRepresentation_Kinded__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { +func (nr *_UnionRepresentation_Kinded__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := (UnionRepresentation_Kinded)(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.(TypeName).Representation(), nil } -func (_UnionRepresentation_Kinded__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation_Kinded__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation_Kinded__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation_Kinded__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (nr *_UnionRepresentation_Kinded__Repr) MapIterator() ipld.MapIterator { +func (nr *_UnionRepresentation_Kinded__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_Kinded__ReprMapItr{(UnionRepresentation_Kinded)(nr), 0} } type _UnionRepresentation_Kinded__ReprMapItr _UnionRepresentation_Kinded__MapItr -func (itr *_UnionRepresentation_Kinded__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { +func (itr *_UnionRepresentation_Kinded__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_UnionRepresentation_Kinded__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.(TypeName).Representation(), nil @@ -42640,7 +42640,7 @@ func (itr *_UnionRepresentation_Kinded__ReprMapItr) Done() bool { return (*_UnionRepresentation_Kinded__MapItr)(itr).Done() } -func (_UnionRepresentation_Kinded__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation_Kinded__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_UnionRepresentation_Kinded__Repr) Length() int64 { @@ -42667,16 +42667,16 @@ func (_UnionRepresentation_Kinded__Repr) AsString() (string, error) { func (_UnionRepresentation_Kinded__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr"}.AsBytes() } -func (_UnionRepresentation_Kinded__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation_Kinded__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr"}.AsLink() } -func (_UnionRepresentation_Kinded__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Kinded__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Kinded__ReprPrototype{} } type _UnionRepresentation_Kinded__ReprPrototype struct{} -func (_UnionRepresentation_Kinded__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_Kinded__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_Kinded__ReprBuilder nb.Reset() return &nb @@ -42686,7 +42686,7 @@ type _UnionRepresentation_Kinded__ReprBuilder struct { _UnionRepresentation_Kinded__ReprAssembler } -func (nb *_UnionRepresentation_Kinded__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation_Kinded__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -42713,7 +42713,7 @@ func (na *_UnionRepresentation_Kinded__ReprAssembler) reset() { na.ka.reset() na.va.reset() } -func (na *_UnionRepresentation_Kinded__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_Kinded__ReprAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -42728,7 +42728,7 @@ func (na *_UnionRepresentation_Kinded__ReprAssembler) BeginMap(sizeHint int64) ( na.w.t = make([]_UnionRepresentation_Kinded__entry, 0, sizeHint) return na, nil } -func (_UnionRepresentation_Kinded__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_Kinded__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr"}.BeginList(0) } func (na *_UnionRepresentation_Kinded__ReprAssembler) AssignNull() error { @@ -42760,10 +42760,10 @@ func (_UnionRepresentation_Kinded__ReprAssembler) AssignString(string) error { func (_UnionRepresentation_Kinded__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation_Kinded__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_Kinded__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation_Kinded__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_Kinded__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -42778,8 +42778,8 @@ func (na *_UnionRepresentation_Kinded__ReprAssembler) AssignNode(v ipld.Node) er *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_Kinded.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -42796,7 +42796,7 @@ func (na *_UnionRepresentation_Kinded__ReprAssembler) AssignNode(v ipld.Node) er } return na.Finish() } -func (_UnionRepresentation_Kinded__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_Kinded__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_Kinded__ReprPrototype{} } func (ma *_UnionRepresentation_Kinded__ReprAssembler) keyFinishTidy() bool { @@ -42827,7 +42827,7 @@ func (ma *_UnionRepresentation_Kinded__ReprAssembler) valueFinishTidy() bool { return false } } -func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -42848,7 +42848,7 @@ func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleEntry(k string) (i return nil, err // TODO wrap in some kind of ErrInvalidKey } if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _UnionRepresentation_Kinded__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -42859,7 +42859,7 @@ func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleEntry(k string) (i ma.va.m = &ma.cm return &ma.va, nil } -func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -42880,7 +42880,7 @@ func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleKey() ipld.NodeAss ma.ka.w = &ma.w.t[len(ma.w.t)-1].k return &ma.ka } -func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_Kinded__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -42917,10 +42917,10 @@ func (ma *_UnionRepresentation_Kinded__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_Kinded__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_Kinded__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _RepresentationKind__ReprPrototype{} } -func (ma *_UnionRepresentation_Kinded__ReprAssembler) ValuePrototype(_ string) ipld.NodePrototype { +func (ma *_UnionRepresentation_Kinded__ReprAssembler) ValuePrototype(_ string) datamodel.NodePrototype { return _TypeName__ReprPrototype{} } @@ -42943,12 +42943,12 @@ func (m MaybeUnionRepresentation_StringPrefix) IsAbsent() bool { func (m MaybeUnionRepresentation_StringPrefix) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnionRepresentation_StringPrefix) AsNode() ipld.Node { +func (m MaybeUnionRepresentation_StringPrefix) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -42965,34 +42965,34 @@ func (m MaybeUnionRepresentation_StringPrefix) Must() UnionRepresentation_String var ( fieldName__UnionRepresentation_StringPrefix_DiscriminantTable = _String{"discriminantTable"} ) -var _ ipld.Node = (UnionRepresentation_StringPrefix)(&_UnionRepresentation_StringPrefix{}) +var _ datamodel.Node = (UnionRepresentation_StringPrefix)(&_UnionRepresentation_StringPrefix{}) var _ schema.TypedNode = (UnionRepresentation_StringPrefix)(&_UnionRepresentation_StringPrefix{}) -func (UnionRepresentation_StringPrefix) Kind() ipld.Kind { - return ipld.Kind_Map +func (UnionRepresentation_StringPrefix) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n UnionRepresentation_StringPrefix) LookupByString(key string) (ipld.Node, error) { +func (n UnionRepresentation_StringPrefix) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantTable": return &n.discriminantTable, nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n UnionRepresentation_StringPrefix) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n UnionRepresentation_StringPrefix) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (UnionRepresentation_StringPrefix) LookupByIndex(idx int64) (ipld.Node, error) { +func (UnionRepresentation_StringPrefix) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_StringPrefix"}.LookupByIndex(0) } -func (n UnionRepresentation_StringPrefix) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n UnionRepresentation_StringPrefix) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n UnionRepresentation_StringPrefix) MapIterator() ipld.MapIterator { +func (n UnionRepresentation_StringPrefix) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_StringPrefix__MapItr{n, 0} } @@ -43001,9 +43001,9 @@ type _UnionRepresentation_StringPrefix__MapItr struct { idx int } -func (itr *_UnionRepresentation_StringPrefix__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_StringPrefix__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -43019,7 +43019,7 @@ func (itr *_UnionRepresentation_StringPrefix__MapItr) Done() bool { return itr.idx >= 1 } -func (UnionRepresentation_StringPrefix) ListIterator() ipld.ListIterator { +func (UnionRepresentation_StringPrefix) ListIterator() datamodel.ListIterator { return nil } func (UnionRepresentation_StringPrefix) Length() int64 { @@ -43046,16 +43046,16 @@ func (UnionRepresentation_StringPrefix) AsString() (string, error) { func (UnionRepresentation_StringPrefix) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_StringPrefix"}.AsBytes() } -func (UnionRepresentation_StringPrefix) AsLink() (ipld.Link, error) { +func (UnionRepresentation_StringPrefix) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_StringPrefix"}.AsLink() } -func (UnionRepresentation_StringPrefix) Prototype() ipld.NodePrototype { +func (UnionRepresentation_StringPrefix) Prototype() datamodel.NodePrototype { return _UnionRepresentation_StringPrefix__Prototype{} } type _UnionRepresentation_StringPrefix__Prototype struct{} -func (_UnionRepresentation_StringPrefix__Prototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_StringPrefix__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_StringPrefix__Builder nb.Reset() return &nb @@ -43065,7 +43065,7 @@ type _UnionRepresentation_StringPrefix__Builder struct { _UnionRepresentation_StringPrefix__Assembler } -func (nb *_UnionRepresentation_StringPrefix__Builder) Build() ipld.Node { +func (nb *_UnionRepresentation_StringPrefix__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -43099,7 +43099,7 @@ var ( fieldBits__UnionRepresentation_StringPrefix_sufficient = 0 + 1<<0 ) -func (na *_UnionRepresentation_StringPrefix__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_StringPrefix__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -43112,7 +43112,7 @@ func (na *_UnionRepresentation_StringPrefix__Assembler) BeginMap(int64) (ipld.Ma } return na, nil } -func (_UnionRepresentation_StringPrefix__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_StringPrefix__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix"}.BeginList(0) } func (na *_UnionRepresentation_StringPrefix__Assembler) AssignNull() error { @@ -43144,10 +43144,10 @@ func (_UnionRepresentation_StringPrefix__Assembler) AssignString(string) error { func (_UnionRepresentation_StringPrefix__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix"}.AssignBytes(nil) } -func (_UnionRepresentation_StringPrefix__Assembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_StringPrefix__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix"}.AssignLink(nil) } -func (na *_UnionRepresentation_StringPrefix__Assembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_StringPrefix__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -43167,8 +43167,8 @@ func (na *_UnionRepresentation_StringPrefix__Assembler) AssignNode(v ipld.Node) *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_StringPrefix", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_StringPrefix", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -43185,7 +43185,7 @@ func (na *_UnionRepresentation_StringPrefix__Assembler) AssignNode(v ipld.Node) } return na.Finish() } -func (_UnionRepresentation_StringPrefix__Assembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_StringPrefix__Assembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_StringPrefix__Prototype{} } func (ma *_UnionRepresentation_StringPrefix__Assembler) valueFinishTidy() bool { @@ -43204,7 +43204,7 @@ func (ma *_UnionRepresentation_StringPrefix__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -43222,7 +43222,7 @@ func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleEntry(k string) switch k { case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable} } ma.s += fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable ma.state = maState_midValue @@ -43231,9 +43231,9 @@ func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleEntry(k string) ma.ca_discriminantTable.m = &ma.cm return &ma.ca_discriminantTable, nil } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix", Key: &_String{k}} } -func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -43251,7 +43251,7 @@ func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleKey() ipld.NodeA ma.state = maState_midKey return (*_UnionRepresentation_StringPrefix__KeyAssembler)(ma) } -func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_StringPrefix__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -43290,7 +43290,7 @@ func (ma *_UnionRepresentation_StringPrefix__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_StringPrefix_sufficient != fieldBits__UnionRepresentation_StringPrefix_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable == 0 { err.Missing = append(err.Missing, "discriminantTable") } @@ -43300,19 +43300,19 @@ func (ma *_UnionRepresentation_StringPrefix__Assembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_StringPrefix__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_StringPrefix__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_StringPrefix__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_StringPrefix__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _UnionRepresentation_StringPrefix__KeyAssembler _UnionRepresentation_StringPrefix__Assembler -func (_UnionRepresentation_StringPrefix__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_StringPrefix__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_StringPrefix__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_StringPrefix__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_StringPrefix__KeyAssembler) AssignNull() error { @@ -43334,36 +43334,36 @@ func (ka *_UnionRepresentation_StringPrefix__KeyAssembler) AssignString(k string switch k { case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable} } ka.s += fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable ka.state = maState_expectValue ka.f = 0 return nil default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix", Key: &_String{k}} } } func (_UnionRepresentation_StringPrefix__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_StringPrefix__KeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_StringPrefix__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_StringPrefix__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_StringPrefix__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_StringPrefix__KeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_StringPrefix__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (UnionRepresentation_StringPrefix) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n UnionRepresentation_StringPrefix) Representation() ipld.Node { +func (n UnionRepresentation_StringPrefix) Representation() datamodel.Node { return (*_UnionRepresentation_StringPrefix__Repr)(n) } @@ -43372,33 +43372,33 @@ type _UnionRepresentation_StringPrefix__Repr _UnionRepresentation_StringPrefix var ( fieldName__UnionRepresentation_StringPrefix_DiscriminantTable_serial = _String{"discriminantTable"} ) -var _ ipld.Node = &_UnionRepresentation_StringPrefix__Repr{} +var _ datamodel.Node = &_UnionRepresentation_StringPrefix__Repr{} -func (_UnionRepresentation_StringPrefix__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_UnionRepresentation_StringPrefix__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_UnionRepresentation_StringPrefix__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_UnionRepresentation_StringPrefix__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { case "discriminantTable": return n.discriminantTable.Representation(), nil default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_UnionRepresentation_StringPrefix__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_UnionRepresentation_StringPrefix__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_UnionRepresentation_StringPrefix__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_UnionRepresentation_StringPrefix__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr"}.LookupByIndex(0) } -func (n _UnionRepresentation_StringPrefix__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _UnionRepresentation_StringPrefix__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_UnionRepresentation_StringPrefix__Repr) MapIterator() ipld.MapIterator { +func (n *_UnionRepresentation_StringPrefix__Repr) MapIterator() datamodel.MapIterator { return &_UnionRepresentation_StringPrefix__ReprMapItr{n, 0} } @@ -43407,9 +43407,9 @@ type _UnionRepresentation_StringPrefix__ReprMapItr struct { idx int } -func (itr *_UnionRepresentation_StringPrefix__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { +func (itr *_UnionRepresentation_StringPrefix__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= 1 { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { case 0: @@ -43424,7 +43424,7 @@ func (itr *_UnionRepresentation_StringPrefix__ReprMapItr) Next() (k ipld.Node, v func (itr *_UnionRepresentation_StringPrefix__ReprMapItr) Done() bool { return itr.idx >= 1 } -func (_UnionRepresentation_StringPrefix__Repr) ListIterator() ipld.ListIterator { +func (_UnionRepresentation_StringPrefix__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_UnionRepresentation_StringPrefix__Repr) Length() int64 { @@ -43452,16 +43452,16 @@ func (_UnionRepresentation_StringPrefix__Repr) AsString() (string, error) { func (_UnionRepresentation_StringPrefix__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr"}.AsBytes() } -func (_UnionRepresentation_StringPrefix__Repr) AsLink() (ipld.Link, error) { +func (_UnionRepresentation_StringPrefix__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr"}.AsLink() } -func (_UnionRepresentation_StringPrefix__Repr) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_StringPrefix__Repr) Prototype() datamodel.NodePrototype { return _UnionRepresentation_StringPrefix__ReprPrototype{} } type _UnionRepresentation_StringPrefix__ReprPrototype struct{} -func (_UnionRepresentation_StringPrefix__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_UnionRepresentation_StringPrefix__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _UnionRepresentation_StringPrefix__ReprBuilder nb.Reset() return &nb @@ -43471,7 +43471,7 @@ type _UnionRepresentation_StringPrefix__ReprBuilder struct { _UnionRepresentation_StringPrefix__ReprAssembler } -func (nb *_UnionRepresentation_StringPrefix__ReprBuilder) Build() ipld.Node { +func (nb *_UnionRepresentation_StringPrefix__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -43499,7 +43499,7 @@ func (na *_UnionRepresentation_StringPrefix__ReprAssembler) reset() { na.s = 0 na.ca_discriminantTable.reset() } -func (na *_UnionRepresentation_StringPrefix__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_UnionRepresentation_StringPrefix__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -43512,7 +43512,7 @@ func (na *_UnionRepresentation_StringPrefix__ReprAssembler) BeginMap(int64) (ipl } return na, nil } -func (_UnionRepresentation_StringPrefix__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_StringPrefix__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr"}.BeginList(0) } func (na *_UnionRepresentation_StringPrefix__ReprAssembler) AssignNull() error { @@ -43544,10 +43544,10 @@ func (_UnionRepresentation_StringPrefix__ReprAssembler) AssignString(string) err func (_UnionRepresentation_StringPrefix__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr"}.AssignBytes(nil) } -func (_UnionRepresentation_StringPrefix__ReprAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_StringPrefix__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr"}.AssignLink(nil) } -func (na *_UnionRepresentation_StringPrefix__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_UnionRepresentation_StringPrefix__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -43567,8 +43567,8 @@ func (na *_UnionRepresentation_StringPrefix__ReprAssembler) AssignNode(v ipld.No *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -43585,7 +43585,7 @@ func (na *_UnionRepresentation_StringPrefix__ReprAssembler) AssignNode(v ipld.No } return na.Finish() } -func (_UnionRepresentation_StringPrefix__ReprAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_StringPrefix__ReprAssembler) Prototype() datamodel.NodePrototype { return _UnionRepresentation_StringPrefix__ReprPrototype{} } func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) valueFinishTidy() bool { @@ -43603,7 +43603,7 @@ func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) valueFinishTidy() bo panic("unreachable") } } -func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -43621,7 +43621,7 @@ func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleEntry(k stri switch k { case "discriminantTable": if ma.s&fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable_serial} } ma.s += fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable ma.state = maState_midValue @@ -43631,9 +43631,9 @@ func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleEntry(k stri return &ma.ca_discriminantTable, nil default: } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr", Key: &_String{k}} } -func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -43651,7 +43651,7 @@ func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleKey() ipld.N ma.state = maState_midKey return (*_UnionRepresentation_StringPrefix__ReprKeyAssembler)(ma) } -func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -43690,7 +43690,7 @@ func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__UnionRepresentation_StringPrefix_sufficient != fieldBits__UnionRepresentation_StringPrefix_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} if ma.s&fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable == 0 { err.Missing = append(err.Missing, "discriminantTable") } @@ -43700,19 +43700,19 @@ func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) Finish() error { *ma.m = schema.Maybe_Value return nil } -func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_UnionRepresentation_StringPrefix__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _UnionRepresentation_StringPrefix__ReprKeyAssembler _UnionRepresentation_StringPrefix__ReprAssembler -func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr.KeyAssembler"}.BeginMap(0) } -func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr.KeyAssembler"}.BeginList(0) } func (na *_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignNull() error { @@ -43734,29 +43734,29 @@ func (ka *_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignString(k st switch k { case "discriminantTable": if ka.s&fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__UnionRepresentation_StringPrefix_DiscriminantTable_serial} } ka.s += fieldBit__UnionRepresentation_StringPrefix_DiscriminantTable ka.state = maState_expectValue ka.f = 0 return nil } - return ipld.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr", Key: &_String{k}} } func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.UnionRepresentation_StringPrefix.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_UnionRepresentation_StringPrefix__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_UnionRepresentation_StringPrefix__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } @@ -43775,12 +43775,12 @@ func (m MaybeUnit) IsAbsent() bool { func (m MaybeUnit) Exists() bool { return m.m == schema.Maybe_Value } -func (m MaybeUnit) AsNode() ipld.Node { +func (m MaybeUnit) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return m.v default: @@ -43795,32 +43795,32 @@ func (m MaybeUnit) Must() Unit { } var () -var _ ipld.Node = (Unit)(&_Unit{}) +var _ datamodel.Node = (Unit)(&_Unit{}) var _ schema.TypedNode = (Unit)(&_Unit{}) -func (Unit) Kind() ipld.Kind { - return ipld.Kind_Map +func (Unit) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n Unit) LookupByString(key string) (ipld.Node, error) { +func (n Unit) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n Unit) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n Unit) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (Unit) LookupByIndex(idx int64) (ipld.Node, error) { +func (Unit) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Unit"}.LookupByIndex(0) } -func (n Unit) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n Unit) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n Unit) MapIterator() ipld.MapIterator { +func (n Unit) MapIterator() datamodel.MapIterator { return &_Unit__MapItr{n, 0} } @@ -43829,15 +43829,15 @@ type _Unit__MapItr struct { idx int } -func (itr *_Unit__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_Unit__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_Unit__MapItr) Done() bool { return itr.idx >= 0 } -func (Unit) ListIterator() ipld.ListIterator { +func (Unit) ListIterator() datamodel.ListIterator { return nil } func (Unit) Length() int64 { @@ -43864,16 +43864,16 @@ func (Unit) AsString() (string, error) { func (Unit) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Unit"}.AsBytes() } -func (Unit) AsLink() (ipld.Link, error) { +func (Unit) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Unit"}.AsLink() } -func (Unit) Prototype() ipld.NodePrototype { +func (Unit) Prototype() datamodel.NodePrototype { return _Unit__Prototype{} } type _Unit__Prototype struct{} -func (_Unit__Prototype) NewBuilder() ipld.NodeBuilder { +func (_Unit__Prototype) NewBuilder() datamodel.NodeBuilder { var nb _Unit__Builder nb.Reset() return &nb @@ -43883,7 +43883,7 @@ type _Unit__Builder struct { _Unit__Assembler } -func (nb *_Unit__Builder) Build() ipld.Node { +func (nb *_Unit__Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -43914,7 +43914,7 @@ var ( fieldBits__Unit_sufficient = 0 ) -func (na *_Unit__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_Unit__Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -43927,7 +43927,7 @@ func (na *_Unit__Assembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_Unit__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Unit__Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Unit"}.BeginList(0) } func (na *_Unit__Assembler) AssignNull() error { @@ -43959,10 +43959,10 @@ func (_Unit__Assembler) AssignString(string) error { func (_Unit__Assembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Unit"}.AssignBytes(nil) } -func (_Unit__Assembler) AssignLink(ipld.Link) error { +func (_Unit__Assembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Unit"}.AssignLink(nil) } -func (na *_Unit__Assembler) AssignNode(v ipld.Node) error { +func (na *_Unit__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -43982,8 +43982,8 @@ func (na *_Unit__Assembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Unit", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Unit", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -44000,7 +44000,7 @@ func (na *_Unit__Assembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Unit__Assembler) Prototype() ipld.NodePrototype { +func (_Unit__Assembler) Prototype() datamodel.NodePrototype { return _Unit__Prototype{} } func (ma *_Unit__Assembler) valueFinishTidy() bool { @@ -44009,7 +44009,7 @@ func (ma *_Unit__Assembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_Unit__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Unit__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -44024,9 +44024,9 @@ func (ma *_Unit__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.Unit", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.Unit", Key: &_String{k}} } -func (ma *_Unit__Assembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Unit__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -44044,7 +44044,7 @@ func (ma *_Unit__Assembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_Unit__KeyAssembler)(ma) } -func (ma *_Unit__Assembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Unit__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -44079,26 +44079,26 @@ func (ma *_Unit__Assembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__Unit_sufficient != fieldBits__Unit_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_Unit__Assembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Unit__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Unit__Assembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_Unit__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } type _Unit__KeyAssembler _Unit__Assembler -func (_Unit__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Unit__KeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Unit.KeyAssembler"}.BeginMap(0) } -func (_Unit__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Unit__KeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Unit.KeyAssembler"}.BeginList(0) } func (na *_Unit__KeyAssembler) AssignNull() error { @@ -44119,60 +44119,60 @@ func (ka *_Unit__KeyAssembler) AssignString(k string) error { } switch k { default: - return ipld.ErrInvalidKey{TypeName: "schemadmt.Unit", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.Unit", Key: &_String{k}} } } func (_Unit__KeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.Unit.KeyAssembler"}.AssignBytes(nil) } -func (_Unit__KeyAssembler) AssignLink(ipld.Link) error { +func (_Unit__KeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.Unit.KeyAssembler"}.AssignLink(nil) } -func (ka *_Unit__KeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_Unit__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_Unit__KeyAssembler) Prototype() ipld.NodePrototype { +func (_Unit__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } func (Unit) Type() schema.Type { return nil /*TODO:typelit*/ } -func (n Unit) Representation() ipld.Node { +func (n Unit) Representation() datamodel.Node { return (*_Unit__Repr)(n) } type _Unit__Repr _Unit var () -var _ ipld.Node = &_Unit__Repr{} +var _ datamodel.Node = &_Unit__Repr{} -func (_Unit__Repr) Kind() ipld.Kind { - return ipld.Kind_Map +func (_Unit__Repr) Kind() datamodel.Kind { + return datamodel.Kind_Map } -func (n *_Unit__Repr) LookupByString(key string) (ipld.Node, error) { +func (n *_Unit__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } -func (n *_Unit__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { +func (n *_Unit__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err } return n.LookupByString(ks) } -func (_Unit__Repr) LookupByIndex(idx int64) (ipld.Node, error) { +func (_Unit__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.Map{TypeName: "schemadmt.Unit.Repr"}.LookupByIndex(0) } -func (n _Unit__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { +func (n _Unit__Repr) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } -func (n *_Unit__Repr) MapIterator() ipld.MapIterator { +func (n *_Unit__Repr) MapIterator() datamodel.MapIterator { return &_Unit__ReprMapItr{n, 0} } @@ -44181,14 +44181,14 @@ type _Unit__ReprMapItr struct { idx int } -func (itr *_Unit__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { - return nil, nil, ipld.ErrIteratorOverread{} +func (itr *_Unit__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { + return nil, nil, datamodel.ErrIteratorOverread{} } func (itr *_Unit__ReprMapItr) Done() bool { return itr.idx >= 0 } -func (_Unit__Repr) ListIterator() ipld.ListIterator { +func (_Unit__Repr) ListIterator() datamodel.ListIterator { return nil } func (rn *_Unit__Repr) Length() int64 { @@ -44216,16 +44216,16 @@ func (_Unit__Repr) AsString() (string, error) { func (_Unit__Repr) AsBytes() ([]byte, error) { return mixins.Map{TypeName: "schemadmt.Unit.Repr"}.AsBytes() } -func (_Unit__Repr) AsLink() (ipld.Link, error) { +func (_Unit__Repr) AsLink() (datamodel.Link, error) { return mixins.Map{TypeName: "schemadmt.Unit.Repr"}.AsLink() } -func (_Unit__Repr) Prototype() ipld.NodePrototype { +func (_Unit__Repr) Prototype() datamodel.NodePrototype { return _Unit__ReprPrototype{} } type _Unit__ReprPrototype struct{} -func (_Unit__ReprPrototype) NewBuilder() ipld.NodeBuilder { +func (_Unit__ReprPrototype) NewBuilder() datamodel.NodeBuilder { var nb _Unit__ReprBuilder nb.Reset() return &nb @@ -44235,7 +44235,7 @@ type _Unit__ReprBuilder struct { _Unit__ReprAssembler } -func (nb *_Unit__ReprBuilder) Build() ipld.Node { +func (nb *_Unit__ReprBuilder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -44261,7 +44261,7 @@ func (na *_Unit__ReprAssembler) reset() { na.state = maState_initial na.s = 0 } -func (na *_Unit__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { +func (na *_Unit__ReprAssembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -44274,7 +44274,7 @@ func (na *_Unit__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) { } return na, nil } -func (_Unit__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Unit__ReprAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.MapAssembler{TypeName: "schemadmt.Unit.Repr"}.BeginList(0) } func (na *_Unit__ReprAssembler) AssignNull() error { @@ -44306,10 +44306,10 @@ func (_Unit__ReprAssembler) AssignString(string) error { func (_Unit__ReprAssembler) AssignBytes([]byte) error { return mixins.MapAssembler{TypeName: "schemadmt.Unit.Repr"}.AssignBytes(nil) } -func (_Unit__ReprAssembler) AssignLink(ipld.Link) error { +func (_Unit__ReprAssembler) AssignLink(datamodel.Link) error { return mixins.MapAssembler{TypeName: "schemadmt.Unit.Repr"}.AssignLink(nil) } -func (na *_Unit__ReprAssembler) AssignNode(v ipld.Node) error { +func (na *_Unit__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -44329,8 +44329,8 @@ func (na *_Unit__ReprAssembler) AssignNode(v ipld.Node) error { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "schemadmt.Unit.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "schemadmt.Unit.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -44347,7 +44347,7 @@ func (na *_Unit__ReprAssembler) AssignNode(v ipld.Node) error { } return na.Finish() } -func (_Unit__ReprAssembler) Prototype() ipld.NodePrototype { +func (_Unit__ReprAssembler) Prototype() datamodel.NodePrototype { return _Unit__ReprPrototype{} } func (ma *_Unit__ReprAssembler) valueFinishTidy() bool { @@ -44356,7 +44356,7 @@ func (ma *_Unit__ReprAssembler) valueFinishTidy() bool { panic("unreachable") } } -func (ma *_Unit__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { +func (ma *_Unit__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -44371,9 +44371,9 @@ func (ma *_Unit__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, err case maState_finished: panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished") } - return nil, ipld.ErrInvalidKey{TypeName: "schemadmt.Unit.Repr", Key: &_String{k}} + return nil, schema.ErrInvalidKey{TypeName: "schemadmt.Unit.Repr", Key: &_String{k}} } -func (ma *_Unit__ReprAssembler) AssembleKey() ipld.NodeAssembler { +func (ma *_Unit__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -44391,7 +44391,7 @@ func (ma *_Unit__ReprAssembler) AssembleKey() ipld.NodeAssembler { ma.state = maState_midKey return (*_Unit__ReprKeyAssembler)(ma) } -func (ma *_Unit__ReprAssembler) AssembleValue() ipld.NodeAssembler { +func (ma *_Unit__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -44426,26 +44426,26 @@ func (ma *_Unit__ReprAssembler) Finish() error { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s&fieldBits__Unit_sufficient != fieldBits__Unit_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} return err } ma.state = maState_finished *ma.m = schema.Maybe_Value return nil } -func (ma *_Unit__ReprAssembler) KeyPrototype() ipld.NodePrototype { +func (ma *_Unit__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } -func (ma *_Unit__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { +func (ma *_Unit__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } type _Unit__ReprKeyAssembler _Unit__ReprAssembler -func (_Unit__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { +func (_Unit__ReprKeyAssembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Unit.Repr.KeyAssembler"}.BeginMap(0) } -func (_Unit__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { +func (_Unit__ReprKeyAssembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.StringAssembler{TypeName: "schemadmt.Unit.Repr.KeyAssembler"}.BeginList(0) } func (na *_Unit__ReprKeyAssembler) AssignNull() error { @@ -44464,21 +44464,21 @@ func (ka *_Unit__ReprKeyAssembler) AssignString(k string) error { if ka.state != maState_midKey { panic("misuse: KeyAssembler held beyond its valid lifetime") } - return ipld.ErrInvalidKey{TypeName: "schemadmt.Unit.Repr", Key: &_String{k}} + return schema.ErrInvalidKey{TypeName: "schemadmt.Unit.Repr", Key: &_String{k}} } func (_Unit__ReprKeyAssembler) AssignBytes([]byte) error { return mixins.StringAssembler{TypeName: "schemadmt.Unit.Repr.KeyAssembler"}.AssignBytes(nil) } -func (_Unit__ReprKeyAssembler) AssignLink(ipld.Link) error { +func (_Unit__ReprKeyAssembler) AssignLink(datamodel.Link) error { return mixins.StringAssembler{TypeName: "schemadmt.Unit.Repr.KeyAssembler"}.AssignLink(nil) } -func (ka *_Unit__ReprKeyAssembler) AssignNode(v ipld.Node) error { +func (ka *_Unit__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } -func (_Unit__ReprKeyAssembler) Prototype() ipld.NodePrototype { +func (_Unit__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } diff --git a/schema/dmt/ipldsch_types.go b/schema/dmt/ipldsch_types.go index 897c20ea..96380c8b 100644 --- a/schema/dmt/ipldsch_types.go +++ b/schema/dmt/ipldsch_types.go @@ -3,10 +3,10 @@ package schemadmt // Code generated by go-ipld-prime gengo. DO NOT EDIT. import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) -var _ ipld.Node = nil // suppress errors when this dependency is not referenced +var _ datamodel.Node = nil // suppress errors when this dependency is not referenced // Type is a struct embeding a NodePrototype/Type for every Node implementation in this package. // One of its major uses is to start the construction of a value. // You can use it like this: diff --git a/schema/errors.go b/schema/errors.go index 340ed5d9..9135fe99 100644 --- a/schema/errors.go +++ b/schema/errors.go @@ -2,24 +2,90 @@ package schema import ( "fmt" + "strings" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // TODO: errors in this package remain somewhat slapdash. // -// - ipld.ErrUnmatchable is used as a catch-all in some places, and contains who-knows-what values wrapped in the Reason field. +// - datamodel.ErrUnmatchable is used as a catch-all in some places, and contains who-knows-what values wrapped in the Reason field. // - sometimes this wraps things like strconv errors... and on the one hand, i'm kinda okay with that; on the other, maybe saying a bit more with types before getting to that kind of shrug would be nice. // - we probably want to use `Type` values, right? // - or do we: because then we probably need a `Repr bool` next to it, or lots of messages would be nonsensical. // - this is *currently* problematic because we don't actually generate type info consts yet. Hopefully soon; but the pain, meanwhile, is... substantial. // - "substantial" is an understatement. it makes incremental development almost impossible because stringifying error reports turn into nil pointer crashes! -// - other ipld-wide errors like `ipld.ErrWrongKind` *sometimes* refer to a TypeName... but don't *have* to, because they also arise at the merely-datamodel level; what would we do with these? +// - other ipld-wide errors like `datamodel.ErrWrongKind` *sometimes* refer to a TypeName... but don't *have* to, because they also arise at the merely-datamodel level; what would we do with these? // - it's undesirable (not to mention intensely forbidden for import cycle reasons) for those error types to refer to schema.Type. // - if we must have TypeName treated stringily in some cases, is it really useful to use full type info in other cases -- inconsistently? // - regardless of where we end up with this, some sort of an embed for helping deal with munging and printing this would probably be wise. -// - generally, whether you should expect an "ipld.Err*" or a "schema.Err*" from various methods is quite unclear. -// - it's possible that we should wrap *all* schema-level errors in a single "ipld.ErrSchemaNoMatch" error of some kind, to fix the above. as yet undecided. +// - generally, whether you should expect an "datamodel.Err*" or a "schema.Err*" from various methods is quite unclear. +// - it's possible that we should wrap *all* schema-level errors in a single "datamodel.ErrSchemaNoMatch" error of some kind, to fix the above. (and maybe that's what ErrUnmatchable really is.) as yet undecided. + +// ErrUnmatchable is the error raised when processing data with IPLD Schemas and +// finding data which cannot be matched into the schema. +// It will be returned by NodeAssemblers and NodeBuilders when they are fed unmatchable data. +// As a result, it will also often be seen returned from unmarshalling +// when unmarshalling into schema-constrained NodeAssemblers. +// +// ErrUnmatchable provides the name of the type in the schema that data couldn't be matched to, +// and wraps another error as the more detailed reason. +type ErrUnmatchable struct { + // TypeName will indicate the named type of a node the function was called on. + TypeName string + + // Reason must always be present. ErrUnmatchable doesn't say much otherwise. + Reason error +} + +func (e ErrUnmatchable) Error() string { + return fmt.Sprintf("matching data to schema of %s rejected: %s", e.TypeName, e.Reason) +} + +// Reasonf returns a new ErrUnmatchable with a Reason field set to the Errorf of the arguments. +// It's a helper function for creating untyped error reasons without importing the fmt package. +func (e ErrUnmatchable) Reasonf(format string, a ...interface{}) ErrUnmatchable { + return ErrUnmatchable{e.TypeName, fmt.Errorf(format, a...)} +} + +// ErrMissingRequiredField is returned when calling 'Finish' on a NodeAssembler +// for a Struct that has not has all required fields set. +type ErrMissingRequiredField struct { + Missing []string +} + +func (e ErrMissingRequiredField) Error() string { + return "missing required fields: " + strings.Join(e.Missing, ",") +} + +// ErrInvalidKey indicates a key is invalid for some reason. +// +// This is only possible for typed nodes; specifically, it may show up when +// handling struct types, or maps with interesting key types. +// (Other kinds of key invalidity that happen for untyped maps +// fall under ErrRepeatedMapKey or ErrWrongKind.) +// (Union types use ErrInvalidUnionDiscriminant instead of ErrInvalidKey, +// even when their representation strategy is maplike.) +type ErrInvalidKey struct { + // TypeName will indicate the named type of a node the function was called on. + TypeName string + + // Key is the key that was rejected. + Key datamodel.Node + + // Reason, if set, may provide details (for example, the reason a key couldn't be converted to a type). + // If absent, it'll be presumed "no such field". + // ErrUnmatchable may show up as a reason for typed maps with complex keys. + Reason error +} + +func (e ErrInvalidKey) Error() string { + if e.Reason == nil { + return fmt.Sprintf("invalid key for map %s: %q: no such field", e.TypeName, e.Key) + } else { + return fmt.Sprintf("invalid key for map %s: %q: %s", e.TypeName, e.Key, e.Reason) + } +} // ErrNoSuchField may be returned from lookup functions on the Node // interface when a field is requested which doesn't exist, @@ -30,7 +96,7 @@ import ( type ErrNoSuchField struct { Type Type - Field ipld.PathSegment + Field datamodel.PathSegment } func (e ErrNoSuchField) Error() string { diff --git a/schema/gen/go/HACKME_maybe.md b/schema/gen/go/HACKME_maybe.md index 6f50a462..8621fcfe 100644 --- a/schema/gen/go/HACKME_maybe.md +++ b/schema/gen/go/HACKME_maybe.md @@ -9,7 +9,7 @@ background ---------- You'll need to understand what the `nullable` and `optional` modifiers in IPLD schemas mean. -The https://specs.ipld.io/ site has more content about that. +The https://specs.datamodel.io/ site has more content about that. ### how this works outside of schemas @@ -17,7 +17,7 @@ There are concepts of null and of absent present in the core `Node` and `NodeAss `Node` specifies `IsNull() bool` and `IsAbsent() bool` predicates; and `NodeAssembler` specifies an `AssignNull` function. -There are also singleton values available called `ipld.Null` and `ipld.Absent` +There are also singleton values available called `datamodel.Null` and `datamodel.Absent` which report true for `IsNull` and `IsAbsent`, respectively. These singletons can be used by an function that need to return a null or absence indicator. @@ -25,27 +25,27 @@ There's really no reason for any package full of `Node` implementations need to since the singletons are always fine to use. However, there's also nothing stopping a `Node` implementation from doing interesting custom internal memory layouts to describe whether they contain nulls, etc -- -and there's nothing particularly blessed about the `ipld.Null` singleton. -Any value reporting `IsNull` to be `true` must be treated indistinguishably from `ipld.Null`. +and there's nothing particularly blessed about the `datamodel.Null` singleton. +Any value reporting `IsNull` to be `true` must be treated indistinguishably from `datamodel.Null`. This indistinguishability is bidirectional. For example, if you have some `myFancyNodeType`, and it answers `IsNull` as `true`, and you insert this into a `basicnode.Map`, then ask for that value back from the map later... -you're very likely to get `ipld.Null`, and not your concrete value of `myFancyNodeType` back again. +you're very likely to get `datamodel.Null`, and not your concrete value of `myFancyNodeType` back again. (This contract is important because some node implementations may compress the concept of null into a bitmask, or otherwise similarly optimize things internally.) #### null The concept of "null" has a Kind in the IPLD Data Model. -It's implemented by the `ipld.nullNode` type (which has no fields -- it's a "unit" type), -and is exposed as the `ipld.Null` singleton value. +It's implemented by the `datamodel.nullNode` type (which has no fields -- it's a "unit" type), +and is exposed as the `datamodel.Null` singleton value. -(More generally, `ipld.Node` can be null by having its `Kind()` method return `ipld.Kind_Null`, +(More generally, `datamodel.Node` can be null by having its `Kind()` method return `datamodel.Kind_Null`, and having the `IsNull()` method return `true`. -However, most code prefers to return the `ipld.Null` singleton value whenever it can.) +However, most code prefers to return the `datamodel.Null` singleton value whenever it can.) -Null values can be easily produced: the `AssignNull()` method on `ipld.NodeAssembler` produces nulls; +Null values can be easily produced: the `AssignNull()` method on `datamodel.NodeAssembler` produces nulls; and many codecs have some concept of null, meaning deserialization can produce them. Null values work essentially the same way in both the plain Data Model and when working with Schemas. @@ -58,48 +58,48 @@ There's also a concept of "absent". (Those familiar with javascript might note that javascript also has concepts of "null" versus "undefined". It's the same idea -- we just call it "absent" instead of "undefined".) -Absent is implemented by the `ipld.absentNode` type (which has no fields -- it's a "unit" type), -and is exposed as the `ipld.Absent` singleton value. +Absent is implemented by the `datamodel.absentNode` type (which has no fields -- it's a "unit" type), +and is exposed as the `datamodel.Absent` singleton value. -(More generally, an `ipld.Node` can describe itself as containing "absent" by having the `IsAbsent()` method return `true`. -(The `Kind()` method still returns `ipld.Kind_Null`, for lack of better option.) -However, most code prefers to return the `ipld.Absent` singleton value whenever it can.) +(More generally, an `datamodel.Node` can describe itself as containing "absent" by having the `IsAbsent()` method return `true`. +(The `Kind()` method still returns `datamodel.Kind_Null`, for lack of better option.) +However, most code prefers to return the `datamodel.Absent` singleton value whenever it can.) Absent values aren't really used at the Data Model level. If you ask for a map key that isn't present in the map, the lookup method will return `nil` and `ErrNotExists`. Absent values *do* show up at the Schema level, however. Specifically, in structs: a struct can have a field which is `optional`, -one of the values such an optional field may report itself as having is `ipld.Absent`. +one of the values such an optional field may report itself as having is `datamodel.Absent`. This represents when a value *wasn't present* in the serialized form of the struct, even though the schema lets us know that it could be, and that it's part of the struct's type. (Accordingly, no `ErrNotExists` is returned for a lookup of that field -- the field is always considered to _exist_... the value is just _absent_.) -Iterators will also return the field name key, together with `ipld.Absent` as the value. +Iterators will also return the field name key, together with `datamodel.Absent` as the value. However, absent values can't really be *created*. -There's no such thing as an `AssignAbsent` or `AssignAbsent` method on the `ipld.NodeAssembler` interface. -Codecs similarly can't produce absent as a value (obviously -- codecs work over `ipld.NodeAssembler`, so how could they?). +There's no such thing as an `AssignAbsent` or `AssignAbsent` method on the `datamodel.NodeAssembler` interface. +Codecs similarly can't produce absent as a value (obviously -- codecs work over `datamodel.NodeAssembler`, so how could they?). Absent values are just produced by implication, when a field is defined, but its value isn't set. Despite absent values not being used or produced at the Data Model, we still have methods like `IsAbsent` specified -as part of the `ipld.Node` interface so that it's possible to write code which is generic over +as part of the `datamodel.Node` interface so that it's possible to write code which is generic over either plain Data Model or Schema data while using just that interface. ### the above is all regarding generic interfaces -As long as we're talking about the `ipld.Node` _interface_, -we talk about the `ipld.Null` and `ipld.Absent` singletons, and their contracts in terms of the interface. +As long as we're talking about the `datamodel.Node` _interface_, +we talk about the `datamodel.Null` and `datamodel.Absent` singletons, and their contracts in terms of the interface. (Part of the reason this works is because an interface, in golang, comes in two parts: a pointer to the typeinfo of the inhabitant value, and a pointer to the value itself. -This means anywhere we have an `ipld.Node` return type, we can toss `ipld.Null` -or `ipld.Absent` into it with no additional overhead!) +This means anywhere we have an `datamodel.Node` return type, we can toss `datamodel.Null` +or `datamodel.Absent` into it with no additional overhead!) -When we talk about concrete types, rather than the `ipld.Node` _interface_ -- +When we talk about concrete types, rather than the `datamodel.Node` _interface_ -- as we're going to, in codegen -- it's a different scenario. -We can't just return `ipld.Null` pointers for a `genresult.Foo` value; +We can't just return `datamodel.Null` pointers for a `genresult.Foo` value; if `genresult.Foo` is a concrete type, that's just flat out a compile error. So what shall we do? @@ -111,13 +111,13 @@ We introduce the "maybe" types. the maybe types --------------- -The general rule of "return `ipld.Null` whenever you have a null value" -holds up only as long as our API is returning monomorphized `ipld.Node` interfaces -- -in that situation, `ipld.Null` fits within `ipld.Node`, and there's no trouble. +The general rule of "return `datamodel.Null` whenever you have a null value" +holds up only as long as our API is returning monomorphized `datamodel.Node` interfaces -- +in that situation, `datamodel.Null` fits within `datamodel.Node`, and there's no trouble. This doesn't hold up when we get to codegen. Or rather, more specifically, it even holds up for codegen... -as long as we're still returning monomorphized `ipld.Node` interfaces (and a decent amount of the API surface still does so). +as long as we're still returning monomorphized `datamodel.Node` interfaces (and a decent amount of the API surface still does so). At the moment we want to return a concrete native type, it breaks. We call methods created by codegen that use specific types @@ -131,7 +131,7 @@ So we have to decide how to handle null and absent for these speciated methods. There are a couple of things we want to accomplish with the maybe types: - Be able to have speciated methods that return a specific type (for doc, editor autocomplete, etc purposes). -- Be able to have speciated methods that return specific *concrete* type (i.e. not only do we want to be more specific than `ipld.Node`, we don't want an interface _at all_ -- so that the compiler can do inlining and optimization and so forth). +- Be able to have speciated methods that return specific *concrete* type (i.e. not only do we want to be more specific than `datamodel.Node`, we don't want an interface _at all_ -- so that the compiler can do inlining and optimization and so forth). - Make reading and writing code that uses speciated methods and handles nullable or optional fields be reasonably ergonomic (and as always, this may vary by "taste"). And we'll consider one more fourth, bonus goal: @@ -166,7 +166,7 @@ but these are prefixed in such a way as to make collision not a concern.) ### maybe types don't implement the full Node interface -The "maybe" types don't implement the full `ipld.Node` interface. +The "maybe" types don't implement the full `datamodel.Node` interface. They could have! They don't. Arguments that went in favor of implementing `Node`: diff --git a/schema/gen/go/HACKME_memorylayout.md b/schema/gen/go/HACKME_memorylayout.md index fcd984d2..5f6894c0 100644 --- a/schema/gen/go/HACKME_memorylayout.md +++ b/schema/gen/go/HACKME_memorylayout.md @@ -324,7 +324,7 @@ and defensive checks to ensure we don't leak mutable references would not come for free; reducing the number of points we might need to do this makes it possible to create a more efficient system overall.) -The documentation on the ipld.NodeAssembler type gives some general +The documentation on the datamodel.NodeAssembler type gives some general description of this. NodeBuilder types end up being just a NodeAssembler embed, plus a few methods diff --git a/schema/gen/go/HACKME_scalars.md b/schema/gen/go/HACKME_scalars.md index 5df9bb85..20629a17 100644 --- a/schema/gen/go/HACKME_scalars.md +++ b/schema/gen/go/HACKME_scalars.md @@ -65,17 +65,17 @@ func (x *Foomp) LookupByNode(k *Foo) (*Bar) { /*...*/ } Such specialized methods are often much shorter, much more efficient to execute, and involve much less error handling to use than their more generalized -counterparts on the `ipld.Node` interface. +counterparts on the `datamodel.Node` interface. Note that when named scalars appear in the signitures of specialized methods, they always appear as pointers. They will never be `nil`, but there is still a reason that pointers are used here, and it's based on performance. (The details don't matter as a user, but: it means if those values need to be -regarded as the `ipld.Node` interface again in the future, that boxing is +regarded as the `datamodel.Node` interface again in the future, that boxing is inexpensive since we already have a (heap-escaped long ago) pointer. By contrast, copying by value in more places is likely to result in more heap escapes and thus additional undesirable new allocation costs in the -(entirely common!) case that the values end up handled as `ipld.Node` later.) +(entirely common!) case that the values end up handled as `datamodel.Node` later.) #### named scalars have a specialized method which unboxes them to a native primitive unconditionally @@ -126,7 +126,7 @@ as a type identifier. At any rate, it seems clear that you can mentally capitalize the 's' at any time you see this debatable syntax. -(We should resolve this issue in the specs, which are in the `ipld/specs` repo.) +(We should resolve this issue in the specs, which are in the `datamodel.specs` repo.) #### plain scalars appear in specialized method argument types and return types @@ -150,15 +150,15 @@ The type might carry less semantic information than it does when a named scalar shows up in the same position, but we still use a generated type (and a pointer) here for two reasons: first of all, and more simply, consistency; but secondly, for the same performance reasons as applied -to named scalars (if we need to treat this value as an `ipld.Node` again +to named scalars (if we need to treat this value as an `datamodel.Node` again in the future, it's much better if we already have a heap pointer rather than a bare primitive value (`runtime.convT*` functions are often not your favorite thing to see in a pprof flamegraph)). (FUTURE: this is still worth review. We might actually want to use bare primitives in a lot of these cases, because surely, if you're about -to want to treat something as an `ipld.Node` again, then you can use the -generalized methods conforming to `ipld.Node` which already yield that...? +to want to treat something as an `datamodel.Node` again, then you can use the +generalized methods conforming to `datamodel.Node` which already yield that...? We'll get more information and impressions about this after trying to use codegen in bulk (especially the specialized methods).) @@ -174,11 +174,11 @@ Code reuse for plain scalars ---------------------------- We *always* need some type that can contain a plain scalar while also -implementing all the `ipld.Node` methods. Even if we didn't export it +implementing all the `datamodel.Node` methods. Even if we didn't export it or show it in any method signitures anywhere at all, we'd *still* need it for internal implementation of other types, because it's important those types be able to return a pointer to their fields in their implements of -the `ipld.Node` contract (otherwise, they'd be terribly slow and alloc-heavy). +the `datamodel.Node` contract (otherwise, they'd be terribly slow and alloc-heavy). ### can we reuse another package's plain scalars? @@ -213,7 +213,7 @@ However, there are *many* "cons" which outweight that single "pro": There are also a few bits that aren't entirely known (at least, at the time of this writing): namely, how 'any' types are going to be handled in codegen. -Probably, though, the answer is: it's just treated as 'ipld.Node', +Probably, though, the answer is: it's just treated as 'datamodel.Node', and the codegen package doesn't export *any* more types which regard this situation because that's already sufficient. Long story short? It's better to have plain scalar types in codegen output, diff --git a/schema/gen/go/HACKME_wip.md b/schema/gen/go/HACKME_wip.md index 1678e4bb..7076479e 100644 --- a/schema/gen/go/HACKME_wip.md +++ b/schema/gen/go/HACKME_wip.md @@ -5,8 +5,8 @@ The handling of absent values is still not consistent. Currently: -- reading (via accessors or iterators) yields `ipld.Absent` values for absent fields -- putting those ipld.Absent values via NodeAssembler.AssignNode will result in `ErrWrongKind`. +- reading (via accessors or iterators) yields `datamodel.Absent` values for absent fields +- putting those datamodel.Absent values via NodeAssembler.AssignNode will result in `ErrWrongKind`. - *the recursive copies embedded in AssignNode methods don't handle absents either*. The first two are defensible and consistent (if not necessarily ergonomic). @@ -76,9 +76,9 @@ Perhaps this only matters for certain styles of unions. Perhaps we should get used to the idea of codec packages offering two styles of methods: -- `UnmarshalIntoAssembler(io.Reader, ipld.NodeAssembler) error` +- `UnmarshalIntoAssembler(io.Reader, datamodel.NodeAssembler) error` - this is for when you have opinions about what kind of in-memory format should be used -- `Unmarshal(io.Reader) (ipld.Node, error)` +- `Unmarshal(io.Reader) (datamodel.Node, error)` - this is for when you want to let the codec pick. We might actually end up preferring the latter in a fair number of cases. diff --git a/schema/gen/go/README_behaviors.md b/schema/gen/go/README_behaviors.md index 3a17c5ef..5c6d1c4a 100644 --- a/schema/gen/go/README_behaviors.md +++ b/schema/gen/go/README_behaviors.md @@ -28,11 +28,11 @@ and such internal details should not be considered part of the intended public A ### absent values -Iterating a type-level node with optional fields will yield the field key and the `ipld.Absent` constant as a value. -Getting a such a field will also yield the `ipld.Absent` constant as a value, and will not return a "not found" error. +Iterating a type-level node with optional fields will yield the field key and the `datamodel.Absent` constant as a value. +Getting a such a field will also yield the `datamodel.Absent` constant as a value, and will not return a "not found" error. -Attempting to *assign* an `ipld.Absent` value, however -- +Attempting to *assign* an `datamodel.Absent` value, however -- via the `NodeAssembler.AssignNode` function (none of the other function signatures permit expressing this) -- -will result in an `ipld.ErrWrongKind` error. +will result in an `datamodel.ErrWrongKind` error. // Seealso some unresolved todos in the [HACKME_wip](HACKME_wip.md) document regarding how absent values are handled. diff --git a/schema/gen/go/adjunctCfg.go b/schema/gen/go/adjunctCfg.go index 25b069bd..910eeea1 100644 --- a/schema/gen/go/adjunctCfg.go +++ b/schema/gen/go/adjunctCfg.go @@ -5,8 +5,8 @@ import ( "reflect" "strings" - ipld "github.com/ipld/go-ipld-prime" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/schema" ) @@ -104,7 +104,7 @@ func init() { // Get the basic node sizes via basicnode. for _, tk := range []struct { typeKind schema.TypeKind - prototype ipld.NodePrototype + prototype datamodel.NodePrototype }{ {schema.TypeKind_Bool, basicnode.Prototype.Bool}, {schema.TypeKind_Int, basicnode.Prototype.Int}, diff --git a/schema/gen/go/genBoolReprBool.go b/schema/gen/go/genBoolReprBool.go index 81d5b9ec..fe642103 100644 --- a/schema/gen/go/genBoolReprBool.go +++ b/schema/gen/go/genBoolReprBool.go @@ -49,7 +49,7 @@ func (g boolReprBoolReprGenerator) EmitNodeType(w io.Writer) { } func (g boolReprBoolReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (boolReprBoolReprGenerator) EmitNodeMethodKind(io.Writer) {} diff --git a/schema/gen/go/genBytesReprBytes.go b/schema/gen/go/genBytesReprBytes.go index ccdc4d0e..d1b404f8 100644 --- a/schema/gen/go/genBytesReprBytes.go +++ b/schema/gen/go/genBytesReprBytes.go @@ -49,7 +49,7 @@ func (g bytesReprBytesReprGenerator) EmitNodeType(w io.Writer) { } func (g bytesReprBytesReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (bytesReprBytesReprGenerator) EmitNodeMethodKind(io.Writer) {} diff --git a/schema/gen/go/genFloatReprFloat.go b/schema/gen/go/genFloatReprFloat.go index b678abe5..a7c1c4ee 100644 --- a/schema/gen/go/genFloatReprFloat.go +++ b/schema/gen/go/genFloatReprFloat.go @@ -49,7 +49,7 @@ func (g float64ReprFloatReprGenerator) EmitNodeType(w io.Writer) { } func (g float64ReprFloatReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (float64ReprFloatReprGenerator) EmitNodeMethodKind(io.Writer) {} diff --git a/schema/gen/go/genIntReprInt.go b/schema/gen/go/genIntReprInt.go index 0a84fd41..06ac3ba4 100644 --- a/schema/gen/go/genIntReprInt.go +++ b/schema/gen/go/genIntReprInt.go @@ -49,7 +49,7 @@ func (g intReprIntReprGenerator) EmitNodeType(w io.Writer) { } func (g intReprIntReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (intReprIntReprGenerator) EmitNodeMethodKind(io.Writer) {} diff --git a/schema/gen/go/genLink.go b/schema/gen/go/genLink.go index 39c9a5d8..89ea79ae 100644 --- a/schema/gen/go/genLink.go +++ b/schema/gen/go/genLink.go @@ -52,7 +52,7 @@ func (g linkGenerator) EmitTypedNodeMethodType(w io.Writer) { // Bonus feature for some links (conforms to the schema.TypedLinkNode interface): if g.Type.HasReferencedType() { doTemplate(` - func ({{ .Type | TypeSymbol }}) LinkTargetNodePrototype() ipld.NodePrototype { + func ({{ .Type | TypeSymbol }}) LinkTargetNodePrototype() datamodel.NodePrototype { return Type.{{ .Type.ReferencedType | TypeSymbol }}__Repr } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genLinkReprLink.go b/schema/gen/go/genLinkReprLink.go index 68297912..75553b3d 100644 --- a/schema/gen/go/genLinkReprLink.go +++ b/schema/gen/go/genLinkReprLink.go @@ -49,7 +49,7 @@ func (g linkReprLinkReprGenerator) EmitNodeType(w io.Writer) { } func (g linkReprLinkReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (linkReprLinkReprGenerator) EmitNodeMethodKind(io.Writer) {} diff --git a/schema/gen/go/genList.go b/schema/gen/go/genList.go index 72058ca9..390a80c9 100644 --- a/schema/gen/go/genList.go +++ b/schema/gen/go/genList.go @@ -74,7 +74,7 @@ func (g listGenerator) EmitNativeAccessors(w io.Writer) { `, w, g.AdjCfg, g) // Generate a speciated iterator. - // The main advantage of this over the general ipld.ListIterator is of course keeping types visible (and concrete, to the compiler's eyes in optimizations, too). + // The main advantage of this over the general datamodel.ListIterator is of course keeping types visible (and concrete, to the compiler's eyes in optimizations, too). // It also elides the error return from the iterator's Next method. (Overreads will result in -1 as an index and nil values; this is both easily avoidable, and unambiguous if you do goof and hit it.) doTemplate(` func (n {{ .Type | TypeSymbol }}) Iterator() *{{ .Type | TypeSymbol }}__Itr { @@ -144,14 +144,14 @@ func (g listGenerator) EmitNodeTypeAssertions(w io.Writer) { func (g listGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByIndex(idx int64) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByIndex(idx int64) (datamodel.Node, error) { if n.Length() <= idx { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)} } v := &n.x[idx] {{- if .Type.ValueIsNullable }} if v.m == schema.Maybe_Null { - return ipld.Null, nil + return datamodel.Null, nil } return {{ if not (MaybeUsesPtr .Type.ValueType) }}&{{end}}v.v, nil {{- else}} @@ -165,7 +165,7 @@ func (g listGenerator) EmitNodeMethodLookupByNode(w io.Writer) { // LookupByNode will procede by coercing to int64 if it can; or fail; those are really the only options. // REVIEW: how much coercion is done by other types varies quite wildly. so we should figure out if that inconsistency is acceptable, and at least document it if so. doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByNode(k ipld.Node) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByNode(k datamodel.Node) (datamodel.Node, error) { idx, err := k.AsInt() if err != nil { return nil, err @@ -177,7 +177,7 @@ func (g listGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g listGenerator) EmitNodeMethodListIterator(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) ListIterator() ipld.ListIterator { + func (n {{ .Type | TypeSymbol }}) ListIterator() datamodel.ListIterator { return &_{{ .Type | TypeSymbol }}__ListItr{n, 0} } @@ -186,16 +186,16 @@ func (g listGenerator) EmitNodeMethodListIterator(w io.Writer) { idx int } - func (itr *_{{ .Type | TypeSymbol }}__ListItr) Next() (idx int64, v ipld.Node, _ error) { + func (itr *_{{ .Type | TypeSymbol }}__ListItr) Next() (idx int64, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.x) { - return -1, nil, ipld.ErrIteratorOverread{} + return -1, nil, datamodel.ErrIteratorOverread{} } idx = int64(itr.idx) x := &itr.n.x[itr.idx] {{- if .Type.ValueIsNullable }} switch x.m { case schema.Maybe_Null: - v = ipld.Null + v = datamodel.Null case schema.Maybe_Value: v = {{ if not (MaybeUsesPtr .Type.ValueType) }}&{{end}}x.v } diff --git a/schema/gen/go/genListReprList.go b/schema/gen/go/genListReprList.go index 15a434c3..d17a7e7f 100644 --- a/schema/gen/go/genListReprList.go +++ b/schema/gen/go/genListReprList.go @@ -63,7 +63,7 @@ func (g listReprListReprGenerator) EmitNodeType(w io.Writer) { func (g listReprListReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } @@ -72,9 +72,9 @@ func (g listReprListReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { // REVIEW: these unchecked casts are definitely safe at compile time, but I'm not sure if the compiler considers that provable, // so we should investigate if there's any runtime checks injected here that waste time. If so: write this with more gsloc to avoid :( doTemplate(` - func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { + func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := ({{ .Type | TypeSymbol }})(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.({{ .Type.ValueType | TypeSymbol}}).Representation(), nil @@ -85,9 +85,9 @@ func (g listReprListReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g listReprListReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { doTemplate(` - func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByIndex(idx int64) (ipld.Node, error) { + func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { v, err := ({{ .Type | TypeSymbol }})(nr).LookupByIndex(idx) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.({{ .Type.ValueType | TypeSymbol}}).Representation(), nil @@ -98,15 +98,15 @@ func (g listReprListReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { func (g listReprListReprGenerator) EmitNodeMethodListIterator(w io.Writer) { // FUTURE: trying to get this to share the preallocated memory if we get iterators wedged into their node slab will be ... fun. doTemplate(` - func (nr *_{{ .Type | TypeSymbol }}__Repr) ListIterator() ipld.ListIterator { + func (nr *_{{ .Type | TypeSymbol }}__Repr) ListIterator() datamodel.ListIterator { return &_{{ .Type | TypeSymbol }}__ReprListItr{({{ .Type | TypeSymbol }})(nr), 0} } type _{{ .Type | TypeSymbol }}__ReprListItr _{{ .Type | TypeSymbol }}__ListItr - func (itr *_{{ .Type | TypeSymbol }}__ReprListItr) Next() (idx int64, v ipld.Node, err error) { + func (itr *_{{ .Type | TypeSymbol }}__ReprListItr) Next() (idx int64, v datamodel.Node, err error) { idx, v, err = (*_{{ .Type | TypeSymbol }}__ListItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return idx, v.({{ .Type.ValueType | TypeSymbol}}).Representation(), nil diff --git a/schema/gen/go/genMap.go b/schema/gen/go/genMap.go index c146adfe..6dc496ec 100644 --- a/schema/gen/go/genMap.go +++ b/schema/gen/go/genMap.go @@ -89,7 +89,7 @@ func (g mapGenerator) EmitNativeAccessors(w io.Writer) { `, w, g.AdjCfg, g) // Generate a speciated iterator. - // The main advantage of this over the general ipld.MapIterator is of course keeping types visible (and concrete, to the compiler's eyes in optimizations, too). + // The main advantage of this over the general datamodel.MapIterator is of course keeping types visible (and concrete, to the compiler's eyes in optimizations, too). // It also elides the error return from the iterator's Next method. (Overreads will result in nil keys; this is both easily avoidable, and unambiguous if you do goof and hit it.) doTemplate(` func (n {{ .Type | TypeSymbol }}) Iterator() *{{ .Type | TypeSymbol }}__Itr { @@ -165,7 +165,7 @@ func (g mapGenerator) EmitNodeMethodLookupByString(w io.Writer) { // For that to work out, it means if the key type doesn't have a string type kind, we must be willing to reach into its representation and use the fromString there. // If the key type *does* have a string kind at the type level, we'll use that; no need to consider going through the representation. doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByString(k string) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByString(k string) (datamodel.Node, error) { var k2 _{{ .Type.KeyType | TypeSymbol }} {{- if eq .Type.KeyType.TypeKind.String "String" }} if err := (_{{ .Type.KeyType | TypeSymbol }}__Prototype{}).fromString(&k2, k); err != nil { @@ -178,11 +178,11 @@ func (g mapGenerator) EmitNodeMethodLookupByString(w io.Writer) { {{- end}} v, exists := n.m[k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k)} } {{- if .Type.ValueIsNullable }} if v.m == schema.Maybe_Null { - return ipld.Null, nil + return datamodel.Null, nil } return {{ if not (MaybeUsesPtr .Type.ValueType) }}&{{end}}v.v, nil {{- else}} @@ -198,19 +198,19 @@ func (g mapGenerator) EmitNodeMethodLookupByNode(w io.Writer) { // if you used a Node here, you should've meant it. // REVIEW: by comparison structs will coerce anything stringish silently...! so we should figure out if that inconsistency is acceptable, and at least document it if so. doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByNode(k ipld.Node) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByNode(k datamodel.Node) (datamodel.Node, error) { k2, ok := k.({{ .Type.KeyType | TypeSymbol }}) if !ok { panic("todo invalid key type error") - // 'ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all + // 'schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}}' doesn't quite cut it: need room to explain the type, and it's not guaranteed k can be turned into a string at all } v, exists := n.m[*k2] if !exists { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(k2.String())} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(k2.String())} } {{- if .Type.ValueIsNullable }} if v.m == schema.Maybe_Null { - return ipld.Null, nil + return datamodel.Null, nil } return {{ if not (MaybeUsesPtr .Type.ValueType) }}&{{end}}v.v, nil {{- else}} @@ -222,7 +222,7 @@ func (g mapGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g mapGenerator) EmitNodeMethodMapIterator(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) MapIterator() ipld.MapIterator { + func (n {{ .Type | TypeSymbol }}) MapIterator() datamodel.MapIterator { return &_{{ .Type | TypeSymbol }}__MapItr{n, 0} } @@ -231,16 +231,16 @@ func (g mapGenerator) EmitNodeMethodMapIterator(w io.Writer) { idx int } - func (itr *_{{ .Type | TypeSymbol }}__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { + func (itr *_{{ .Type | TypeSymbol }}__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.idx >= len(itr.n.t) { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } x := &itr.n.t[itr.idx] k = &x.k {{- if .Type.ValueIsNullable }} switch x.v.m { case schema.Maybe_Null: - v = ipld.Null + v = datamodel.Null case schema.Maybe_Value: v = {{ if not (MaybeUsesPtr .Type.ValueType) }}&{{end}}x.v.v } diff --git a/schema/gen/go/genMapReprMap.go b/schema/gen/go/genMapReprMap.go index d5d52cb5..977fc1a6 100644 --- a/schema/gen/go/genMapReprMap.go +++ b/schema/gen/go/genMapReprMap.go @@ -62,15 +62,15 @@ func (g mapReprMapReprGenerator) EmitNodeType(w io.Writer) { } func (g mapReprMapReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (g mapReprMapReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { doTemplate(` - func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByString(k string) (ipld.Node, error) { + func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByString(k string) (datamodel.Node, error) { v, err := ({{ .Type | TypeSymbol }})(nr).LookupByString(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.({{ .Type.ValueType | TypeSymbol}}).Representation(), nil @@ -82,9 +82,9 @@ func (g mapReprMapReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { // REVIEW: these unchecked casts are definitely safe at compile time, but I'm not sure if the compiler considers that provable, // so we should investigate if there's any runtime checks injected here that waste time. If so: write this with more gsloc to avoid :( doTemplate(` - func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) { + func (nr *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(k datamodel.Node) (datamodel.Node, error) { v, err := ({{ .Type | TypeSymbol }})(nr).LookupByNode(k) - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return v, err } return v.({{ .Type.ValueType | TypeSymbol}}).Representation(), nil @@ -94,15 +94,15 @@ func (g mapReprMapReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g mapReprMapReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { // FUTURE: trying to get this to share the preallocated memory if we get iterators wedged into their node slab will be ... fun. doTemplate(` - func (nr *_{{ .Type | TypeSymbol }}__Repr) MapIterator() ipld.MapIterator { + func (nr *_{{ .Type | TypeSymbol }}__Repr) MapIterator() datamodel.MapIterator { return &_{{ .Type | TypeSymbol }}__ReprMapItr{({{ .Type | TypeSymbol }})(nr), 0} } type _{{ .Type | TypeSymbol }}__ReprMapItr _{{ .Type | TypeSymbol }}__MapItr - func (itr *_{{ .Type | TypeSymbol }}__ReprMapItr) Next() (k ipld.Node, v ipld.Node, err error) { + func (itr *_{{ .Type | TypeSymbol }}__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, err error) { k, v, err = (*_{{ .Type | TypeSymbol }}__MapItr)(itr).Next() - if err != nil || v == ipld.Null { + if err != nil || v == datamodel.Null { return } return k, v.({{ .Type.ValueType | TypeSymbol}}).Representation(), nil diff --git a/schema/gen/go/genStringReprString.go b/schema/gen/go/genStringReprString.go index dec996e5..8389f174 100644 --- a/schema/gen/go/genStringReprString.go +++ b/schema/gen/go/genStringReprString.go @@ -49,7 +49,7 @@ func (g stringReprStringReprGenerator) EmitNodeType(w io.Writer) { } func (g stringReprStringReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (stringReprStringReprGenerator) EmitNodeMethodKind(io.Writer) {} diff --git a/schema/gen/go/genStruct.go b/schema/gen/go/genStruct.go index 7f955959..1351eb3c 100644 --- a/schema/gen/go/genStruct.go +++ b/schema/gen/go/genStruct.go @@ -95,18 +95,18 @@ func (g structGenerator) EmitNodeTypeAssertions(w io.Writer) { func (g structGenerator) EmitNodeMethodLookupByString(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByString(key string) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByString(key string) (datamodel.Node, error) { switch key { {{- range $field := .Type.Fields }} case "{{ $field.Name }}": {{- if $field.IsOptional }} if n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Absent { - return ipld.Absent, nil + return datamodel.Absent, nil } {{- end}} {{- if $field.IsNullable }} if n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Null { - return ipld.Null, nil + return datamodel.Null, nil } {{- end}} {{- if $field.IsMaybe }} @@ -116,7 +116,7 @@ func (g structGenerator) EmitNodeMethodLookupByString(w io.Writer) { {{- end}} {{- end}} default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } `, w, g.AdjCfg, g) @@ -124,7 +124,7 @@ func (g structGenerator) EmitNodeMethodLookupByString(w io.Writer) { func (g structGenerator) EmitNodeMethodLookupByNode(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByNode(key ipld.Node) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err @@ -138,7 +138,7 @@ func (g structGenerator) EmitNodeMethodMapIterator(w io.Writer) { // Note that the typed iterator will report absent fields. // The representation iterator (if has one) however will skip those. doTemplate(` - func (n {{ .Type | TypeSymbol }}) MapIterator() ipld.MapIterator { + func (n {{ .Type | TypeSymbol }}) MapIterator() datamodel.MapIterator { return &_{{ .Type | TypeSymbol }}__MapItr{n, 0} } @@ -147,12 +147,12 @@ func (g structGenerator) EmitNodeMethodMapIterator(w io.Writer) { idx int } - func (itr *_{{ .Type | TypeSymbol }}__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { + func (itr *_{{ .Type | TypeSymbol }}__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { {{- if not .Type.Fields }} - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} {{ else -}} if itr.idx >= {{ len .Type.Fields }} { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { {{- $type := .Type -}} {{- /* ranging modifies dot, unhelpfully */ -}} @@ -161,13 +161,13 @@ func (g structGenerator) EmitNodeMethodMapIterator(w io.Writer) { k = &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} {{- if $field.IsOptional }} if itr.n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Absent { - v = ipld.Absent + v = datamodel.Absent break } {{- end}} {{- if $field.IsNullable }} if itr.n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Null { - v = ipld.Null + v = datamodel.Null break } {{- end}} @@ -292,7 +292,7 @@ func (g structBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) { // // We do not set m=midvalue in phase 3 -- it shouldn't matter unless you're trying to pull off concurrent access, which is wrong and unsafe regardless. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__Assembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -314,8 +314,8 @@ func (g structBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -407,7 +407,7 @@ func (g structBuilderGenerator) emitMapAssemblerChildTidyHelper(w io.Writer) { func (g structBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { // FUTURE: some of the setup of the child assemblers could probably be DRY'd up. doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -428,7 +428,7 @@ func (g structBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { {{- range $i, $field := .Type.Fields }} case "{{ $field.Name }}": if ma.s & fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}} } ma.s += fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} ma.state = maState_midValue @@ -447,9 +447,9 @@ func (g structBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { {{- end}} } {{- end}} - return nil, ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} + return nil, schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} } - func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleKey() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -467,7 +467,7 @@ func (g structBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { ma.state = maState_midKey return (*_{{ .Type | TypeSymbol }}__KeyAssembler)(ma) } - func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleValue() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -516,7 +516,7 @@ func (g structBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s & fieldBits__{{ $type | TypeSymbol }}_sufficient != fieldBits__{{ $type | TypeSymbol }}_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} {{- range $i, $field := .Type.Fields }} {{- if not $field.IsMaybe}} if ma.s & fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} == 0 { @@ -530,10 +530,10 @@ func (g structBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { *ma.m = schema.Maybe_Value return nil } - func (ma *_{{ .Type | TypeSymbol }}__Assembler) KeyPrototype() ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } - func (ma *_{{ .Type | TypeSymbol }}__Assembler) ValuePrototype(k string) ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler valueprototype") } `, w, g.AdjCfg, g) @@ -565,7 +565,7 @@ func (g structBuilderGenerator) emitKeyAssembler(w io.Writer) { {{- range $i, $field := .Type.Fields }} case "{{ $field.Name }}": if ka.s & fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}} } ka.s += fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} ka.state = maState_expectValue @@ -573,21 +573,21 @@ func (g structBuilderGenerator) emitKeyAssembler(w io.Writer) { return nil {{- end}} default: - return ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} + return schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} } } `, w, g.AdjCfg, g) stubs.EmitNodeAssemblerMethodAssignBytes(w) stubs.EmitNodeAssemblerMethodAssignLink(w) doTemplate(` - func (ka *_{{ .Type | TypeSymbol }}__KeyAssembler) AssignNode(v ipld.Node) error { + func (ka *_{{ .Type | TypeSymbol }}__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } - func (_{{ .Type | TypeSymbol }}__KeyAssembler) Prototype() ipld.NodePrototype { + func (_{{ .Type | TypeSymbol }}__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genStructReprMap.go b/schema/gen/go/genStructReprMap.go index dc9c999c..368a3111 100644 --- a/schema/gen/go/genStructReprMap.go +++ b/schema/gen/go/genStructReprMap.go @@ -74,25 +74,25 @@ func (g structReprMapReprGenerator) EmitNodeType(w io.Writer) { func (g structReprMapReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (g structReprMapReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { // Similar to the type-level method, except any absent fields also return ErrNotExists. doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByString(key string) (ipld.Node, error) { + func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { {{- range $field := .Type.Fields }} case "{{ $field | $field.Parent.RepresentationStrategy.GetFieldKey }}": {{- if $field.IsOptional }} if n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } {{- end}} {{- if $field.IsNullable }} if n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Null { - return ipld.Null, nil + return datamodel.Null, nil } {{- end}} {{- if $field.IsMaybe }} @@ -102,7 +102,7 @@ func (g structReprMapReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { {{- end}} {{- end}} default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } `, w, g.AdjCfg, g) @@ -110,7 +110,7 @@ func (g structReprMapReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { func (g structReprMapReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { + func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err @@ -153,7 +153,7 @@ func (g structReprMapReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { // Now: finally we can get on with the actual templating. doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) MapIterator() ipld.MapIterator { + func (n *_{{ .Type | TypeSymbol }}__Repr) MapIterator() datamodel.MapIterator { {{- if .HaveTrailingOptionals }} end := {{ len .Type.Fields }}`+ func() string { // this next part was too silly in templates due to lack of reverse ranging. @@ -179,14 +179,14 @@ func (g structReprMapReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { {{if .HaveTrailingOptionals }}end int{{end}} } - func (itr *_{{ .Type | TypeSymbol }}__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { + func (itr *_{{ .Type | TypeSymbol }}__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { {{- if not .Type.Fields }} {{- /* TODO: deduplicate all these methods which just error */ -}} - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} {{ else -}} {{ if .HaveOptionals }}advance:{{end -}} if itr.idx >= {{ len .Type.Fields }} { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { {{- $type := .Type -}} {{- /* ranging modifies dot, unhelpfully */ -}} @@ -201,7 +201,7 @@ func (g structReprMapReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { {{- end}} {{- if $field.IsNullable }} if itr.n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Null { - v = ipld.Null + v = datamodel.Null break } {{- end}} @@ -342,7 +342,7 @@ func (g structReprMapReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w i // // We do not set m=midvalue in phase 3 -- it shouldn't matter unless you're trying to pull off concurrent access, which is wrong and unsafe regardless. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -364,8 +364,8 @@ func (g structReprMapReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w i *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -445,7 +445,7 @@ func (g structReprMapReprBuilderGenerator) emitMapAssemblerChildTidyHelper(w io. func (g structReprMapReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { // FUTURE: some of the setup of the child assemblers could probably be DRY'd up. doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -466,7 +466,7 @@ func (g structReprMapReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) {{- range $i, $field := .Type.Fields }} case "{{ $field | $type.RepresentationStrategy.GetFieldKey }}": if ma.s & fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} != 0 { - return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}_serial} + return nil, datamodel.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}_serial} } ma.s += fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} ma.state = maState_midValue @@ -484,9 +484,9 @@ func (g structReprMapReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) default: } {{- end}} - return nil, ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} + return nil, schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} } - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleKey() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -504,7 +504,7 @@ func (g structReprMapReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) ma.state = maState_midKey return (*_{{ .Type | TypeSymbol }}__ReprKeyAssembler)(ma) } - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleValue() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -551,7 +551,7 @@ func (g structReprMapReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) panic("invalid state: Finish cannot be called on an assembler that's already finished") } if ma.s & fieldBits__{{ $type | TypeSymbol }}_sufficient != fieldBits__{{ $type | TypeSymbol }}_sufficient { - err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)} + err := schema.ErrMissingRequiredField{Missing: make([]string, 0)} {{- range $i, $field := .Type.Fields }} {{- if not $field.IsMaybe}} if ma.s & fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} == 0 { @@ -569,10 +569,10 @@ func (g structReprMapReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) *ma.m = schema.Maybe_Value return nil } - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) KeyPrototype() ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { panic("todo structbuilder mapassembler repr valueprototype") } `, w, g.AdjCfg, g) @@ -605,7 +605,7 @@ func (g structReprMapReprBuilderGenerator) emitKeyAssembler(w io.Writer) { {{- range $i, $field := .Type.Fields }} case "{{ $field | $type.RepresentationStrategy.GetFieldKey }}": if ka.s & fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} != 0 { - return ipld.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}_serial} + return datamodel.ErrRepeatedMapKey{Key: &fieldName__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }}_serial} } ka.s += fieldBit__{{ $type | TypeSymbol }}_{{ $field | FieldSymbolUpper }} ka.state = maState_expectValue @@ -614,20 +614,20 @@ func (g structReprMapReprBuilderGenerator) emitKeyAssembler(w io.Writer) { {{- end }} } {{- end }} - return ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} + return schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} } `, w, g.AdjCfg, g) stubs.EmitNodeAssemblerMethodAssignBytes(w) stubs.EmitNodeAssemblerMethodAssignLink(w) doTemplate(` - func (ka *_{{ .Type | TypeSymbol }}__ReprKeyAssembler) AssignNode(v ipld.Node) error { + func (ka *_{{ .Type | TypeSymbol }}__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } - func (_{{ .Type | TypeSymbol }}__ReprKeyAssembler) Prototype() ipld.NodePrototype { + func (_{{ .Type | TypeSymbol }}__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genStructReprStringjoin.go b/schema/gen/go/genStructReprStringjoin.go index 466bef0c..cb702545 100644 --- a/schema/gen/go/genStructReprStringjoin.go +++ b/schema/gen/go/genStructReprStringjoin.go @@ -59,7 +59,7 @@ func (g structReprStringjoinReprGenerator) EmitNodeType(w io.Writer) { func (g structReprStringjoinReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } @@ -153,12 +153,12 @@ func (g structReprStringjoinReprBuilderGenerator) EmitNodeBuilderMethods(w io.Wr func (_{{ .Type | TypeSymbol }}__ReprPrototype) fromString(w *_{{ .Type | TypeSymbol }}, v string) error { ss, err := mixins.SplitExact(v, "{{ .Type.RepresentationStrategy.GetDelim }}", {{ len .Type.Fields }}) if err != nil { - return ipld.ErrUnmatchable{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Reason: err} + return schema.ErrUnmatchable{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Reason: err} } {{- $dot := . -}} {{- /* ranging modifies dot, unhelpfully */ -}} {{- range $i, $field := .Type.Fields }} if err := (_{{ $field.Type | TypeSymbol }}__ReprPrototype{}).fromString(&w.{{ $field | FieldSymbolLower }}, ss[{{ $i }}]); err != nil { - return ipld.ErrUnmatchable{TypeName:"{{ $dot.PkgName }}.{{ $dot.Type.Name }}.Repr", Reason: err} + return schema.ErrUnmatchable{TypeName:"{{ $dot.PkgName }}.{{ $dot.Type.Name }}.Repr", Reason: err} } {{- end}} return nil @@ -208,7 +208,7 @@ func (g structReprStringjoinReprBuilderGenerator) EmitNodeAssemblerMethodAssignN // 2. is it our own type? Handle specially -- we might be able to do efficient things. // 3. is it the right kind to morph into us? Do so. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } diff --git a/schema/gen/go/genStructReprTuple.go b/schema/gen/go/genStructReprTuple.go index b57c1eb3..f4a255ff 100644 --- a/schema/gen/go/genStructReprTuple.go +++ b/schema/gen/go/genStructReprTuple.go @@ -72,24 +72,24 @@ func (g structReprTupleReprGenerator) EmitNodeType(w io.Writer) { func (g structReprTupleReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (g structReprTupleReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByIndex(idx int64) (ipld.Node, error) { + func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByIndex(idx int64) (datamodel.Node, error) { switch idx { {{- range $i, $field := .Type.Fields }} case {{ $i }}: {{- if $field.IsOptional }} if n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Absent { - return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)} + return datamodel.Absent, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfInt(idx)} } {{- end}} {{- if $field.IsNullable }} if n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Null { - return ipld.Null, nil + return datamodel.Null, nil } {{- end}} {{- if $field.IsMaybe }} @@ -99,7 +99,7 @@ func (g structReprTupleReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { {{- end}} {{- end}} default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfInt(idx)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfInt(idx)} } } `, w, g.AdjCfg, g) @@ -107,7 +107,7 @@ func (g structReprTupleReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { func (g structReprTupleReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { + func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ki, err := key.AsInt() if err != nil { return nil, err @@ -144,7 +144,7 @@ func (g structReprTupleReprGenerator) EmitNodeMethodListIterator(w io.Writer) { // Now: finally we can get on with the actual templating. doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) ListIterator() ipld.ListIterator { + func (n *_{{ .Type | TypeSymbol }}__Repr) ListIterator() datamodel.ListIterator { {{- if .HaveTrailingOptionals }} end := {{ len .Type.Fields }}`+ func() string { // this next part was too silly in templates due to lack of reverse ranging. @@ -170,9 +170,9 @@ func (g structReprTupleReprGenerator) EmitNodeMethodListIterator(w io.Writer) { {{if .HaveTrailingOptionals }}end int{{end}} } - func (itr *_{{ .Type | TypeSymbol }}__ReprListItr) Next() (idx int64, v ipld.Node, err error) { + func (itr *_{{ .Type | TypeSymbol }}__ReprListItr) Next() (idx int64, v datamodel.Node, err error) { if itr.idx >= {{ len .Type.Fields }} { - return -1, nil, ipld.ErrIteratorOverread{} + return -1, nil, datamodel.ErrIteratorOverread{} } switch itr.idx { {{- range $i, $field := .Type.Fields }} @@ -180,12 +180,12 @@ func (g structReprTupleReprGenerator) EmitNodeMethodListIterator(w io.Writer) { idx = int64(itr.idx) {{- if $field.IsOptional }} if itr.n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Absent { - return -1, nil, ipld.ErrIteratorOverread{} + return -1, nil, datamodel.ErrIteratorOverread{} } {{- end}} {{- if $field.IsNullable }} if itr.n.{{ $field | FieldSymbolLower }}.m == schema.Maybe_Null { - v = ipld.Null + v = datamodel.Null break } {{- end}} @@ -312,7 +312,7 @@ func (g structReprTupleReprBuilderGenerator) EmitNodeAssemblerType(w io.Writer) func (g structReprTupleReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(w io.Writer) { // Future: This could do something strict with the sizehint; it currently ignores it. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) BeginList(int64) (ipld.ListAssembler, error) { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) BeginList(int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -380,7 +380,7 @@ func (g structReprTupleReprBuilderGenerator) emitListAssemblerChildTidyHelper(w } func (g structReprTupleReprBuilderGenerator) emitListAssemblerChildListAssemblerMethods(w io.Writer) { doTemplate(` - func (la *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleValue() ipld.NodeAssembler { + func (la *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch la.state { case laState_initial: // carry on @@ -392,7 +392,7 @@ func (g structReprTupleReprBuilderGenerator) emitListAssemblerChildListAssembler panic("invalid state: AssembleValue cannot be called on an assembler that's already finished") } if la.f >= {{ len .Type.Fields }} { - return _ErrorThunkAssembler{schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfInt({{ len .Type.Fields }})}} + return _ErrorThunkAssembler{schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfInt({{ len .Type.Fields }})}} } la.state = laState_midValue switch la.f { @@ -436,7 +436,7 @@ func (g structReprTupleReprBuilderGenerator) emitListAssemblerChildListAssembler } `, w, g.AdjCfg, g) doTemplate(` - func (la *_{{ .Type | TypeSymbol }}__ReprAssembler) ValuePrototype(_ int64) ipld.NodePrototype { + func (la *_{{ .Type | TypeSymbol }}__ReprAssembler) ValuePrototype(_ int64) datamodel.NodePrototype { panic("todo structbuilder tuplerepr valueprototype") } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genUnion.go b/schema/gen/go/genUnion.go index 7111e09a..1eb342da 100644 --- a/schema/gen/go/genUnion.go +++ b/schema/gen/go/genUnion.go @@ -151,25 +151,25 @@ func (g unionGenerator) EmitNodeTypeAssertions(w io.Writer) { func (g unionGenerator) EmitNodeMethodLookupByString(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByString(key string) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByString(key string) (datamodel.Node, error) { switch key { {{- range $i, $member := .Type.Members }} case "{{ $member.Name }}": {{- if (eq (dot.AdjCfg.UnionMemlayout dot.Type) "embedAll") }} if n.tag != {{ add $i 1 }} { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return &n.x{{ add $i 1 }}, nil {{- else if (eq (dot.AdjCfg.UnionMemlayout dot.Type) "interface") }} if n2, ok := n.x.({{ $member | TypeSymbol }}); ok { return n2, nil } else { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } {{- end}} {{- end}} default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } `, w, g.AdjCfg, g) @@ -177,7 +177,7 @@ func (g unionGenerator) EmitNodeMethodLookupByString(w io.Writer) { func (g unionGenerator) EmitNodeMethodLookupByNode(w io.Writer) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) LookupByNode(key ipld.Node) (ipld.Node, error) { + func (n {{ .Type | TypeSymbol }}) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err @@ -190,7 +190,7 @@ func (g unionGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g unionGenerator) EmitNodeMethodMapIterator(w io.Writer) { // This is kind of a hilarious "iterator": it has to count all the way up to... 1. doTemplate(` - func (n {{ .Type | TypeSymbol }}) MapIterator() ipld.MapIterator { + func (n {{ .Type | TypeSymbol }}) MapIterator() datamodel.MapIterator { return &_{{ .Type | TypeSymbol }}__MapItr{n, false} } @@ -199,9 +199,9 @@ func (g unionGenerator) EmitNodeMethodMapIterator(w io.Writer) { done bool } - func (itr *_{{ .Type | TypeSymbol }}__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) { + func (itr *_{{ .Type | TypeSymbol }}__MapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } {{- if (eq (.AdjCfg.UnionMemlayout .Type) "embedAll") }} switch itr.n.tag { @@ -356,7 +356,7 @@ func (g unionBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) { // // DRY: this turns out to be textually identical to the method for structs! (At least, for now. It could/should probably be optimized to get to the point faster in phase 3.) doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__Assembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -378,8 +378,8 @@ func (g unionBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) { *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -446,7 +446,7 @@ func (g unionBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { // Note that calling AssembleEntry again when it's not for the first entry *returns* an error; it doesn't panic. // This is subtle but important: trying to add more data than is acceptable is a data mismatch, not a system misuse, and must error accordingly politely. doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -488,7 +488,7 @@ func (g unionBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { {{- end}} {{- end}} } - return nil, ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} + return nil, schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} } `, w, g.AdjCfg, g) @@ -500,7 +500,7 @@ func (g unionBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { // and we don't want to make this call unchainable for everyone everywhere, either, so it can't be rewritten to have an immmediate error return. // The transition to midKey state is particularly irritating because it means this assembler will be perma-wedged; but I see no alternative. doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleKey() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -524,7 +524,7 @@ func (g unionBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { // and some of the logical continuity bounces through state in the form of 'ma.ca'. // The potential to DRY up some of this should be plentiful, but it's a bit heady. doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleValue() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -590,10 +590,10 @@ func (g unionBuilderGenerator) emitMapAssemblerMethods(w io.Writer) { `, w, g.AdjCfg, g) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__Assembler) KeyPrototype() ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } - func (ma *_{{ .Type | TypeSymbol }}__Assembler) ValuePrototype(k string) ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__Assembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { {{- range $i, $member := .Type.Members }} case "{{ $member.Name }}": @@ -641,20 +641,20 @@ func (g unionBuilderGenerator) emitKeyAssembler(w io.Writer) { return nil {{- end}} } - return ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}", Key:&_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } `, w, g.AdjCfg, g) stubs.EmitNodeAssemblerMethodAssignBytes(w) stubs.EmitNodeAssemblerMethodAssignLink(w) doTemplate(` - func (ka *_{{ .Type | TypeSymbol }}__KeyAssembler) AssignNode(v ipld.Node) error { + func (ka *_{{ .Type | TypeSymbol }}__KeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } - func (_{{ .Type | TypeSymbol }}__KeyAssembler) Prototype() ipld.NodePrototype { + func (_{{ .Type | TypeSymbol }}__KeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genUnionReprKeyed.go b/schema/gen/go/genUnionReprKeyed.go index 592ea42a..44b6213a 100644 --- a/schema/gen/go/genUnionReprKeyed.go +++ b/schema/gen/go/genUnionReprKeyed.go @@ -73,32 +73,32 @@ func (g unionReprKeyedReprGenerator) EmitNodeType(w io.Writer) { func (g unionReprKeyedReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (g unionReprKeyedReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { // Similar to the type-level method, except uses discriminant values as keys instead of the member type names. doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByString(key string) (ipld.Node, error) { + func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByString(key string) (datamodel.Node, error) { switch key { {{- range $i, $member := .Type.Members }} case "{{ $member | dot.Type.RepresentationStrategy.GetDiscriminant }}": {{- if (eq (dot.AdjCfg.UnionMemlayout dot.Type) "embedAll") }} if n.tag != {{ add $i 1 }} { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } return n.x{{ add $i 1 }}.Representation(), nil {{- else if (eq (dot.AdjCfg.UnionMemlayout dot.Type) "interface") }} if n2, ok := n.x.({{ $member | TypeSymbol }}); ok { return n2.Representation(), nil } else { - return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)} + return nil, datamodel.ErrNotExists{Segment: datamodel.PathSegmentOfString(key)} } {{- end}} {{- end}} default: - return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)} + return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(key)} } } `, w, g.AdjCfg, g) @@ -106,7 +106,7 @@ func (g unionReprKeyedReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { func (g unionReprKeyedReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) { + func (n *_{{ .Type | TypeSymbol }}__Repr) LookupByNode(key datamodel.Node) (datamodel.Node, error) { ks, err := key.AsString() if err != nil { return nil, err @@ -119,7 +119,7 @@ func (g unionReprKeyedReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g unionReprKeyedReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { // Similar to the type-level method, except yields discriminant values as keys instead of the member type names. doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) MapIterator() ipld.MapIterator { + func (n *_{{ .Type | TypeSymbol }}__Repr) MapIterator() datamodel.MapIterator { return &_{{ .Type | TypeSymbol }}__ReprMapItr{n, false} } @@ -128,9 +128,9 @@ func (g unionReprKeyedReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { done bool } - func (itr *_{{ .Type | TypeSymbol }}__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) { + func (itr *_{{ .Type | TypeSymbol }}__ReprMapItr) Next() (k datamodel.Node, v datamodel.Node, _ error) { if itr.done { - return nil, nil, ipld.ErrIteratorOverread{} + return nil, nil, datamodel.ErrIteratorOverread{} } {{- if (eq (.AdjCfg.UnionMemlayout .Type) "embedAll") }} switch itr.n.tag { @@ -251,7 +251,7 @@ func (g unionReprKeyedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNull(w func (g unionReprKeyedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) { // DRY: this is once again not-coincidentally very nearly equal to the type-level method. Would be good to dedup them... after we do the get-to-the-point-in-phase-3 improvement. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -273,8 +273,8 @@ func (g unionReprKeyedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -320,7 +320,7 @@ func (g unionReprKeyedReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) // DRY: the number of times these `ma.state` switches are appearing is truly intense! This is starting to look like one of them most important things to shrink the GSLOC/ASM size of! doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -362,12 +362,12 @@ func (g unionReprKeyedReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) {{- end}} } {{- end}} - return nil, ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} + return nil, schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} } `, w, g.AdjCfg, g) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleKey() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -388,7 +388,7 @@ func (g unionReprKeyedReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) `, w, g.AdjCfg, g) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleValue() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -452,10 +452,10 @@ func (g unionReprKeyedReprBuilderGenerator) emitMapAssemblerMethods(w io.Writer) `, w, g.AdjCfg, g) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) KeyPrototype() ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) KeyPrototype() datamodel.NodePrototype { return _String__Prototype{} } - func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__ReprAssembler) ValuePrototype(k string) datamodel.NodePrototype { switch k { {{- range $i, $member := .Type.Members }} case "{{ $member.Name }}": @@ -502,20 +502,20 @@ func (g unionReprKeyedReprBuilderGenerator) emitKeyAssembler(w io.Writer) { return nil {{- end}} } - return ipld.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? + return schema.ErrInvalidKey{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr", Key:&_String{k}} // TODO: error quality: ErrInvalidUnionDiscriminant ? } `, w, g.AdjCfg, g) stubs.EmitNodeAssemblerMethodAssignBytes(w) stubs.EmitNodeAssemblerMethodAssignLink(w) doTemplate(` - func (ka *_{{ .Type | TypeSymbol }}__ReprKeyAssembler) AssignNode(v ipld.Node) error { + func (ka *_{{ .Type | TypeSymbol }}__ReprKeyAssembler) AssignNode(v datamodel.Node) error { if v2, err := v.AsString(); err != nil { return err } else { return ka.AssignString(v2) } } - func (_{{ .Type | TypeSymbol }}__ReprKeyAssembler) Prototype() ipld.NodePrototype { + func (_{{ .Type | TypeSymbol }}__ReprKeyAssembler) Prototype() datamodel.NodePrototype { return _String__Prototype{} } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genUnionReprKinded.go b/schema/gen/go/genUnionReprKinded.go index 0be3f519..d98a8fba 100644 --- a/schema/gen/go/genUnionReprKinded.go +++ b/schema/gen/go/genUnionReprKinded.go @@ -65,13 +65,13 @@ func (g unionKindedReprGenerator) EmitNodeType(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } func (g unionKindedReprGenerator) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func (n *_{{ .Type | TypeSymbol }}__Repr) Kind() ipld.Kind { + func (n *_{{ .Type | TypeSymbol }}__Repr) Kind() datamodel.Kind { {{- if (eq (.AdjCfg.UnionMemlayout .Type) "embedAll") }} switch n.tag { {{- range $i, $member := .Type.Members }} @@ -115,7 +115,7 @@ func kindedUnionNodeMethodTemplateMunge( errorClause := `return ` + nopeSentinel if !nopeSentinelOnly { - errorClause += `, ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", MethodName: "` + methodName + `", AppropriateKind: ` + appropriateKind + `, ActualKind: n.Kind()}` + errorClause += `, datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", MethodName: "` + methodName + `", AppropriateKind: ` + appropriateKind + `, ActualKind: n.Kind()}` } return ` func (n *_{{ .Type | TypeSymbol }}__Repr) ` + methodSig + ` { @@ -150,11 +150,11 @@ func kindedUnionNodeMethodTemplateMunge( func (g unionKindedReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `LookupByString`, - `LookupByString(key string) (ipld.Node, error)`, + `LookupByString(key string) (datamodel.Node, error)`, `{{- if .Type.RepresentationStrategy.GetMember (Kind "map") }}`, `{{- if eq $member.RepresentationBehavior.String "map" }}`, `.LookupByString(key)`, - `ipld.KindSet_JustMap`, + `datamodel.KindSet_JustMap`, `nil`, false, ), w, g.AdjCfg, g) @@ -163,11 +163,11 @@ func (g unionKindedReprGenerator) EmitNodeMethodLookupByString(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `LookupByIndex`, - `LookupByIndex(idx int64) (ipld.Node, error)`, + `LookupByIndex(idx int64) (datamodel.Node, error)`, `{{- if .Type.RepresentationStrategy.GetMember (Kind "list") }}`, `{{- if eq $member.RepresentationBehavior.String "list" }}`, `.LookupByIndex(idx)`, - `ipld.KindSet_JustList`, + `datamodel.KindSet_JustList`, `nil`, false, ), w, g.AdjCfg, g) @@ -176,11 +176,11 @@ func (g unionKindedReprGenerator) EmitNodeMethodLookupByIndex(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `LookupByNode`, - `LookupByNode(key ipld.Node) (ipld.Node, error)`, + `LookupByNode(key datamodel.Node) (datamodel.Node, error)`, `{{- if or (.Type.RepresentationStrategy.GetMember (Kind "map")) (.Type.RepresentationStrategy.GetMember (Kind "list")) }}`, `{{- if or (eq $member.RepresentationBehavior.String "map") (eq $member.RepresentationBehavior.String "list") }}`, `.LookupByNode(key)`, - `ipld.KindSet_Recursive`, + `datamodel.KindSet_Recursive`, `nil`, false, ), w, g.AdjCfg, g) @@ -189,11 +189,11 @@ func (g unionKindedReprGenerator) EmitNodeMethodLookupByNode(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeMethodLookupBySegment(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `LookupBySegment`, - `LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)`, + `LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error)`, `{{- if or (.Type.RepresentationStrategy.GetMember (Kind "map")) (.Type.RepresentationStrategy.GetMember (Kind "list")) }}`, `{{- if or (eq $member.RepresentationBehavior.String "map") (eq $member.RepresentationBehavior.String "list") }}`, `.LookupBySegment(seg)`, - `ipld.KindSet_Recursive`, + `datamodel.KindSet_Recursive`, `nil`, false, ), w, g.AdjCfg, g) @@ -202,11 +202,11 @@ func (g unionKindedReprGenerator) EmitNodeMethodLookupBySegment(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `MapIterator`, - `MapIterator() ipld.MapIterator`, + `MapIterator() datamodel.MapIterator`, `{{- if .Type.RepresentationStrategy.GetMember (Kind "map") }}`, `{{- if eq $member.RepresentationBehavior.String "map" }}`, `.MapIterator()`, - `ipld.KindSet_JustMap`, + `datamodel.KindSet_JustMap`, `nil`, true, ), w, g.AdjCfg, g) @@ -215,11 +215,11 @@ func (g unionKindedReprGenerator) EmitNodeMethodMapIterator(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeMethodListIterator(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `ListIterator`, - `ListIterator() ipld.ListIterator`, + `ListIterator() datamodel.ListIterator`, `{{- if .Type.RepresentationStrategy.GetMember (Kind "list") }}`, `{{- if eq $member.RepresentationBehavior.String "list" }}`, `.ListIterator()`, - `ipld.KindSet_JustList`, + `datamodel.KindSet_JustList`, `nil`, true, ), w, g.AdjCfg, g) @@ -232,7 +232,7 @@ func (g unionKindedReprGenerator) EmitNodeMethodLength(w io.Writer) { `{{- if or (.Type.RepresentationStrategy.GetMember (Kind "map")) (.Type.RepresentationStrategy.GetMember (Kind "list")) }}`, `{{- if or (eq $member.RepresentationBehavior.String "map") (eq $member.RepresentationBehavior.String "list") }}`, `.Length()`, - `ipld.KindSet_Recursive`, + `datamodel.KindSet_Recursive`, `-1`, true, ), w, g.AdjCfg, g) @@ -261,7 +261,7 @@ func (g unionKindedReprGenerator) EmitNodeMethodAsBool(w io.Writer) { `{{- if .Type.RepresentationStrategy.GetMember (Kind "bool") }}`, `{{- if eq $member.RepresentationBehavior.String "bool" }}`, `.AsBool()`, - `ipld.KindSet_JustBool`, + `datamodel.KindSet_JustBool`, `false`, false, ), w, g.AdjCfg, g) @@ -274,7 +274,7 @@ func (g unionKindedReprGenerator) EmitNodeMethodAsInt(w io.Writer) { `{{- if .Type.RepresentationStrategy.GetMember (Kind "int") }}`, `{{- if eq $member.RepresentationBehavior.String "int" }}`, `.AsInt()`, - `ipld.KindSet_JustInt`, + `datamodel.KindSet_JustInt`, `0`, false, ), w, g.AdjCfg, g) @@ -287,7 +287,7 @@ func (g unionKindedReprGenerator) EmitNodeMethodAsFloat(w io.Writer) { `{{- if .Type.RepresentationStrategy.GetMember (Kind "float") }}`, `{{- if eq $member.RepresentationBehavior.String "float" }}`, `.AsFloat()`, - `ipld.KindSet_JustFloat`, + `datamodel.KindSet_JustFloat`, `0`, false, ), w, g.AdjCfg, g) @@ -300,7 +300,7 @@ func (g unionKindedReprGenerator) EmitNodeMethodAsString(w io.Writer) { `{{- if .Type.RepresentationStrategy.GetMember (Kind "string") }}`, `{{- if eq $member.RepresentationBehavior.String "string" }}`, `.AsString()`, - `ipld.KindSet_JustString`, + `datamodel.KindSet_JustString`, `""`, false, ), w, g.AdjCfg, g) @@ -313,7 +313,7 @@ func (g unionKindedReprGenerator) EmitNodeMethodAsBytes(w io.Writer) { `{{- if .Type.RepresentationStrategy.GetMember (Kind "bytes") }}`, `{{- if eq $member.RepresentationBehavior.String "bytes" }}`, `.AsBytes()`, - `ipld.KindSet_JustBytes`, + `datamodel.KindSet_JustBytes`, `nil`, false, ), w, g.AdjCfg, g) @@ -322,11 +322,11 @@ func (g unionKindedReprGenerator) EmitNodeMethodAsBytes(w io.Writer) { func (g unionKindedReprGenerator) EmitNodeMethodAsLink(w io.Writer) { doTemplate(kindedUnionNodeMethodTemplateMunge( `AsLink`, - `AsLink() (ipld.Link, error)`, + `AsLink() (datamodel.Link, error)`, `{{- if .Type.RepresentationStrategy.GetMember (Kind "link") }}`, `{{- if eq $member.RepresentationBehavior.String "link" }}`, `.AsLink()`, - `ipld.KindSet_JustLink`, + `datamodel.KindSet_JustLink`, `nil`, false, ), w, g.AdjCfg, g) @@ -467,7 +467,7 @@ func kindedUnionNodeAssemblerMethodTemplateMunge( func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(w io.Writer) { doTemplate(kindedUnionNodeAssemblerMethodTemplateMunge( `BeginMap`, - `BeginMap(sizeHint int64) (ipld.MapAssembler, error)`, + `BeginMap(sizeHint int64) (datamodel.MapAssembler, error)`, `{{- if eq $member.RepresentationBehavior.String "map" }}`, `.BeginMap(sizeHint)`, true, @@ -476,7 +476,7 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(w io.Wr func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(w io.Writer) { doTemplate(kindedUnionNodeAssemblerMethodTemplateMunge( `BeginList`, - `BeginList(sizeHint int64) (ipld.ListAssembler, error)`, + `BeginList(sizeHint int64) (datamodel.ListAssembler, error)`, `{{- if eq $member.RepresentationBehavior.String "list" }}`, `.BeginList(sizeHint)`, true, @@ -540,7 +540,7 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(w io func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignLink(w io.Writer) { doTemplate(kindedUnionNodeAssemblerMethodTemplateMunge( `AssignLink`, - `AssignLink(v ipld.Link) error `, + `AssignLink(v datamodel.Link) error `, `{{- if eq $member.RepresentationBehavior.String "link" }}`, `.AssignLink(v)`, false, @@ -555,7 +555,7 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io. // Errors are problematic again, same as is noted in kindedUnionNodeAssemblerMethodTemplateMunge. // We also end up returning errors with other method names due to how we delegate; unfortunate. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -578,22 +578,22 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io. return nil } switch v.Kind() { - case ipld.Kind_Bool: + case datamodel.Kind_Bool: v2, _ := v.AsBool() return na.AssignBool(v2) - case ipld.Kind_Int: + case datamodel.Kind_Int: v2, _ := v.AsInt() return na.AssignInt(v2) - case ipld.Kind_Float: + case datamodel.Kind_Float: v2, _ := v.AsFloat() return na.AssignFloat(v2) - case ipld.Kind_String: + case datamodel.Kind_String: v2, _ := v.AsString() return na.AssignString(v2) - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: v2, _ := v.AsBytes() return na.AssignBytes(v2) - case ipld.Kind_Map: + case datamodel.Kind_Map: na, err := na.BeginMap(v.Length()) if err != nil { return err @@ -612,7 +612,7 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io. } } return na.Finish() - case ipld.Kind_List: + case datamodel.Kind_List: na, err := na.BeginList(v.Length()) if err != nil { return err @@ -628,7 +628,7 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io. } } return na.Finish() - case ipld.Kind_Link: + case datamodel.Kind_Link: v2, _ := v.AsLink() return na.AssignLink(v2) default: @@ -639,7 +639,7 @@ func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io. } func (g unionKindedReprBuilderGenerator) EmitNodeAssemblerMethodPrototype(w io.Writer) { doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) Prototype() ipld.NodePrototype { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) Prototype() datamodel.NodePrototype { return _{{ .Type | TypeSymbol }}__ReprPrototype{} } `, w, g.AdjCfg, g) diff --git a/schema/gen/go/genUnionReprStringprefix.go b/schema/gen/go/genUnionReprStringprefix.go index 53fbe664..7bc4fb63 100644 --- a/schema/gen/go/genUnionReprStringprefix.go +++ b/schema/gen/go/genUnionReprStringprefix.go @@ -69,7 +69,7 @@ func (g unionReprStringprefixReprGenerator) EmitNodeType(w io.Writer) { func (g unionReprStringprefixReprGenerator) EmitNodeTypeAssertions(w io.Writer) { doTemplate(` - var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{} + var _ datamodel.Node = &_{{ .Type | TypeSymbol }}__Repr{} `, w, g.AdjCfg, g) } @@ -154,7 +154,7 @@ func (g unionReprStringprefixReprBuilderGenerator) EmitNodeBuilderMethods(w io.W func (_{{ .Type | TypeSymbol }}__ReprPrototype) fromString(w *_{{ .Type | TypeSymbol }}, v string) error { ss := mixins.SplitN(v, "{{ .Type.RepresentationStrategy.GetDelim }}", 2) if len(ss) != 2 { - return ipld.ErrUnmatchable{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr"}.Reasonf("expecting a stringprefix union but found no delimiter in the value") + return schema.ErrUnmatchable{TypeName:"{{ .PkgName }}.{{ .Type.Name }}.Repr"}.Reasonf("expecting a stringprefix union but found no delimiter in the value") } switch ss[0] { {{- range $i, $member := .Type.Members }} @@ -162,20 +162,20 @@ func (g unionReprStringprefixReprBuilderGenerator) EmitNodeBuilderMethods(w io.W {{- if (eq (dot.AdjCfg.UnionMemlayout dot.Type) "embedAll") }} w.tag = {{ add $i 1 }} if err := (_{{ $member | TypeSymbol }}__ReprPrototype{}).fromString(&w.x{{ add $i 1 }}, ss[1]); err != nil { - return ipld.ErrUnmatchable{TypeName:"{{ dot.PkgName }}.{{ dot.Type.Name }}.Repr", Reason: err} + return schema.ErrUnmatchable{TypeName:"{{ dot.PkgName }}.{{ dot.Type.Name }}.Repr", Reason: err} } return nil {{- else if (eq (dot.AdjCfg.UnionMemlayout dot.Type) "interface") }} var n2 _{{ $member | TypeSymbol }} if err := (_{{ $member | TypeSymbol }}__ReprPrototype{}).fromString(&n2, ss[1]); err != nil { - return ipld.ErrUnmatchable{TypeName:"{{ dot.PkgName }}.{{ dot.Type.Name }}.Repr", Reason: err} + return schema.ErrUnmatchable{TypeName:"{{ dot.PkgName }}.{{ dot.Type.Name }}.Repr", Reason: err} } w.x = &n2 return nil {{- end}} {{- end}} default: - return schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(ss[0])} + return schema.ErrNoSuchField{Type: nil /*TODO*/, Field: datamodel.PathSegmentOfString(ss[0])} } } `, w, g.AdjCfg, g) @@ -225,7 +225,7 @@ func (g unionReprStringprefixReprBuilderGenerator) EmitNodeAssemblerMethodAssign // 3. is it the right kind to morph into us? Do so. // TODO:DRY: this is identical to other string-repr-on-non-string-type. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } diff --git a/schema/gen/go/generate.go b/schema/gen/go/generate.go index bf99654e..24777627 100644 --- a/schema/gen/go/generate.go +++ b/schema/gen/go/generate.go @@ -93,9 +93,9 @@ func Generate(pth string, pkgName string, ts schema.TypeSystem, adjCfg *AdjunctC fmt.Fprintf(f, "package %s\n\n", pkgName) fmt.Fprintf(f, doNotEditComment+"\n\n") fmt.Fprintf(f, "import (\n") - fmt.Fprintf(f, "\tipld \"github.com/ipld/go-ipld-prime\"\n") // referenced for links + fmt.Fprintf(f, "\t\"github.com/ipld/go-ipld-prime/datamodel\"\n") // referenced for links fmt.Fprintf(f, ")\n") - fmt.Fprintf(f, "var _ ipld.Node = nil // suppress errors when this dependency is not referenced\n") + fmt.Fprintf(f, "var _ datamodel.Node = nil // suppress errors when this dependency is not referenced\n") // Emit the type table. EmitTypeTable(pkgName, ts, adjCfg, f) @@ -117,7 +117,7 @@ func Generate(pth string, pkgName string, ts schema.TypeSystem, adjCfg *AdjunctC fmt.Fprintf(f, "package %s\n\n", pkgName) fmt.Fprintf(f, doNotEditComment+"\n\n") fmt.Fprintf(f, "import (\n") - fmt.Fprintf(f, "\tipld \"github.com/ipld/go-ipld-prime\"\n") // referenced everywhere. + fmt.Fprintf(f, "\t\"github.com/ipld/go-ipld-prime/datamodel\"\n") // referenced everywhere. fmt.Fprintf(f, "\t\"github.com/ipld/go-ipld-prime/node/mixins\"\n") // referenced by node implementation guts. fmt.Fprintf(f, "\t\"github.com/ipld/go-ipld-prime/schema\"\n") // referenced by maybes (and surprisingly little else). fmt.Fprintf(f, ")\n\n") diff --git a/schema/gen/go/generators.go b/schema/gen/go/generators.go index f0c5ca3f..7671aeda 100644 --- a/schema/gen/go/generators.go +++ b/schema/gen/go/generators.go @@ -84,7 +84,7 @@ func EmitFileHeader(packageName string, w io.Writer) { fmt.Fprintf(w, "package %s\n\n", packageName) fmt.Fprintf(w, doNotEditComment+"\n\n") fmt.Fprintf(w, "import (\n") - fmt.Fprintf(w, "\tipld \"github.com/ipld/go-ipld-prime\"\n") + fmt.Fprintf(w, "\t\"github.com/ipld/go-ipld-prime/datamodel\"\n") fmt.Fprintf(w, "\t\"github.com/ipld/go-ipld-prime/node/mixins\"\n") fmt.Fprintf(w, "\t\"github.com/ipld/go-ipld-prime/schema\"\n") fmt.Fprintf(w, ")\n\n") diff --git a/schema/gen/go/genpartsCommon.go b/schema/gen/go/genpartsCommon.go index f2a6d6d0..fc4058a9 100644 --- a/schema/gen/go/genpartsCommon.go +++ b/schema/gen/go/genpartsCommon.go @@ -34,12 +34,12 @@ func emitNativeMaybe(w io.Writer, adjCfg *AdjunctCfg, data interface{}) { func (m Maybe{{ .Type | TypeSymbol }}) Exists() bool { return m.m == schema.Maybe_Value } - func (m Maybe{{ .Type | TypeSymbol }}) AsNode() ipld.Node { + func (m Maybe{{ .Type | TypeSymbol }}) AsNode() datamodel.Node { switch m.m { case schema.Maybe_Absent: - return ipld.Absent + return datamodel.Absent case schema.Maybe_Null: - return ipld.Null + return datamodel.Null case schema.Maybe_Value: return {{if not (MaybeUsesPtr .Type) }}&{{end}}m.v default: @@ -95,7 +95,7 @@ func emitNativeBuilder_scalar(w io.Writer, adjCfg *AdjunctCfg, data interface{}) func emitNodeTypeAssertions_typical(w io.Writer, adjCfg *AdjunctCfg, data interface{}) { doTemplate(` - var _ ipld.Node = ({{ .Type | TypeSymbol }})(&_{{ .Type | TypeSymbol }}{}) + var _ datamodel.Node = ({{ .Type | TypeSymbol }})(&_{{ .Type | TypeSymbol }}{}) var _ schema.TypedNode = ({{ .Type | TypeSymbol }})(&_{{ .Type | TypeSymbol }}{}) `, w, adjCfg, data) } @@ -110,7 +110,7 @@ func emitNodeMethodAsKind_scalar(w io.Writer, adjCfg *AdjunctCfg, data interface func emitNodeMethodPrototype_typical(w io.Writer, adjCfg *AdjunctCfg, data interface{}) { doTemplate(` - func ({{ if .IsRepr }}_{{end}}{{ .Type | TypeSymbol }}{{ if .IsRepr }}__Repr{{end}}) Prototype() ipld.NodePrototype { + func ({{ if .IsRepr }}_{{end}}{{ .Type | TypeSymbol }}{{ if .IsRepr }}__Repr{{end}}) Prototype() datamodel.NodePrototype { return _{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype{} } `, w, adjCfg, data) @@ -122,7 +122,7 @@ func emitNodePrototypeType_typical(w io.Writer, adjCfg *AdjunctCfg, data interfa doTemplate(` type _{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype struct{} - func (_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype) NewBuilder() ipld.NodeBuilder { + func (_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype) NewBuilder() datamodel.NodeBuilder { var nb _{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Builder nb.Reset() return &nb @@ -142,7 +142,7 @@ func emitNodePrototypeType_typical(w io.Writer, adjCfg *AdjunctCfg, data interfa // and two, mixins are also used in the repr generators, and it wouldn't be all sane for this method to end up also on reprs. func emitTypicalTypedNodeMethodRepresentation(w io.Writer, adjCfg *AdjunctCfg, data interface{}) { doTemplate(` - func (n {{ .Type | TypeSymbol }}) Representation() ipld.Node { + func (n {{ .Type | TypeSymbol }}) Representation() datamodel.Node { return (*_{{ .Type | TypeSymbol }}__Repr)(n) } `, w, adjCfg, data) @@ -161,7 +161,7 @@ func emitEmitNodeBuilderType_typical(w io.Writer, adjCfg *AdjunctCfg, data inter // We count on the zero value of any addntl non-common fields of the assembler being correct. func emitNodeBuilderMethods_typical(w io.Writer, adjCfg *AdjunctCfg, data interface{}) { doTemplate(` - func (nb *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Builder) Build() ipld.Node { + func (nb *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Builder) Build() datamodel.Node { if *nb.m != schema.Maybe_Value { panic("invalid state: cannot call Build on an assembler that's not finished") } @@ -258,7 +258,7 @@ func emitNodeAssemblerMethodAssignNode_scalar(w io.Writer, adjCfg *AdjunctCfg, d // 2. is it our own type? Handle specially -- we might be able to do efficient things. // 3. is it the right kind to morph into us? Do so. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__Assembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } diff --git a/schema/gen/go/genpartsList.go b/schema/gen/go/genpartsList.go index 305a61f1..ca087a58 100644 --- a/schema/gen/go/genpartsList.go +++ b/schema/gen/go/genpartsList.go @@ -25,7 +25,7 @@ func emitNodeAssemblerMethodBeginList_listoid(w io.Writer, adjCfg *AdjunctCfg, d // Would also want to examine if that makes desirable trades in gsloc/asmsize/speed/debuggability. // Only seems to apply to case of list-repr-list, so unclear if worth the effort. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { + func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -60,7 +60,7 @@ func emitNodeAssemblerMethodAssignNode_listoid(w io.Writer, adjCfg *AdjunctCfg, // This works easily for both type-level and representational nodes because // any divergences that have to do with the child value are nicely hidden behind `AssembleValue`. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -82,8 +82,8 @@ func emitNodeAssemblerMethodAssignNode_listoid(w io.Writer, adjCfg *AdjunctCfg, *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_List { - return ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}{{ if .IsRepr }}.Repr{{end}}", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_List { + return datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}{{ if .IsRepr }}.Repr{{end}}", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustList, ActualKind: v.Kind()} } itr := v.ListIterator() for !itr.Done() { @@ -154,7 +154,7 @@ func emitNodeAssemblerHelper_listoid_listAssemblerMethods(w io.Writer, adjCfg *A // DRY(nope): Can this be extracted to a shared function in the output? // Same story as the tidy helper -- it touches `la.va` concretely in several places, and that blocks extraction. doTemplate(` - func (la *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleValue() ipld.NodeAssembler { + func (la *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleValue() datamodel.NodeAssembler { switch la.state { case laState_initial: // carry on @@ -199,7 +199,7 @@ func emitNodeAssemblerHelper_listoid_listAssemblerMethods(w io.Writer, adjCfg *A } `, w, adjCfg, data) doTemplate(` - func (la *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) ValuePrototype(_ int64) ipld.NodePrototype { + func (la *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) ValuePrototype(_ int64) datamodel.NodePrototype { return _{{ .Type.ValueType | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype{} } `, w, adjCfg, data) diff --git a/schema/gen/go/genpartsMap.go b/schema/gen/go/genpartsMap.go index 27d5c715..571d5497 100644 --- a/schema/gen/go/genpartsMap.go +++ b/schema/gen/go/genpartsMap.go @@ -16,7 +16,7 @@ func emitNodeAssemblerMethodBeginMap_mapoid(w io.Writer, adjCfg *AdjunctCfg, dat // This allocation only happens if the 'w' ptr is nil, which means we're being used on a Maybe; // otherwise, the 'w' ptr should already be set, and we fill that memory location without allocating, as usual. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { + func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") @@ -50,7 +50,7 @@ func emitNodeAssemblerMethodAssignNode_mapoid(w io.Writer, adjCfg *AdjunctCfg, d // This works easily for both type-level and representational nodes because // any divergences that have to do with the child value are nicely hidden behind `AssembleKey` and `AssembleValue`. doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssignNode(v ipld.Node) error { + func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssignNode(v datamodel.Node) error { if v.IsNull() { return na.AssignNull() } @@ -72,8 +72,8 @@ func emitNodeAssemblerMethodAssignNode_mapoid(w io.Writer, adjCfg *AdjunctCfg, d *na.m = schema.Maybe_Value return nil } - if v.Kind() != ipld.Kind_Map { - return ipld.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}{{ if .IsRepr }}.Repr{{end}}", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()} + if v.Kind() != datamodel.Kind_Map { + return datamodel.ErrWrongKind{TypeName: "{{ .PkgName }}.{{ .Type.Name }}{{ if .IsRepr }}.Repr{{end}}", MethodName: "AssignNode", AppropriateKind: datamodel.KindSet_JustMap, ActualKind: v.Kind()} } itr := v.MapIterator() for !itr.Done() { @@ -200,7 +200,7 @@ func emitNodeAssemblerHelper_mapoid_mapAssemblerMethods(w io.Writer, adjCfg *Adj // except for the fact they need to call the valueFinishTidy function, which is another one of those points that blocks extraction because we strongly don't want virtual functions calls there. // Maybe the templates can be textually dedup'd more, though, at least. doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) { + func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleEntry(k string) (datamodel.NodeAssembler, error) { switch ma.state { case maState_initial: // carry on @@ -227,7 +227,7 @@ func emitNodeAssemblerHelper_mapoid_mapAssemblerMethods(w io.Writer, adjCfg *Adj } {{- end}} if _, exists := ma.w.m[k2]; exists { - return nil, ipld.ErrRepeatedMapKey{Key: &k2} + return nil, datamodel.ErrRepeatedMapKey{Key: &k2} } ma.w.t = append(ma.w.t, _{{ .Type | TypeSymbol }}__entry{k: k2}) tz := &ma.w.t[len(ma.w.t)-1] @@ -248,7 +248,7 @@ func emitNodeAssemblerHelper_mapoid_mapAssemblerMethods(w io.Writer, adjCfg *Adj } `, w, adjCfg, data) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleKey() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleKey() datamodel.NodeAssembler { switch ma.state { case maState_initial: // carry on @@ -271,7 +271,7 @@ func emitNodeAssemblerHelper_mapoid_mapAssemblerMethods(w io.Writer, adjCfg *Adj } `, w, adjCfg, data) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleValue() ipld.NodeAssembler { + func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) AssembleValue() datamodel.NodeAssembler { switch ma.state { case maState_initial: panic("invalid state: AssembleValue cannot be called when no key is primed") @@ -312,10 +312,10 @@ func emitNodeAssemblerHelper_mapoid_mapAssemblerMethods(w io.Writer, adjCfg *Adj } `, w, adjCfg, data) doTemplate(` - func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) KeyPrototype() ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) KeyPrototype() datamodel.NodePrototype { return _{{ .Type.KeyType | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype{} } - func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) ValuePrototype(_ string) ipld.NodePrototype { + func (ma *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) ValuePrototype(_ string) datamodel.NodePrototype { return _{{ .Type.ValueType | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Prototype{} } `, w, adjCfg, data) diff --git a/schema/gen/go/genpartsMinima.go b/schema/gen/go/genpartsMinima.go index 059307ed..7dc351f2 100644 --- a/schema/gen/go/genpartsMinima.go +++ b/schema/gen/go/genpartsMinima.go @@ -23,7 +23,7 @@ func EmitInternalEnums(packageName string, w io.Writer) { import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/schema" ) @@ -65,23 +65,23 @@ func EmitInternalEnums(packageName string, w io.Writer) { `)) // We occasionally need this erroring thunk to be able to snake an error out from some assembly processes. - // It implements all of ipld.NodeAssembler, but all of its methods return errors when used. + // It implements all of datamodel.NodeAssembler, but all of its methods return errors when used. fmt.Fprint(w, wish.Dedent(` type _ErrorThunkAssembler struct { e error } - func (ea _ErrorThunkAssembler) BeginMap(_ int64) (ipld.MapAssembler, error) { return nil, ea.e } - func (ea _ErrorThunkAssembler) BeginList(_ int64) (ipld.ListAssembler, error) { return nil, ea.e } + func (ea _ErrorThunkAssembler) BeginMap(_ int64) (datamodel.MapAssembler, error) { return nil, ea.e } + func (ea _ErrorThunkAssembler) BeginList(_ int64) (datamodel.ListAssembler, error) { return nil, ea.e } func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e } func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e } func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e } func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e } func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e } func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e } - func (ea _ErrorThunkAssembler) AssignLink(ipld.Link) error { return ea.e } - func (ea _ErrorThunkAssembler) AssignNode(ipld.Node) error { return ea.e } - func (ea _ErrorThunkAssembler) Prototype() ipld.NodePrototype { + func (ea _ErrorThunkAssembler) AssignLink(datamodel.Link) error { return ea.e } + func (ea _ErrorThunkAssembler) AssignNode(datamodel.Node) error { return ea.e } + func (ea _ErrorThunkAssembler) Prototype() datamodel.NodePrototype { panic(fmt.Errorf("cannot get prototype from error-carrying assembler: already derailed with error: %w", ea.e)) } `)) diff --git a/schema/gen/go/genpartsStrictoid.go b/schema/gen/go/genpartsStrictoid.go index 64d59378..2bf795ed 100644 --- a/schema/gen/go/genpartsStrictoid.go +++ b/schema/gen/go/genpartsStrictoid.go @@ -16,7 +16,7 @@ func emitNodeAssemblerMethodBeginMap_strictoid(w io.Writer, adjCfg *AdjunctCfg, // otherwise, the 'w' ptr should already be set, and we fill that memory location without allocating, as usual. // (Note that the Maybe we're talking about here is for us, not our children: so it applies on unions too.) doTemplate(` - func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) BeginMap(int64) (ipld.MapAssembler, error) { + func (na *_{{ .Type | TypeSymbol }}__{{ if .IsRepr }}Repr{{end}}Assembler) BeginMap(int64) (datamodel.MapAssembler, error) { switch *na.m { case schema.Maybe_Value, schema.Maybe_Null: panic("invalid state: cannot assign into assembler that's already finished") diff --git a/schema/gen/go/mixins/boolGenMixin.go b/schema/gen/go/mixins/boolGenMixin.go index 4d8b376e..b048050a 100644 --- a/schema/gen/go/mixins/boolGenMixin.go +++ b/schema/gen/go/mixins/boolGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type BoolTraits struct { @@ -12,57 +12,57 @@ type BoolTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (BoolTraits) Kind() ipld.Kind { - return ipld.Kind_Bool +func (BoolTraits) Kind() datamodel.Kind { + return datamodel.Kind_Bool } func (g BoolTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_Bool + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_Bool } `, w, g) } func (g BoolTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodLookupByString(w) } func (g BoolTraits) EmitNodeMethodLookupByNode(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodLookupByNode(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodLookupByNode(w) } func (g BoolTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodLookupByIndex(w) } func (g BoolTraits) EmitNodeMethodLookupBySegment(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodLookupBySegment(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodLookupBySegment(w) } func (g BoolTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodMapIterator(w) } func (g BoolTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodListIterator(w) } func (g BoolTraits) EmitNodeMethodLength(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodLength(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodLength(w) } func (g BoolTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodIsAbsent(w) } func (g BoolTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodIsNull(w) } func (g BoolTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodAsInt(w) } func (g BoolTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodAsFloat(w) } func (g BoolTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodAsString(w) } func (g BoolTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodAsBytes(w) } func (g BoolTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bool}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bool}.emitNodeMethodAsLink(w) } type BoolAssemblerTraits struct { @@ -71,33 +71,33 @@ type BoolAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (BoolAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_Bool +func (BoolAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_Bool } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodBeginMap(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodBeginList(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodAssignNull(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodAssignInt(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodAssignFloat(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodAssignString(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodAssignBytes(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodAssignLink(w) } func (g BoolAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bool}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bool}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/bytesGenMixin.go b/schema/gen/go/mixins/bytesGenMixin.go index 6d9136a6..953819ef 100644 --- a/schema/gen/go/mixins/bytesGenMixin.go +++ b/schema/gen/go/mixins/bytesGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type BytesTraits struct { @@ -12,57 +12,57 @@ type BytesTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (BytesTraits) Kind() ipld.Kind { - return ipld.Kind_Bytes +func (BytesTraits) Kind() datamodel.Kind { + return datamodel.Kind_Bytes } func (g BytesTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_Bytes + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_Bytes } `, w, g) } func (g BytesTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodLookupByString(w) } func (g BytesTraits) EmitNodeMethodLookupByNode(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodLookupByNode(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodLookupByNode(w) } func (g BytesTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodLookupByIndex(w) } func (g BytesTraits) EmitNodeMethodLookupBySegment(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodLookupBySegment(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodLookupBySegment(w) } func (g BytesTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodMapIterator(w) } func (g BytesTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodListIterator(w) } func (g BytesTraits) EmitNodeMethodLength(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodLength(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodLength(w) } func (g BytesTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodIsAbsent(w) } func (g BytesTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodIsNull(w) } func (g BytesTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodAsBool(w) } func (g BytesTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodAsInt(w) } func (g BytesTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodAsFloat(w) } func (g BytesTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodAsString(w) } func (g BytesTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Bytes}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Bytes}.emitNodeMethodAsLink(w) } type BytesAssemblerTraits struct { @@ -71,33 +71,33 @@ type BytesAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (BytesAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_Bytes +func (BytesAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_Bytes } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodBeginMap(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodBeginList(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodAssignNull(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodAssignBool(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodAssignInt(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodAssignFloat(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodAssignString(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodAssignLink(w) } func (g BytesAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Bytes}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Bytes}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/floatGenMixin.go b/schema/gen/go/mixins/floatGenMixin.go index 0ff69947..8e993cef 100644 --- a/schema/gen/go/mixins/floatGenMixin.go +++ b/schema/gen/go/mixins/floatGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type FloatTraits struct { @@ -12,57 +12,57 @@ type FloatTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (FloatTraits) Kind() ipld.Kind { - return ipld.Kind_Float +func (FloatTraits) Kind() datamodel.Kind { + return datamodel.Kind_Float } func (g FloatTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_Float + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_Float } `, w, g) } func (g FloatTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodLookupByString(w) } func (g FloatTraits) EmitNodeMethodLookupByNode(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodLookupByNode(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodLookupByNode(w) } func (g FloatTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodLookupByIndex(w) } func (g FloatTraits) EmitNodeMethodLookupBySegment(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodLookupBySegment(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodLookupBySegment(w) } func (g FloatTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodMapIterator(w) } func (g FloatTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodListIterator(w) } func (g FloatTraits) EmitNodeMethodLength(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodLength(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodLength(w) } func (g FloatTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodIsAbsent(w) } func (g FloatTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodIsNull(w) } func (g FloatTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodAsBool(w) } func (g FloatTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodAsInt(w) } func (g FloatTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodAsString(w) } func (g FloatTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodAsBytes(w) } func (g FloatTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Float}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Float}.emitNodeMethodAsLink(w) } type FloatAssemblerTraits struct { @@ -71,33 +71,33 @@ type FloatAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (FloatAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_Float +func (FloatAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_Float } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodBeginMap(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodBeginList(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodAssignNull(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodAssignBool(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodAssignInt(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodAssignString(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodAssignBytes(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodAssignLink(w) } func (g FloatAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Float}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Float}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/intGenMixin.go b/schema/gen/go/mixins/intGenMixin.go index b7a20f64..c45b136b 100644 --- a/schema/gen/go/mixins/intGenMixin.go +++ b/schema/gen/go/mixins/intGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type IntTraits struct { @@ -12,57 +12,57 @@ type IntTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (IntTraits) Kind() ipld.Kind { - return ipld.Kind_Int +func (IntTraits) Kind() datamodel.Kind { + return datamodel.Kind_Int } func (g IntTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_Int + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_Int } `, w, g) } func (g IntTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodLookupByString(w) } func (g IntTraits) EmitNodeMethodLookupByNode(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodLookupByNode(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodLookupByNode(w) } func (g IntTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodLookupByIndex(w) } func (g IntTraits) EmitNodeMethodLookupBySegment(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodLookupBySegment(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodLookupBySegment(w) } func (g IntTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodMapIterator(w) } func (g IntTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodListIterator(w) } func (g IntTraits) EmitNodeMethodLength(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodLength(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodLength(w) } func (g IntTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodIsAbsent(w) } func (g IntTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodIsNull(w) } func (g IntTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodAsBool(w) } func (g IntTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodAsFloat(w) } func (g IntTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodAsString(w) } func (g IntTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodAsBytes(w) } func (g IntTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Int}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Int}.emitNodeMethodAsLink(w) } type IntAssemblerTraits struct { @@ -71,33 +71,33 @@ type IntAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (IntAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_Int +func (IntAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_Int } func (g IntAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodBeginMap(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodBeginList(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodAssignNull(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodAssignBool(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodAssignFloat(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodAssignString(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodAssignBytes(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodAssignLink(w) } func (g IntAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Int}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Int}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/kindTraits.go b/schema/gen/go/mixins/kindTraits.go index 52f7feec..61bf3c89 100644 --- a/schema/gen/go/mixins/kindTraits.go +++ b/schema/gen/go/mixins/kindTraits.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // kindTraitsGenerator is the center of all the other mixins, @@ -28,77 +28,77 @@ type kindTraitsGenerator struct { PkgName string TypeName string // as will be printed in messages (e.g. can be goosed up a bit, like "Thing.Repr" instead of "_Thing__Repr"). TypeSymbol string // the identifier in code (sometimes is munged internals like "_Thing__Repr" corresponding to no publicly admitted schema.Type.Name). - Kind ipld.Kind + Kind datamodel.Kind } func (g kindTraitsGenerator) emitNodeMethodLookupByString(w io.Writer) { - if ipld.KindSet_JustMap.Contains(g.Kind) { + if datamodel.KindSet_JustMap.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) LookupByString(string) (ipld.Node, error) { + func ({{ .TypeSymbol }}) LookupByString(string) (datamodel.Node, error) { return mixins.{{ .Kind.String | title }}{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.LookupByString("") } `, w, g) } func (g kindTraitsGenerator) emitNodeMethodLookupByNode(w io.Writer) { - if ipld.KindSet_JustMap.Contains(g.Kind) { + if datamodel.KindSet_JustMap.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) LookupByNode(ipld.Node) (ipld.Node, error) { + func ({{ .TypeSymbol }}) LookupByNode(datamodel.Node) (datamodel.Node, error) { return mixins.{{ .Kind.String | title }}{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.LookupByNode(nil) } `, w, g) } func (g kindTraitsGenerator) emitNodeMethodLookupByIndex(w io.Writer) { - if ipld.KindSet_JustList.Contains(g.Kind) { + if datamodel.KindSet_JustList.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) LookupByIndex(idx int64) (ipld.Node, error) { + func ({{ .TypeSymbol }}) LookupByIndex(idx int64) (datamodel.Node, error) { return mixins.{{ .Kind.String | title }}{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.LookupByIndex(0) } `, w, g) } func (g kindTraitsGenerator) emitNodeMethodLookupBySegment(w io.Writer) { - if ipld.KindSet_Recursive.Contains(g.Kind) { + if datamodel.KindSet_Recursive.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { + func ({{ .TypeSymbol }}) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return mixins.{{ .Kind.String | title }}{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.LookupBySegment(seg) } `, w, g) } func (g kindTraitsGenerator) emitNodeMethodMapIterator(w io.Writer) { - if ipld.KindSet_JustMap.Contains(g.Kind) { + if datamodel.KindSet_JustMap.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) MapIterator() ipld.MapIterator { + func ({{ .TypeSymbol }}) MapIterator() datamodel.MapIterator { return nil } `, w, g) } func (g kindTraitsGenerator) emitNodeMethodListIterator(w io.Writer) { - if ipld.KindSet_JustList.Contains(g.Kind) { + if datamodel.KindSet_JustList.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) ListIterator() ipld.ListIterator { + func ({{ .TypeSymbol }}) ListIterator() datamodel.ListIterator { return nil } `, w, g) } func (g kindTraitsGenerator) emitNodeMethodLength(w io.Writer) { - if ipld.KindSet_Recursive.Contains(g.Kind) { + if datamodel.KindSet_Recursive.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -125,7 +125,7 @@ func (g kindTraitsGenerator) emitNodeMethodIsNull(w io.Writer) { } func (g kindTraitsGenerator) emitNodeMethodAsBool(w io.Writer) { - if ipld.KindSet_JustBool.Contains(g.Kind) { + if datamodel.KindSet_JustBool.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -136,7 +136,7 @@ func (g kindTraitsGenerator) emitNodeMethodAsBool(w io.Writer) { } func (g kindTraitsGenerator) emitNodeMethodAsInt(w io.Writer) { - if ipld.KindSet_JustInt.Contains(g.Kind) { + if datamodel.KindSet_JustInt.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -147,7 +147,7 @@ func (g kindTraitsGenerator) emitNodeMethodAsInt(w io.Writer) { } func (g kindTraitsGenerator) emitNodeMethodAsFloat(w io.Writer) { - if ipld.KindSet_JustFloat.Contains(g.Kind) { + if datamodel.KindSet_JustFloat.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -158,7 +158,7 @@ func (g kindTraitsGenerator) emitNodeMethodAsFloat(w io.Writer) { } func (g kindTraitsGenerator) emitNodeMethodAsString(w io.Writer) { - if ipld.KindSet_JustString.Contains(g.Kind) { + if datamodel.KindSet_JustString.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -169,7 +169,7 @@ func (g kindTraitsGenerator) emitNodeMethodAsString(w io.Writer) { } func (g kindTraitsGenerator) emitNodeMethodAsBytes(w io.Writer) { - if ipld.KindSet_JustBytes.Contains(g.Kind) { + if datamodel.KindSet_JustBytes.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -180,11 +180,11 @@ func (g kindTraitsGenerator) emitNodeMethodAsBytes(w io.Writer) { } func (g kindTraitsGenerator) emitNodeMethodAsLink(w io.Writer) { - if ipld.KindSet_JustLink.Contains(g.Kind) { + if datamodel.KindSet_JustLink.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .TypeSymbol }}) AsLink() (ipld.Link, error) { + func ({{ .TypeSymbol }}) AsLink() (datamodel.Link, error) { return mixins.{{ .Kind.String | title }}{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.AsLink() } `, w, g) @@ -196,7 +196,7 @@ type kindAssemblerTraitsGenerator struct { PkgName string TypeName string // as will be printed in messages (e.g. can be goosed up a bit, like "Thing.Repr" instead of "_Thing__Repr"). AppliedPrefix string // the prefix of what to attach methods to... this one is a little wild: should probably be either "_{{ .Type | TypeSymbol }}__" or "_{{ .Type | TypeSymbol }}__Repr", and we'll just add the words "Builder" and "Assembler". - Kind ipld.Kind + Kind datamodel.Kind } // bailed on extracting a common emitNodeBuilderType: too many variations in content and pointer placement to be worth it. @@ -208,29 +208,29 @@ type kindAssemblerTraitsGenerator struct { // - to still be ready for boatloads of exceptions if the representation isn't directly castable to and from the type-level node. func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodBeginMap(w io.Writer) { - if ipld.KindSet_JustMap.Contains(g.Kind) { + if datamodel.KindSet_JustMap.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .AppliedPrefix }}Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) { + func ({{ .AppliedPrefix }}Assembler) BeginMap(sizeHint int64) (datamodel.MapAssembler, error) { return mixins.{{ .Kind.String | title }}Assembler{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.BeginMap(0) } `, w, g) } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodBeginList(w io.Writer) { - if ipld.KindSet_JustList.Contains(g.Kind) { + if datamodel.KindSet_JustList.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .AppliedPrefix }}Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) { + func ({{ .AppliedPrefix }}Assembler) BeginList(sizeHint int64) (datamodel.ListAssembler, error) { return mixins.{{ .Kind.String | title }}Assembler{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.BeginList(0) } `, w, g) } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignNull(w io.Writer) { - if ipld.KindSet_JustNull.Contains(g.Kind) { + if datamodel.KindSet_JustNull.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -241,7 +241,7 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignNull(w io.Wri } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignBool(w io.Writer) { - if ipld.KindSet_JustBool.Contains(g.Kind) { + if datamodel.KindSet_JustBool.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -252,7 +252,7 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignBool(w io.Wri } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignInt(w io.Writer) { - if ipld.KindSet_JustInt.Contains(g.Kind) { + if datamodel.KindSet_JustInt.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -263,7 +263,7 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignInt(w io.Writ } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignFloat(w io.Writer) { - if ipld.KindSet_JustFloat.Contains(g.Kind) { + if datamodel.KindSet_JustFloat.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -274,7 +274,7 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignFloat(w io.Wr } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignString(w io.Writer) { - if ipld.KindSet_JustString.Contains(g.Kind) { + if datamodel.KindSet_JustString.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -285,7 +285,7 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignString(w io.W } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignBytes(w io.Writer) { - if ipld.KindSet_JustBytes.Contains(g.Kind) { + if datamodel.KindSet_JustBytes.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` @@ -296,11 +296,11 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignBytes(w io.Wr } func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignLink(w io.Writer) { - if ipld.KindSet_JustLink.Contains(g.Kind) { + if datamodel.KindSet_JustLink.Contains(g.Kind) { panic("gen internals error: you should've overriden this") } doTemplate(` - func ({{ .AppliedPrefix }}Assembler) AssignLink(ipld.Link) error { + func ({{ .AppliedPrefix }}Assembler) AssignLink(datamodel.Link) error { return mixins.{{ .Kind.String | title }}Assembler{TypeName: "{{ .PkgName }}.{{ .TypeName }}"}.AssignLink(nil) } `, w, g) @@ -310,7 +310,7 @@ func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodAssignLink(w io.Wri func (g kindAssemblerTraitsGenerator) emitNodeAssemblerMethodPrototype(w io.Writer) { doTemplate(` - func ({{ .AppliedPrefix }}Assembler) Prototype() ipld.NodePrototype { + func ({{ .AppliedPrefix }}Assembler) Prototype() datamodel.NodePrototype { return {{ .AppliedPrefix }}Prototype{} } `, w, g) diff --git a/schema/gen/go/mixins/linkGenMixin.go b/schema/gen/go/mixins/linkGenMixin.go index 5223b9a1..1b8d2973 100644 --- a/schema/gen/go/mixins/linkGenMixin.go +++ b/schema/gen/go/mixins/linkGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type LinkTraits struct { @@ -12,57 +12,57 @@ type LinkTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (LinkTraits) Kind() ipld.Kind { - return ipld.Kind_Link +func (LinkTraits) Kind() datamodel.Kind { + return datamodel.Kind_Link } func (g LinkTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_Link + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_Link } `, w, g) } func (g LinkTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodLookupByString(w) } func (g LinkTraits) EmitNodeMethodLookupByNode(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodLookupByNode(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodLookupByNode(w) } func (g LinkTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodLookupByIndex(w) } func (g LinkTraits) EmitNodeMethodLookupBySegment(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodLookupBySegment(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodLookupBySegment(w) } func (g LinkTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodMapIterator(w) } func (g LinkTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodListIterator(w) } func (g LinkTraits) EmitNodeMethodLength(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodLength(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodLength(w) } func (g LinkTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodIsAbsent(w) } func (g LinkTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodIsNull(w) } func (g LinkTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodAsBool(w) } func (g LinkTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodAsInt(w) } func (g LinkTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodAsFloat(w) } func (g LinkTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodAsString(w) } func (g LinkTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Link}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Link}.emitNodeMethodAsBytes(w) } type LinkAssemblerTraits struct { @@ -71,33 +71,33 @@ type LinkAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (LinkAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_Link +func (LinkAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_Link } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodBeginMap(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodBeginList(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodAssignNull(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodAssignBool(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodAssignInt(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodAssignFloat(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodAssignString(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodAssignBytes(w) } func (g LinkAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Link}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Link}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/listGenMixin.go b/schema/gen/go/mixins/listGenMixin.go index a1019507..7c26d4c2 100644 --- a/schema/gen/go/mixins/listGenMixin.go +++ b/schema/gen/go/mixins/listGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type ListTraits struct { @@ -12,56 +12,56 @@ type ListTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (ListTraits) Kind() ipld.Kind { - return ipld.Kind_List +func (ListTraits) Kind() datamodel.Kind { + return datamodel.Kind_List } func (g ListTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_List + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_List } `, w, g) } func (g ListTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodLookupByString(w) } func (g ListTraits) EmitNodeMethodLookupBySegment(w io.Writer) { doTemplate(` - func (n {{ .TypeSymbol }}) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { + func (n {{ .TypeSymbol }}) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { i, err := seg.Index() if err != nil { - return nil, ipld.ErrInvalidSegmentForList{TypeName: "{{ .PkgName }}.{{ .TypeName }}", TroubleSegment: seg, Reason: err} + return nil, datamodel.ErrInvalidSegmentForList{TypeName: "{{ .PkgName }}.{{ .TypeName }}", TroubleSegment: seg, Reason: err} } return n.LookupByIndex(i) } `, w, g) } func (g ListTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodMapIterator(w) } func (g ListTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodIsAbsent(w) } func (g ListTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodIsNull(w) } func (g ListTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodAsBool(w) } func (g ListTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodAsInt(w) } func (g ListTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodAsFloat(w) } func (g ListTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodAsString(w) } func (g ListTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodAsBytes(w) } func (g ListTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_List}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_List}.emitNodeMethodAsLink(w) } type ListAssemblerTraits struct { @@ -70,33 +70,33 @@ type ListAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (ListAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_List +func (ListAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_List } func (g ListAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodBeginMap(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignNull(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignBool(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignInt(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignFloat(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignString(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignBytes(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodAssignLink(w) } func (g ListAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_List}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_List}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/mapGenMixin.go b/schema/gen/go/mixins/mapGenMixin.go index cd5dee83..570deccb 100644 --- a/schema/gen/go/mixins/mapGenMixin.go +++ b/schema/gen/go/mixins/mapGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type MapTraits struct { @@ -12,52 +12,52 @@ type MapTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (MapTraits) Kind() ipld.Kind { - return ipld.Kind_Map +func (MapTraits) Kind() datamodel.Kind { + return datamodel.Kind_Map } func (g MapTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_Map + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_Map } `, w, g) } func (g MapTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodLookupByIndex(w) } func (g MapTraits) EmitNodeMethodLookupBySegment(w io.Writer) { doTemplate(` - func (n {{ .TypeSymbol }}) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) { + func (n {{ .TypeSymbol }}) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) { return n.LookupByString(seg.String()) } `, w, g) } func (g MapTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodListIterator(w) } func (g MapTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodIsAbsent(w) } func (g MapTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodIsNull(w) } func (g MapTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodAsBool(w) } func (g MapTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodAsInt(w) } func (g MapTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodAsFloat(w) } func (g MapTraits) EmitNodeMethodAsString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodAsString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodAsString(w) } func (g MapTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodAsBytes(w) } func (g MapTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_Map}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_Map}.emitNodeMethodAsLink(w) } type MapAssemblerTraits struct { @@ -66,33 +66,33 @@ type MapAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (MapAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_Map +func (MapAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_Map } func (g MapAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodBeginList(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignNull(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignBool(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignInt(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignFloat(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignString(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignString(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignBytes(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodAssignLink(w) } func (g MapAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_Map}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_Map}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/mixins/stringGenMixin.go b/schema/gen/go/mixins/stringGenMixin.go index e13516b5..c4e21c12 100644 --- a/schema/gen/go/mixins/stringGenMixin.go +++ b/schema/gen/go/mixins/stringGenMixin.go @@ -3,7 +3,7 @@ package mixins import ( "io" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type StringTraits struct { @@ -12,57 +12,57 @@ type StringTraits struct { TypeSymbol string // see doc in kindTraitsGenerator } -func (StringTraits) Kind() ipld.Kind { - return ipld.Kind_String +func (StringTraits) Kind() datamodel.Kind { + return datamodel.Kind_String } func (g StringTraits) EmitNodeMethodKind(w io.Writer) { doTemplate(` - func ({{ .TypeSymbol }}) Kind() ipld.Kind { - return ipld.Kind_String + func ({{ .TypeSymbol }}) Kind() datamodel.Kind { + return datamodel.Kind_String } `, w, g) } func (g StringTraits) EmitNodeMethodLookupByString(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodLookupByString(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodLookupByString(w) } func (g StringTraits) EmitNodeMethodLookupByNode(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodLookupByNode(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodLookupByNode(w) } func (g StringTraits) EmitNodeMethodLookupByIndex(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodLookupByIndex(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodLookupByIndex(w) } func (g StringTraits) EmitNodeMethodLookupBySegment(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodLookupBySegment(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodLookupBySegment(w) } func (g StringTraits) EmitNodeMethodMapIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodMapIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodMapIterator(w) } func (g StringTraits) EmitNodeMethodListIterator(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodListIterator(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodListIterator(w) } func (g StringTraits) EmitNodeMethodLength(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodLength(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodLength(w) } func (g StringTraits) EmitNodeMethodIsAbsent(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodIsAbsent(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodIsAbsent(w) } func (g StringTraits) EmitNodeMethodIsNull(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodIsNull(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodIsNull(w) } func (g StringTraits) EmitNodeMethodAsBool(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodAsBool(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodAsBool(w) } func (g StringTraits) EmitNodeMethodAsInt(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodAsInt(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodAsInt(w) } func (g StringTraits) EmitNodeMethodAsFloat(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodAsFloat(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodAsFloat(w) } func (g StringTraits) EmitNodeMethodAsBytes(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodAsBytes(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodAsBytes(w) } func (g StringTraits) EmitNodeMethodAsLink(w io.Writer) { - kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.Kind_String}.emitNodeMethodAsLink(w) + kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, datamodel.Kind_String}.emitNodeMethodAsLink(w) } type StringAssemblerTraits struct { @@ -71,33 +71,33 @@ type StringAssemblerTraits struct { AppliedPrefix string // see doc in kindAssemblerTraitsGenerator } -func (StringAssemblerTraits) Kind() ipld.Kind { - return ipld.Kind_String +func (StringAssemblerTraits) Kind() datamodel.Kind { + return datamodel.Kind_String } func (g StringAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodBeginMap(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodBeginMap(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodBeginList(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodBeginList(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodAssignNull(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodAssignNull(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodAssignBool(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodAssignBool(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodAssignInt(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodAssignInt(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodAssignFloat(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodAssignFloat(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodAssignBytes(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodAssignBytes(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodAssignLink(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodAssignLink(w) } func (g StringAssemblerTraits) EmitNodeAssemblerMethodPrototype(w io.Writer) { - kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.Kind_String}.emitNodeAssemblerMethodPrototype(w) + kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, datamodel.Kind_String}.emitNodeAssemblerMethodPrototype(w) } diff --git a/schema/gen/go/templateUtil.go b/schema/gen/go/templateUtil.go index fb7c327d..b1e881a9 100644 --- a/schema/gen/go/templateUtil.go +++ b/schema/gen/go/templateUtil.go @@ -7,7 +7,7 @@ import ( wish "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) func doTemplate(tmplstr string, w io.Writer, adjCfg *AdjunctCfg, data interface{}) { @@ -31,74 +31,74 @@ func doTemplate(tmplstr string, w io.Writer, adjCfg *AdjunctCfg, data interface{ // (This may seem silly, but empirically, I found myself writing a dummy line to store the value of dot before endering a range clause >20 times; that's plenty.) "dot": func() interface{} { return data }, - "KindPrim": func(k ipld.Kind) string { + "KindPrim": func(k datamodel.Kind) string { switch k { - case ipld.Kind_Map: + case datamodel.Kind_Map: panic("this isn't useful for non-scalars") - case ipld.Kind_List: + case datamodel.Kind_List: panic("this isn't useful for non-scalars") - case ipld.Kind_Null: + case datamodel.Kind_Null: panic("this isn't useful for null") - case ipld.Kind_Bool: + case datamodel.Kind_Bool: return "bool" - case ipld.Kind_Int: + case datamodel.Kind_Int: return "int64" - case ipld.Kind_Float: + case datamodel.Kind_Float: return "float64" - case ipld.Kind_String: + case datamodel.Kind_String: return "string" - case ipld.Kind_Bytes: + case datamodel.Kind_Bytes: return "[]byte" - case ipld.Kind_Link: - return "ipld.Link" + case datamodel.Kind_Link: + return "datamodel.Link" default: panic("invalid enumeration value!") } }, - "Kind": func(s string) ipld.Kind { + "Kind": func(s string) datamodel.Kind { switch s { case "map": - return ipld.Kind_Map + return datamodel.Kind_Map case "list": - return ipld.Kind_List + return datamodel.Kind_List case "null": - return ipld.Kind_Null + return datamodel.Kind_Null case "bool": - return ipld.Kind_Bool + return datamodel.Kind_Bool case "int": - return ipld.Kind_Int + return datamodel.Kind_Int case "float": - return ipld.Kind_Float + return datamodel.Kind_Float case "string": - return ipld.Kind_String + return datamodel.Kind_String case "bytes": - return ipld.Kind_Bytes + return datamodel.Kind_Bytes case "link": - return ipld.Kind_Link + return datamodel.Kind_Link default: panic("invalid enumeration value!") } }, - "KindSymbol": func(k ipld.Kind) string { + "KindSymbol": func(k datamodel.Kind) string { switch k { - case ipld.Kind_Map: - return "ipld.Kind_Map" - case ipld.Kind_List: - return "ipld.Kind_List" - case ipld.Kind_Null: - return "ipld.Kind_Null" - case ipld.Kind_Bool: - return "ipld.Kind_Bool" - case ipld.Kind_Int: - return "ipld.Kind_Int" - case ipld.Kind_Float: - return "ipld.Kind_Float" - case ipld.Kind_String: - return "ipld.Kind_String" - case ipld.Kind_Bytes: - return "ipld.Kind_Bytes" - case ipld.Kind_Link: - return "ipld.Kind_Link" + case datamodel.Kind_Map: + return "datamodel.Kind_Map" + case datamodel.Kind_List: + return "datamodel.Kind_List" + case datamodel.Kind_Null: + return "datamodel.Kind_Null" + case datamodel.Kind_Bool: + return "datamodel.Kind_Bool" + case datamodel.Kind_Int: + return "datamodel.Kind_Int" + case datamodel.Kind_Float: + return "datamodel.Kind_Float" + case datamodel.Kind_String: + return "datamodel.Kind_String" + case datamodel.Kind_Bytes: + return "datamodel.Kind_Bytes" + case datamodel.Kind_Link: + return "datamodel.Kind_Link" default: panic("invalid enumeration value!") } diff --git a/schema/gen/go/testEngine_disabled_test.go b/schema/gen/go/testEngine_disabled_test.go index 3702401f..3814a5e8 100644 --- a/schema/gen/go/testEngine_disabled_test.go +++ b/schema/gen/go/testEngine_disabled_test.go @@ -11,7 +11,7 @@ import ( "path/filepath" "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) func buildGennedCode(t *testing.T, prefix string, pkgName string) { @@ -45,7 +45,6 @@ func buildGennedCode(t *testing.T, prefix string, pkgName string) { t.Skip("behavioral tests for generated code skipped: you used the 'skipgenbehavtests' build tag.") } - -func fnPrototypeByName(prefix string) func(string) ipld.NodePrototype { +func fnPrototypeByName(prefix string) func(string) datamodel.NodePrototype { return nil // unused } diff --git a/schema/gen/go/testEngine_nocgo_test.go b/schema/gen/go/testEngine_nocgo_test.go index 76073075..607d0b15 100644 --- a/schema/gen/go/testEngine_nocgo_test.go +++ b/schema/gen/go/testEngine_nocgo_test.go @@ -26,7 +26,7 @@ import ( "path/filepath" "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) func buildGennedCode(t *testing.T, prefix string, pkgName string) { @@ -60,6 +60,6 @@ func buildGennedCode(t *testing.T, prefix string, pkgName string) { t.Skip("behavioral tests for generated code skipped: cgo is required for these tests") } -func fnPrototypeByName(prefix string) func(string) ipld.NodePrototype { +func fnPrototypeByName(prefix string) func(string) datamodel.NodePrototype { return nil // unused } diff --git a/schema/gen/go/testEngine_plugin_test.go b/schema/gen/go/testEngine_plugin_test.go index 1f684d5b..40d38395 100644 --- a/schema/gen/go/testEngine_plugin_test.go +++ b/schema/gen/go/testEngine_plugin_test.go @@ -10,7 +10,7 @@ import ( "plugin" "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) func objPath(prefix string) string { @@ -35,7 +35,7 @@ func buildGennedCode(t *testing.T, prefix string, _ string) { } } -func fnPrototypeByName(prefix string) func(string) ipld.NodePrototype { +func fnPrototypeByName(prefix string) func(string) datamodel.NodePrototype { plg, err := plugin.Open(objPath(prefix)) if err != nil { panic(err) // Panic because if this was going to flunk, we expected it to flunk earlier when we ran 'go build'. @@ -44,5 +44,5 @@ func fnPrototypeByName(prefix string) func(string) ipld.NodePrototype { if err != nil { panic(err) } - return sym.(func(string) ipld.NodePrototype) + return sym.(func(string) datamodel.NodePrototype) } diff --git a/schema/gen/go/testEngine_test.go b/schema/gen/go/testEngine_test.go index 8e652b57..b751e6b2 100644 --- a/schema/gen/go/testEngine_test.go +++ b/schema/gen/go/testEngine_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/node/tests" "github.com/ipld/go-ipld-prime/schema" ) @@ -19,15 +19,15 @@ type genAndCompileEngine struct { adjCfg AdjunctCfg - prototypeByName func(string) ipld.NodePrototype + prototypeByName func(string) datamodel.NodePrototype } -var tmpGenBuildDir = filepath.Join(os.TempDir(), "go-ipld-prime-gengo") +var tmpGenBuildDir = filepath.Join(os.TempDir(), "test-go-ipld-prime-gengo") func (e *genAndCompileEngine) Init(t *testing.T, ts schema.TypeSystem) { // Make directories for the package we're about to generate. // They will live in a temporary directory, usually - // /tmp/go-ipld-prime-gengo on Linux. It can be removed at any time. + // /tmp/test-go-ipld-prime-gengo on Linux. It can be removed at any time. // We don't by default because it's nicer to let go's builds of things cache. // If you change the names of types, though, you'll have garbage files leftover, // and that's currently a manual cleanup problem. Sorry. @@ -49,9 +49,9 @@ func (e *genAndCompileEngine) Init(t *testing.T, ts schema.TypeSystem) { doTemplate(` package `+pkgName+` - import "github.com/ipld/go-ipld-prime" + import "github.com/ipld/go-ipld-prime/datamodel" - func GetPrototypeByName(name string) ipld.NodePrototype { + func GetPrototypeByName(name string) datamodel.NodePrototype { switch name { {{- range . }} case "{{ .Name }}": @@ -76,6 +76,6 @@ func (e *genAndCompileEngine) Init(t *testing.T, ts schema.TypeSystem) { e.prototypeByName = fnPrototypeByName(e.prefix) } -func (e *genAndCompileEngine) PrototypeByName(name string) ipld.NodePrototype { +func (e *genAndCompileEngine) PrototypeByName(name string) datamodel.NodePrototype { return e.prototypeByName(name) } diff --git a/schema/gen/go/testutil_test.go b/schema/gen/go/testutil_test.go index 2838318f..bb6c1126 100644 --- a/schema/gen/go/testutil_test.go +++ b/schema/gen/go/testutil_test.go @@ -1,7 +1,7 @@ package gengo import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // This file is full of helper functions. Most are moderately embarassing. @@ -10,13 +10,13 @@ import ( // they'd probably be much less fragile and give better error messages that way. // On the other hand, the functions for condensing two-arg returns wouldn't go away anyway. -func plz(n ipld.Node, e error) ipld.Node { +func plz(n datamodel.Node, e error) datamodel.Node { if e != nil { panic(e) } return n } -func plzStr(n ipld.Node, e error) string { +func plzStr(n datamodel.Node, e error) string { if e != nil { panic(e) } @@ -26,14 +26,14 @@ func plzStr(n ipld.Node, e error) string { panic(ok) } } -func str(n ipld.Node) string { +func str(n datamodel.Node) string { if s, ok := n.AsString(); ok == nil { return s } else { panic(ok) } } -func erp(n ipld.Node, e error) interface{} { +func erp(n datamodel.Node, e error) interface{} { if e != nil { return e } @@ -41,6 +41,6 @@ func erp(n ipld.Node, e error) interface{} { } // purely to syntactically flip large inline closures so we can see the argument at the top rather than the bottom of the block. -func withNode(n ipld.Node, cb func(n ipld.Node)) { +func withNode(n datamodel.Node, cb func(n datamodel.Node)) { cb(n) } diff --git a/schema/kind.go b/schema/kind.go index 10c30e02..db0ee492 100644 --- a/schema/kind.go +++ b/schema/kind.go @@ -1,12 +1,12 @@ package schema import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // TypeKind is an enum of kind in the IPLD Schema system. // -// Note that schema.TypeKind is distinct from ipld.Kind! +// Note that schema.TypeKind is distinct from datamodel.Kind! // Schema kinds include concepts such as "struct" and "enum", which are // concepts only introduced by the Schema layer, and not present in the // Data Model layer. @@ -62,7 +62,7 @@ func (k TypeKind) String() string { } } -// ActsLike returns a constant from the ipld.Kind enum describing what +// ActsLike returns a constant from the datamodel.Kind enum describing what // this schema.TypeKind acts like at the Data Model layer. // // Things with similar names are generally conserved @@ -74,34 +74,34 @@ func (k TypeKind) String() string { // it does not necessarily describe how it will be *serialized* // (for example, a struct will always act like a map, even if it has a tuple // representation strategy and thus becomes a list when serialized). -func (k TypeKind) ActsLike() ipld.Kind { +func (k TypeKind) ActsLike() datamodel.Kind { switch k { case TypeKind_Invalid: - return ipld.Kind_Invalid + return datamodel.Kind_Invalid case TypeKind_Map: - return ipld.Kind_Map + return datamodel.Kind_Map case TypeKind_List: - return ipld.Kind_List + return datamodel.Kind_List case TypeKind_Unit: - return ipld.Kind_Bool // maps to 'true'. + return datamodel.Kind_Bool // maps to 'true'. case TypeKind_Bool: - return ipld.Kind_Bool + return datamodel.Kind_Bool case TypeKind_Int: - return ipld.Kind_Int + return datamodel.Kind_Int case TypeKind_Float: - return ipld.Kind_Float + return datamodel.Kind_Float case TypeKind_String: - return ipld.Kind_String + return datamodel.Kind_String case TypeKind_Bytes: - return ipld.Kind_Bytes + return datamodel.Kind_Bytes case TypeKind_Link: - return ipld.Kind_Link + return datamodel.Kind_Link case TypeKind_Struct: - return ipld.Kind_Map // clear enough: fields are keys. + return datamodel.Kind_Map // clear enough: fields are keys. case TypeKind_Union: - return ipld.Kind_Map // REVIEW: unions are tricky. + return datamodel.Kind_Map // REVIEW: unions are tricky. case TypeKind_Enum: - return ipld.Kind_String // 'AsString' is the one clear thing to define. + return datamodel.Kind_String // 'AsString' is the one clear thing to define. default: panic("invalid enumeration value!") } diff --git a/schema/schema2/kind.go b/schema/schema2/kind.go index 10c30e02..db0ee492 100644 --- a/schema/schema2/kind.go +++ b/schema/schema2/kind.go @@ -1,12 +1,12 @@ package schema import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // TypeKind is an enum of kind in the IPLD Schema system. // -// Note that schema.TypeKind is distinct from ipld.Kind! +// Note that schema.TypeKind is distinct from datamodel.Kind! // Schema kinds include concepts such as "struct" and "enum", which are // concepts only introduced by the Schema layer, and not present in the // Data Model layer. @@ -62,7 +62,7 @@ func (k TypeKind) String() string { } } -// ActsLike returns a constant from the ipld.Kind enum describing what +// ActsLike returns a constant from the datamodel.Kind enum describing what // this schema.TypeKind acts like at the Data Model layer. // // Things with similar names are generally conserved @@ -74,34 +74,34 @@ func (k TypeKind) String() string { // it does not necessarily describe how it will be *serialized* // (for example, a struct will always act like a map, even if it has a tuple // representation strategy and thus becomes a list when serialized). -func (k TypeKind) ActsLike() ipld.Kind { +func (k TypeKind) ActsLike() datamodel.Kind { switch k { case TypeKind_Invalid: - return ipld.Kind_Invalid + return datamodel.Kind_Invalid case TypeKind_Map: - return ipld.Kind_Map + return datamodel.Kind_Map case TypeKind_List: - return ipld.Kind_List + return datamodel.Kind_List case TypeKind_Unit: - return ipld.Kind_Bool // maps to 'true'. + return datamodel.Kind_Bool // maps to 'true'. case TypeKind_Bool: - return ipld.Kind_Bool + return datamodel.Kind_Bool case TypeKind_Int: - return ipld.Kind_Int + return datamodel.Kind_Int case TypeKind_Float: - return ipld.Kind_Float + return datamodel.Kind_Float case TypeKind_String: - return ipld.Kind_String + return datamodel.Kind_String case TypeKind_Bytes: - return ipld.Kind_Bytes + return datamodel.Kind_Bytes case TypeKind_Link: - return ipld.Kind_Link + return datamodel.Kind_Link case TypeKind_Struct: - return ipld.Kind_Map // clear enough: fields are keys. + return datamodel.Kind_Map // clear enough: fields are keys. case TypeKind_Union: - return ipld.Kind_Map // REVIEW: unions are tricky. + return datamodel.Kind_Map // REVIEW: unions are tricky. case TypeKind_Enum: - return ipld.Kind_String // 'AsString' is the one clear thing to define. + return datamodel.Kind_String // 'AsString' is the one clear thing to define. default: panic("invalid enumeration value!") } diff --git a/schema/schema2/type.go b/schema/schema2/type.go index 32c4cdd0..9f85fddc 100644 --- a/schema/schema2/type.go +++ b/schema/schema2/type.go @@ -1,7 +1,7 @@ package schema import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // typesystem.Type is an union interface; each of the `Type*` concrete types @@ -55,7 +55,7 @@ type Type interface { // The returned value is a 1:1 association with which of the concrete // "schema.Type*" structs this interface can be cast to. // - // Note that a schema.TypeKind is a different enum than ipld.Kind; + // Note that a schema.TypeKind is a different enum than datamodel.Kind; // and furthermore, there's no strict relationship between them. // schema.TypedNode values can be described by *two* distinct Kinds: // one which describes how the Node itself will act, @@ -83,5 +83,5 @@ type Type interface { // You may also be interested in a related property that might have been called "TypeBehavior". // However, this method doesn't exist, because it's a deterministic property of `TypeKind()`! // You can use `TypeKind.ActsLike()` to get type-level behavioral information. - RepresentationBehavior() ipld.Kind + RepresentationBehavior() datamodel.Kind } diff --git a/schema/schema2/type_bool.go b/schema/schema2/type_bool.go index 8d6edaef..0c51379c 100644 --- a/schema/schema2/type_bool.go +++ b/schema/schema2/type_bool.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,6 +29,6 @@ func (t *TypeBool) Name() TypeName { return t.name } -func (t TypeBool) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Bool +func (t TypeBool) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Bool } diff --git a/schema/schema2/type_bytes.go b/schema/schema2/type_bytes.go index 8ec4b97f..6127779c 100644 --- a/schema/schema2/type_bytes.go +++ b/schema/schema2/type_bytes.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,6 +29,6 @@ func (t *TypeBytes) Name() TypeName { return t.name } -func (t TypeBytes) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Bytes +func (t TypeBytes) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Bytes } diff --git a/schema/schema2/type_enum.go b/schema/schema2/type_enum.go index 671f04c6..128f0a0c 100644 --- a/schema/schema2/type_enum.go +++ b/schema/schema2/type_enum.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -41,12 +41,12 @@ func (t *TypeEnum) Name() TypeName { return t.name } -func (t TypeEnum) RepresentationBehavior() ipld.Kind { +func (t TypeEnum) RepresentationBehavior() datamodel.Kind { switch t.dmt.FieldRepresentation().AsInterface().(type) { case schemadmt.EnumRepresentation_String: - return ipld.Kind_String + return datamodel.Kind_String case schemadmt.EnumRepresentation_Int: - return ipld.Kind_Int + return datamodel.Kind_Int default: panic("unreachable") } diff --git a/schema/schema2/type_float.go b/schema/schema2/type_float.go index ab0039a7..8c907546 100644 --- a/schema/schema2/type_float.go +++ b/schema/schema2/type_float.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,6 +29,6 @@ func (t *TypeFloat) Name() TypeName { return t.name } -func (t TypeFloat) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Float +func (t TypeFloat) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Float } diff --git a/schema/schema2/type_int.go b/schema/schema2/type_int.go index a322ebb5..9e73660d 100644 --- a/schema/schema2/type_int.go +++ b/schema/schema2/type_int.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,6 +29,6 @@ func (t *TypeInt) Name() TypeName { return t.name } -func (t TypeInt) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Int +func (t TypeInt) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Int } diff --git a/schema/schema2/type_link.go b/schema/schema2/type_link.go index 1359aee5..df015af5 100644 --- a/schema/schema2/type_link.go +++ b/schema/schema2/type_link.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,8 +29,8 @@ func (t *TypeLink) Name() TypeName { return t.name } -func (t TypeLink) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Link +func (t TypeLink) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Link } // -- specific to TypeLink --> diff --git a/schema/schema2/type_list.go b/schema/schema2/type_list.go index b2cabd9f..19402c1b 100644 --- a/schema/schema2/type_list.go +++ b/schema/schema2/type_list.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,8 +29,8 @@ func (t *TypeList) Name() TypeName { return t.name } -func (t TypeList) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Map +func (t TypeList) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Map } // -- specific to TypeList --> diff --git a/schema/schema2/type_map.go b/schema/schema2/type_map.go index 462afe4c..76f218f8 100644 --- a/schema/schema2/type_map.go +++ b/schema/schema2/type_map.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,8 +29,8 @@ func (t *TypeMap) Name() TypeName { return t.name } -func (t TypeMap) RepresentationBehavior() ipld.Kind { - return ipld.Kind_Map +func (t TypeMap) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_Map } // -- specific to TypeMap --> diff --git a/schema/schema2/type_string.go b/schema/schema2/type_string.go index 860c9c5d..c10425a8 100644 --- a/schema/schema2/type_string.go +++ b/schema/schema2/type_string.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -29,6 +29,6 @@ func (t *TypeString) Name() TypeName { return t.name } -func (t TypeString) RepresentationBehavior() ipld.Kind { - return ipld.Kind_String +func (t TypeString) RepresentationBehavior() datamodel.Kind { + return datamodel.Kind_String } diff --git a/schema/schema2/type_struct.go b/schema/schema2/type_struct.go index 06bebb9f..a3e8a0bf 100644 --- a/schema/schema2/type_struct.go +++ b/schema/schema2/type_struct.go @@ -3,7 +3,7 @@ package schema import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -62,18 +62,18 @@ func (t *TypeStruct) Name() TypeName { return t.name } -func (t TypeStruct) RepresentationBehavior() ipld.Kind { +func (t TypeStruct) RepresentationBehavior() datamodel.Kind { switch t.dmt.FieldRepresentation().AsInterface().(type) { case schemadmt.StructRepresentation_Map: - return ipld.Kind_Map + return datamodel.Kind_Map case schemadmt.StructRepresentation_Tuple: - return ipld.Kind_List + return datamodel.Kind_List case schemadmt.StructRepresentation_Stringpairs: - return ipld.Kind_String + return datamodel.Kind_String case schemadmt.StructRepresentation_Stringjoin: - return ipld.Kind_String + return datamodel.Kind_String case schemadmt.StructRepresentation_Listpairs: - return ipld.Kind_List + return datamodel.Kind_List default: panic("unreachable") } diff --git a/schema/schema2/type_union.go b/schema/schema2/type_union.go index 7716a854..63841e68 100644 --- a/schema/schema2/type_union.go +++ b/schema/schema2/type_union.go @@ -1,7 +1,7 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -63,20 +63,20 @@ func (t *TypeUnion) Name() TypeName { return t.name } -func (t TypeUnion) RepresentationBehavior() ipld.Kind { +func (t TypeUnion) RepresentationBehavior() datamodel.Kind { switch t.dmt.FieldRepresentation().AsInterface().(type) { case schemadmt.UnionRepresentation_Keyed: - return ipld.Kind_Map + return datamodel.Kind_Map case schemadmt.UnionRepresentation_Kinded: - return ipld.Kind_Invalid // you can't know with this one, until you see the value (and thus can see its inhabitant's behavior)! + return datamodel.Kind_Invalid // you can't know with this one, until you see the value (and thus can see its inhabitant's behavior)! case schemadmt.UnionRepresentation_Envelope: - return ipld.Kind_Map + return datamodel.Kind_Map case schemadmt.UnionRepresentation_Inline: - return ipld.Kind_Map + return datamodel.Kind_Map case schemadmt.UnionRepresentation_StringPrefix: - return ipld.Kind_String + return datamodel.Kind_String case schemadmt.UnionRepresentation_BytePrefix: - return ipld.Kind_Bytes + return datamodel.Kind_Bytes default: panic("unreachable") } @@ -120,7 +120,7 @@ func (r UnionRepresentation_Keyed) GetDiscriminantForType(t Type) string { // GetMember returns type info for the member matching the kind argument, // or may return nil if that kind is not mapped to a member of this union. -func (r UnionRepresentation_Kinded) GetMember(k ipld.Kind) Type { +func (r UnionRepresentation_Kinded) GetMember(k datamodel.Kind) Type { rkdmt, _ := schemadmt.Type.RepresentationKind.FromString(k.String()) // FUTURE: this is currently awkward because we used a string where we should use an enum; this can be fixed when codegen for enums is implemented. tn := r.dmt.Lookup(rkdmt) if tn == nil { diff --git a/schema/schema2/typesystem.go b/schema/schema2/typesystem.go index 3ec0bf8d..be4a4023 100644 --- a/schema/schema2/typesystem.go +++ b/schema/schema2/typesystem.go @@ -3,7 +3,7 @@ package schema import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" schemadmt "github.com/ipld/go-ipld-prime/schema/dmt" ) @@ -160,7 +160,7 @@ func BuildTypeSystem(schdmt schemadmt.Schema) (*TypeSystem, []error) { // We create these temporary things rather than looking in the typesystem map we're accumulating because it makes the process work correctly regardless of order. // For some of the kinds, this is fairly overkill (we know that the representation behavior of a bool type is bool because it doesn't have any other representation strategies!) // but I've ground the whole thing out in a consistent way anyway. - var mkind ipld.Kind + var mkind datamodel.Kind switch t3 := typesdmt.Lookup(v).AsInterface().(type) { case schemadmt.TypeBool: mkind = TypeBool{dmt: t3}.RepresentationBehavior() @@ -190,7 +190,7 @@ func BuildTypeSystem(schdmt schemadmt.Schema) (*TypeSystem, []error) { panic("unreachable") } // TODO RepresentationKind is supposed to be an enum, but is not presently generated as such. This block's use of `k` as a string should turn into something cleaner when enum gen is implemented and used for RepresentationKind. - if mkind == ipld.Kind_Invalid { + if mkind == datamodel.Kind_Invalid { ee = append(ee, fmt.Errorf("kinded union %s declares a %s kind should be received as type %s, which is not sensible because that type is also a kinded union", tn, k, v)) } else if k.String() != mkind.String() { ee = append(ee, fmt.Errorf("kinded union %s declares a %s kind should be received as type %s, but that type's representation kind is %s", tn, k, v, mkind)) @@ -207,7 +207,7 @@ func BuildTypeSystem(schdmt schemadmt.Schema) (*TypeSystem, []error) { _, v := itr.Next() // As with the switch above which handles kinded union members, we go for the full destructuring here. // It's slightly overkill considering that most of the type kinds will flatly error in practice, but consistency is nice. - var mkind ipld.Kind + var mkind datamodel.Kind switch t3 := typesdmt.Lookup(v).AsInterface().(type) { case schemadmt.TypeBool: mkind = TypeBool{dmt: t3}.RepresentationBehavior() @@ -240,7 +240,7 @@ func BuildTypeSystem(schdmt schemadmt.Schema) (*TypeSystem, []error) { case schemadmt.TypeStruct: // Check representation strategy first. Still has to be mappy. t4 := TypeStruct{dmt: t3} - if t4.RepresentationBehavior() != ipld.Kind_Map { + if t4.RepresentationBehavior() != datamodel.Kind_Map { goto kindcheck // it'll fail, of course, but this goto DRY's the error message. } @@ -267,7 +267,7 @@ func BuildTypeSystem(schdmt schemadmt.Schema) (*TypeSystem, []error) { panic("unreachable") } kindcheck: - if mkind != ipld.Kind_Map { + if mkind != datamodel.Kind_Map { ee = append(ee, fmt.Errorf("union %s has representation strategy inline, which requires all members have map representations, so %s (which has representation kind %s) is not a valid member", tn, v, mkind)) } } @@ -416,7 +416,7 @@ func hasStringRepresentation(t schemadmt.TypeDefn) bool { // The discriminantsMap is an untyped Node because it turns out convenient to do that way: // we happen to know all the different union representations have a map *somewhere* for this, // but its position and key types vary. Untyped access lets us write more reusable code in this case. -func checkUnionDiscriminantInfo(tn TypeName, members []schemadmt.TypeName, discriminantsMap ipld.Node, ee *[]error) { +func checkUnionDiscriminantInfo(tn TypeName, members []schemadmt.TypeName, discriminantsMap datamodel.Node, ee *[]error) { for itr := discriminantsMap.MapIterator(); !itr.Done(); { _, v, _ := itr.Next() found := false diff --git a/schema/tmpBuilders.go b/schema/tmpBuilders.go index 4be9ba00..82a93923 100644 --- a/schema/tmpBuilders.go +++ b/schema/tmpBuilders.go @@ -3,7 +3,7 @@ package schema import ( "fmt" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Everything in this file is __a temporary hack__ and will be __removed__. @@ -104,7 +104,7 @@ func SpawnUnion(name TypeName, members []TypeName, repr UnionRepresentation) *Ty func SpawnUnionRepresentationKeyed(table map[string]TypeName) UnionRepresentation_Keyed { return UnionRepresentation_Keyed{table} } -func SpawnUnionRepresentationKinded(table map[ipld.Kind]TypeName) UnionRepresentation_Kinded { +func SpawnUnionRepresentationKinded(table map[datamodel.Kind]TypeName) UnionRepresentation_Kinded { return UnionRepresentation_Kinded{table} } func SpawnUnionRepresentationStringprefix(delim string, table map[string]TypeName) UnionRepresentation_Stringprefix { diff --git a/schema/type.go b/schema/type.go index f2565e8a..f463061b 100644 --- a/schema/type.go +++ b/schema/type.go @@ -1,7 +1,7 @@ package schema import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) type TypeName string // = ast.TypeName @@ -60,7 +60,7 @@ type Type interface { // The returned value is a 1:1 association with which of the concrete // "schema.Type*" structs this interface can be cast to. // - // Note that a schema.TypeKind is a different enum than ipld.Kind; + // Note that a schema.TypeKind is a different enum than datamodel.Kind; // and furthermore, there's no strict relationship between them. // schema.TypedNode values can be described by *two* distinct Kinds: // one which describes how the Node itself will act, @@ -88,7 +88,7 @@ type Type interface { // You may also be interested in a related property that might have been called "TypeBehavior". // However, this method doesn't exist, because it's a deterministic property of `TypeKind()`! // You can use `TypeKind.ActsLike()` to get type-level behavioral information. - RepresentationBehavior() ipld.Kind + RepresentationBehavior() datamodel.Kind } var ( @@ -180,7 +180,7 @@ type UnionRepresentation_Keyed struct { table map[string]TypeName // key is user-defined freetext } type UnionRepresentation_Kinded struct { - table map[ipld.Kind]TypeName + table map[datamodel.Kind]TypeName } type UnionRepresentation_Envelope struct { discriminantKey string diff --git a/schema/typeMethods.go b/schema/typeMethods.go index 73d5aa10..5c90e4b3 100644 --- a/schema/typeMethods.go +++ b/schema/typeMethods.go @@ -1,7 +1,7 @@ package schema import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) /* cookie-cutter standard interface stuff */ @@ -24,45 +24,45 @@ func (TypeUnion) TypeKind() TypeKind { return TypeKind_Union } func (TypeStruct) TypeKind() TypeKind { return TypeKind_Struct } func (TypeEnum) TypeKind() TypeKind { return TypeKind_Enum } -func (TypeBool) RepresentationBehavior() ipld.Kind { return ipld.Kind_Bool } -func (TypeString) RepresentationBehavior() ipld.Kind { return ipld.Kind_String } -func (TypeBytes) RepresentationBehavior() ipld.Kind { return ipld.Kind_Bytes } -func (TypeInt) RepresentationBehavior() ipld.Kind { return ipld.Kind_Int } -func (TypeFloat) RepresentationBehavior() ipld.Kind { return ipld.Kind_Float } -func (TypeMap) RepresentationBehavior() ipld.Kind { return ipld.Kind_Map } -func (TypeList) RepresentationBehavior() ipld.Kind { return ipld.Kind_List } -func (TypeLink) RepresentationBehavior() ipld.Kind { return ipld.Kind_Link } -func (t TypeUnion) RepresentationBehavior() ipld.Kind { +func (TypeBool) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_Bool } +func (TypeString) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_String } +func (TypeBytes) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_Bytes } +func (TypeInt) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_Int } +func (TypeFloat) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_Float } +func (TypeMap) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_Map } +func (TypeList) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_List } +func (TypeLink) RepresentationBehavior() datamodel.Kind { return datamodel.Kind_Link } +func (t TypeUnion) RepresentationBehavior() datamodel.Kind { switch t.representation.(type) { case UnionRepresentation_Keyed: - return ipld.Kind_Map + return datamodel.Kind_Map case UnionRepresentation_Kinded: - return ipld.Kind_Invalid // you can't know with this one, until you see the value (and thus can its inhabitant's behavior)! + return datamodel.Kind_Invalid // you can't know with this one, until you see the value (and thus can its inhabitant's behavior)! case UnionRepresentation_Envelope: - return ipld.Kind_Map + return datamodel.Kind_Map case UnionRepresentation_Inline: - return ipld.Kind_Map + return datamodel.Kind_Map default: panic("unreachable") } } -func (t TypeStruct) RepresentationBehavior() ipld.Kind { +func (t TypeStruct) RepresentationBehavior() datamodel.Kind { switch t.representation.(type) { case StructRepresentation_Map: - return ipld.Kind_Map + return datamodel.Kind_Map case StructRepresentation_Tuple: - return ipld.Kind_List + return datamodel.Kind_List case StructRepresentation_StringPairs: - return ipld.Kind_String + return datamodel.Kind_String case StructRepresentation_Stringjoin: - return ipld.Kind_String + return datamodel.Kind_String default: panic("unreachable") } } -func (t TypeEnum) RepresentationBehavior() ipld.Kind { +func (t TypeEnum) RepresentationBehavior() datamodel.Kind { // TODO: this should have a representation strategy switch too; sometimes that will indicate int representation behavior. - return ipld.Kind_String + return datamodel.Kind_String } /* interesting methods per Type type */ @@ -163,7 +163,7 @@ func (r UnionRepresentation_Stringprefix) GetDiscriminant(t Type) string { // GetMember returns type info for the member matching the kind argument, // or may return nil if that kind is not mapped to a member of this union. -func (r UnionRepresentation_Kinded) GetMember(k ipld.Kind) TypeName { +func (r UnionRepresentation_Kinded) GetMember(k datamodel.Kind) TypeName { return r.table[k] } diff --git a/schema/typedNode.go b/schema/typedNode.go index 730805ce..cae7cc6a 100644 --- a/schema/typedNode.go +++ b/schema/typedNode.go @@ -1,19 +1,19 @@ package schema import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) -// schema.TypedNode is a superset of the ipld.Node interface, and has additional behaviors. +// schema.TypedNode is a superset of the datamodel.Node interface, and has additional behaviors. // // A schema.TypedNode can be inspected for its schema.Type and schema.TypeKind, // which conveys much more and richer information than the Data Model layer -// ipld.Kind. +// datamodel.Kind. // // There are many different implementations of schema.TypedNode. -// One implementation can wrap any other existing ipld.Node (i.e., it's zero-copy) +// One implementation can wrap any other existing datamodel.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 +// another implementation similarly wraps any other existing datamodel.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 schema.TypedNode. @@ -28,7 +28,7 @@ import ( // return ErrNotExists, because the representation isn't a schema.TypedNode! type TypedNode interface { // schema.TypedNode acts just like a regular Node for almost all purposes; - // which ipld.Kind it acts as is determined by the TypeKind. + // which datamodel.Kind it acts as is determined by the TypeKind. // (Note that the representation strategy of the type does *not* affect // the Kind of schema.TypedNode -- rather, the representation strategy // affects the `.Representation().Kind()`.) @@ -36,19 +36,19 @@ type TypedNode interface { // For example: if the `.Type().TypeKind()` of this node is "struct", // it will act like Kind() == "map" // (even if Type().(Struct).ReprStrategy() is "tuple"). - ipld.Node + datamodel.Node // Type returns a reference to the reified schema.Type value. Type() Type - // Representation returns an ipld.Node which sees the data in this node + // Representation returns an datamodel.Node which sees the data in this node // in its representation form. // // For example: if the `.Type().TypeKind()` of this node is "struct", // `.Representation().TypeKind()` may vary based on its representation strategy: // if the representation strategy is "map", then it will be Kind=="map"; // if the streatgy is "tuple", then it will be Kind=="list". - Representation() ipld.Node + Representation() datamodel.Node } // schema.TypedLinkNode is a superset of the schema.TypedNode interface, and has one additional behavior. @@ -61,26 +61,26 @@ type TypedNode interface { // with a code-gen'd node builder while utilizing the automatic loading facilities // of the traversal package, you could write a LinkNodeBuilderChooser as follows: // -// func LinkNodeBuilderChooser(lnk ipld.Link, lnkCtx ipld.LinkContext) ipld.NodePrototype { +// func LinkNodeBuilderChooser(lnk datamodel.Link, lnkCtx linking.LinkContext) datamodel.NodePrototype { // if tlnkNd, ok := lnkCtx.LinkNode.(schema.TypedLinkNode); ok { // return tlnkNd.LinkTargetNodePrototype() // } -// return basicnode.Prototype__Any{} +// return basicnode.Prototype.Any // } // type TypedLinkNode interface { - LinkTargetNodePrototype() ipld.NodePrototype + LinkTargetNodePrototype() datamodel.NodePrototype } -// TypedPrototype is a superset of the ipld.Nodeprototype interface, and has -// additional behaviors, much like TypedNode for ipld.Node. +// TypedPrototype is a superset of the datamodel.Nodeprototype interface, and has +// additional behaviors, much like TypedNode for datamodel.Node. type TypedPrototype interface { - ipld.NodePrototype + datamodel.NodePrototype // Type returns a reference to the reified schema.Type value. Type() Type - // Representation returns an ipld.NodePrototype for the representation + // Representation returns an datamodel.NodePrototype for the representation // form of the prototype. - Representation() ipld.NodePrototype + Representation() datamodel.NodePrototype } diff --git a/storage/memory.go b/storage/memory.go index 52ba4b8d..fd6bfd8c 100644 --- a/storage/memory.go +++ b/storage/memory.go @@ -5,15 +5,16 @@ import ( "fmt" "io" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" ) -// Memory is a simple in-memory storage for data indexed by ipld.Link. +// Memory is a simple in-memory storage for data indexed by datamodel.Link. // (It's little more than a map -- in fact, the map is exported, // and you can poke it directly.) // -// The OpenRead method conforms to ipld.BlockReadOpener, -// and the OpenWrite method conforms to ipld.BlockWriteOpener. +// The OpenRead method conforms to linking.BlockReadOpener, +// and the OpenWrite method conforms to linking.BlockWriteOpener. // Therefore it's easy to use in a LinkSystem like this: // // store := storage.Memory{} @@ -23,17 +24,17 @@ import ( // This storage is mostly expected to be used for testing and demos, // and as an example of how you can implement and integrate your own storage systems. type Memory struct { - Bag map[ipld.Link][]byte + Bag map[datamodel.Link][]byte } func (store *Memory) beInitialized() { if store.Bag != nil { return } - store.Bag = make(map[ipld.Link][]byte) + store.Bag = make(map[datamodel.Link][]byte) } -func (store *Memory) OpenRead(lnkCtx ipld.LinkContext, lnk ipld.Link) (io.Reader, error) { +func (store *Memory) OpenRead(lnkCtx linking.LinkContext, lnk datamodel.Link) (io.Reader, error) { store.beInitialized() data, exists := store.Bag[lnk] if !exists { @@ -42,10 +43,10 @@ func (store *Memory) OpenRead(lnkCtx ipld.LinkContext, lnk ipld.Link) (io.Reader return bytes.NewReader(data), nil } -func (store *Memory) OpenWrite(lnkCtx ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error) { +func (store *Memory) OpenWrite(lnkCtx linking.LinkContext) (io.Writer, linking.BlockWriteCommitter, error) { store.beInitialized() buf := bytes.Buffer{} - return &buf, func(lnk ipld.Link) error { + return &buf, func(lnk datamodel.Link) error { store.Bag[lnk] = buf.Bytes() return nil }, nil diff --git a/traversal/common.go b/traversal/common.go index d3e2282d..363f6e61 100644 --- a/traversal/common.go +++ b/traversal/common.go @@ -4,7 +4,8 @@ import ( "context" "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" "github.com/ipld/go-ipld-prime/schema" ) @@ -19,7 +20,7 @@ func (tc *Config) init() { tc.Ctx = context.Background() } if tc.LinkTargetNodePrototypeChooser == nil { - tc.LinkTargetNodePrototypeChooser = func(lnk ipld.Link, lnkCtx ipld.LinkContext) (ipld.NodePrototype, error) { + tc.LinkTargetNodePrototypeChooser = func(lnk datamodel.Link, lnkCtx linking.LinkContext) (datamodel.NodePrototype, error) { if tlnkNd, ok := lnkCtx.LinkNode.(schema.TypedLinkNode); ok { return tlnkNd.LinkTargetNodePrototype(), nil } @@ -40,17 +41,17 @@ func (prog *Progress) init() { // If it's a string or an int, that's it. // Any other case will panic. (If you're using this one keys returned by a MapIterator, though, you can ignore this possibility; // any compliant map implementation should've already rejected that data long ago, and should not be able to yield it to you from an iterator.) -func asPathSegment(n ipld.Node) ipld.PathSegment { +func asPathSegment(n datamodel.Node) datamodel.PathSegment { if n2, ok := n.(schema.TypedNode); ok { n = n2.Representation() } switch n.Kind() { - case ipld.Kind_String: + case datamodel.Kind_String: s, _ := n.AsString() - return ipld.PathSegmentOfString(s) - case ipld.Kind_Int: + return datamodel.PathSegmentOfString(s) + case datamodel.Kind_Int: i, _ := n.AsInt() - return ipld.PathSegmentOfInt(i) + return datamodel.PathSegmentOfInt(i) default: panic(fmt.Errorf("cannot get pathsegment from a %s", n.Kind())) } diff --git a/traversal/fns.go b/traversal/fns.go index d359c673..f9096780 100644 --- a/traversal/fns.go +++ b/traversal/fns.go @@ -3,7 +3,8 @@ package traversal import ( "context" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" ) // This file defines interfaces for things users provide, @@ -11,13 +12,13 @@ import ( //-------------------------------------------------------- // VisitFn is a read-only visitor. -type VisitFn func(Progress, ipld.Node) error +type VisitFn func(Progress, datamodel.Node) error // TransformFn is like a visitor that can also return a new Node to replace the visited one. -type TransformFn func(Progress, ipld.Node) (ipld.Node, error) +type TransformFn func(Progress, datamodel.Node) (datamodel.Node, error) // AdvVisitFn is like VisitFn, but for use with AdvTraversal: it gets additional arguments describing *why* this node is visited. -type AdvVisitFn func(Progress, ipld.Node, VisitReason) error +type AdvVisitFn func(Progress, datamodel.Node, VisitReason) error // VisitReason provides additional information to traversals using AdvVisitFn. type VisitReason byte @@ -30,16 +31,16 @@ const ( type Progress struct { Cfg *Config - Path ipld.Path // Path is how we reached the current point in the traversal. - LastBlock struct { // LastBlock stores the Path and Link of the last block edge we had to load. (It will always be zero in traversals with no linkloader.) - Path ipld.Path - Link ipld.Link + Path datamodel.Path // Path is how we reached the current point in the traversal. + LastBlock struct { // LastBlock stores the Path and Link of the last block edge we had to load. (It will always be zero in traversals with no linkloader.) + Path datamodel.Path + Link datamodel.Link } } type Config struct { Ctx context.Context // Context carried through a traversal. Optional; use it if you need cancellation. - LinkSystem ipld.LinkSystem // LinkSystem used for automatic link loading, and also any storing if mutation features (e.g. traversal.Transform) are used. + LinkSystem linking.LinkSystem // LinkSystem used for automatic link loading, and also any storing if mutation features (e.g. traversal.Transform) are used. LinkTargetNodePrototypeChooser LinkTargetNodePrototypeChooser // Chooser for Node implementations to produce during automatic link traversal. } @@ -48,11 +49,11 @@ type Config struct { // // A LinkTargetNodePrototypeChooser can be used in a traversal.Config to be clear about // what kind of Node implementation to use when loading a Link. -// In a simple example, it could constantly return a `basicnode.Prototype__Any{}`. +// In a simple example, it could constantly return a `basicnode.Prototype.Any`. // In a more complex example, a program using `bind` over native Go types // could decide what kind of native type is expected, and return a // `bind.NodeBuilder` for that specific concrete native type. -type LinkTargetNodePrototypeChooser func(ipld.Link, ipld.LinkContext) (ipld.NodePrototype, error) +type LinkTargetNodePrototypeChooser func(datamodel.Link, linking.LinkContext) (datamodel.NodePrototype, error) // SkipMe is a signalling "error" which can be used to tell traverse to skip some data. // diff --git a/traversal/focus.go b/traversal/focus.go index cc54fa3e..a2048e83 100644 --- a/traversal/focus.go +++ b/traversal/focus.go @@ -3,7 +3,8 @@ package traversal import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" ) // Focus traverses a Node graph according to a path, reaches a single Node, @@ -13,7 +14,7 @@ import ( // It cannot cross links automatically (since this requires configuration). // Use the equivalent Focus function on the Progress structure // for more advanced and configurable walks. -func Focus(n ipld.Node, p ipld.Path, fn VisitFn) error { +func Focus(n datamodel.Node, p datamodel.Path, fn VisitFn) error { return Progress{}.Focus(n, p, fn) } @@ -24,11 +25,11 @@ func Focus(n ipld.Node, p ipld.Path, fn VisitFn) error { // It cannot cross links automatically (since this requires configuration). // Use the equivalent Get function on the Progress structure // for more advanced and configurable walks. -func Get(n ipld.Node, p ipld.Path) (ipld.Node, error) { +func Get(n datamodel.Node, p datamodel.Path) (datamodel.Node, error) { return Progress{}.Get(n, p) } -// FocusedTransform traverses an ipld.Node graph, reaches a single Node, +// FocusedTransform traverses an datamodel.Node graph, reaches a single Node, // and calls the given TransformFn to decide what new node to replace the visited node with. // A new Node tree will be returned (the original is unchanged). // @@ -36,7 +37,7 @@ func Get(n ipld.Node, p ipld.Path) (ipld.Node, error) { // It cannot cross links automatically (since this requires configuration). // Use the equivalent FocusedTransform function on the Progress structure // for more advanced and configurable walks. -func FocusedTransform(n ipld.Node, p ipld.Path, fn TransformFn, createParents bool) (ipld.Node, error) { +func FocusedTransform(n datamodel.Node, p datamodel.Path, fn TransformFn, createParents bool) (datamodel.Node, error) { return Progress{}.FocusedTransform(n, p, fn, createParents) } @@ -55,7 +56,7 @@ func FocusedTransform(n ipld.Node, p ipld.Path, fn TransformFn, createParents bo // By using the traversal.Progress handed to the VisitFn, // the Path recorded of the traversal so far will continue to be extended, // and thus continued nested uses of Walk and Focus will see the fully contextualized Path. -func (prog Progress) Focus(n ipld.Node, p ipld.Path, fn VisitFn) error { +func (prog Progress) Focus(n datamodel.Node, p datamodel.Path, fn VisitFn) error { n, err := prog.get(n, p, true) if err != nil { return err @@ -74,29 +75,29 @@ func (prog Progress) Focus(n ipld.Node, p ipld.Path, fn VisitFn) error { // If doing several traversals which are nested, consider using the Focus funcion in preference to Get; // the Focus functions provide updated Progress objects which can be used to do nested traversals while keeping consistent track of progress, // such that continued nested uses of Walk or Focus or Get will see the fully contextualized Path. -func (prog Progress) Get(n ipld.Node, p ipld.Path) (ipld.Node, error) { +func (prog Progress) Get(n datamodel.Node, p datamodel.Path) (datamodel.Node, error) { return prog.get(n, p, false) } // get is the internal implementation for Focus and Get. // It *mutates* the Progress object it's called on, and returns reached nodes. // For Get calls, trackProgress=false, which avoids some allocations for state tracking that's not needed by that call. -func (prog *Progress) get(n ipld.Node, p ipld.Path, trackProgress bool) (ipld.Node, error) { +func (prog *Progress) get(n datamodel.Node, p datamodel.Path, trackProgress bool) (datamodel.Node, error) { prog.init() segments := p.Segments() - var prev ipld.Node // for LinkContext + var prev datamodel.Node // for LinkContext for i, seg := range segments { // Traverse the segment. switch n.Kind() { - case ipld.Kind_Invalid: + case datamodel.Kind_Invalid: panic(fmt.Errorf("invalid node encountered at %q", p.Truncate(i))) - case ipld.Kind_Map: + case datamodel.Kind_Map: next, err := n.LookupByString(seg.String()) if err != nil { return nil, fmt.Errorf("error traversing segment %q on node at %q: %s", seg, p.Truncate(i), err) } prev, n = n, next - case ipld.Kind_List: + case datamodel.Kind_List: intSeg, err := seg.Index() if err != nil { return nil, fmt.Errorf("error traversing segment %q on node at %q: the segment cannot be parsed as a number and the node is a list", seg, p.Truncate(i)) @@ -110,9 +111,9 @@ func (prog *Progress) get(n ipld.Node, p ipld.Path, trackProgress bool) (ipld.No return nil, fmt.Errorf("cannot traverse node at %q: %s", p.Truncate(i), fmt.Errorf("cannot traverse terminals")) } // Dereference any links. - for n.Kind() == ipld.Kind_Link { + for n.Kind() == datamodel.Kind_Link { lnk, _ := n.AsLink() - lnkCtx := ipld.LinkContext{ + lnkCtx := linking.LinkContext{ Ctx: prog.Cfg.Ctx, LinkPath: p.Truncate(i), LinkNode: n, @@ -141,7 +142,7 @@ func (prog *Progress) get(n ipld.Node, p ipld.Path, trackProgress bool) (ipld.No return n, nil } -// FocusedTransform traverses an ipld.Node graph, reaches a single Node, +// FocusedTransform traverses an datamodel.Node graph, reaches a single Node, // and calls the given TransformFn to decide what new node to replace the visited node with. // A new Node tree will be returned (the original is unchanged). // @@ -178,7 +179,7 @@ func (prog *Progress) get(n ipld.Node, p ipld.Path, trackProgress bool) (ipld.No // does a large amount of the intermediate bookkeeping that's useful when // creating new values which are partial updates to existing values. // -func (prog Progress) FocusedTransform(n ipld.Node, p ipld.Path, fn TransformFn, createParents bool) (ipld.Node, error) { +func (prog Progress) FocusedTransform(n datamodel.Node, p datamodel.Path, fn TransformFn, createParents bool) (datamodel.Node, error) { prog.init() nb := n.Prototype().NewBuilder() if err := prog.focusedTransform(n, nb, p, fn, createParents); err != nil { @@ -191,7 +192,7 @@ func (prog Progress) FocusedTransform(n ipld.Node, p ipld.Path, fn TransformFn, // begins building an updated node tree. // // As implemented, this is not actually efficient if the update will be a no-op; it won't notice until it gets there. -func (prog Progress) focusedTransform(n ipld.Node, na ipld.NodeAssembler, p ipld.Path, fn TransformFn, createParents bool) error { +func (prog Progress) focusedTransform(n datamodel.Node, na datamodel.NodeAssembler, p datamodel.Path, fn TransformFn, createParents bool) error { if p.Len() == 0 { n2, err := fn(prog, n) if err != nil { @@ -224,7 +225,7 @@ func (prog Progress) focusedTransform(n ipld.Node, na ipld.NodeAssembler, p ipld // if we're at the end, it was already handled at the top of the function, // so we only get to this case if we were expecting to go deeper. switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: ma, err := na.BeginMap(n.Length()) if err != nil { return err @@ -269,7 +270,7 @@ func (prog Progress) focusedTransform(n ipld.Node, na ipld.NodeAssembler, p ipld return err } return ma.Finish() - case ipld.Kind_List: + case datamodel.Kind_List: la, err := na.BeginList(n.Length()) if err != nil { return err @@ -312,13 +313,13 @@ func (prog Progress) focusedTransform(n ipld.Node, na ipld.NodeAssembler, p ipld if ti >= 0 { return fmt.Errorf("transform: cannot navigate path segment %q at %q because it is beyond the list bounds", seg, prog.Path) } - prog.Path = prog.Path.AppendSegment(ipld.PathSegmentOfInt(n.Length())) + prog.Path = prog.Path.AppendSegment(datamodel.PathSegmentOfInt(n.Length())) if err := prog.focusedTransform(nil, la.AssembleValue(), p2, fn, createParents); err != nil { return err } return la.Finish() - case ipld.Kind_Link: - lnkCtx := ipld.LinkContext{ + case datamodel.Kind_Link: + lnkCtx := linking.LinkContext{ Ctx: prog.Cfg.Ctx, LinkPath: prog.Path, LinkNode: n, diff --git a/traversal/focus_test.go b/traversal/focus_test.go index e4cd5fbd..da42fb36 100644 --- a/traversal/focus_test.go +++ b/traversal/focus_test.go @@ -7,12 +7,13 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" _ "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" + "github.com/ipld/go-ipld-prime/linking" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/ipld/go-ipld-prime/must" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/storage" "github.com/ipld/go-ipld-prime/traversal" ) @@ -24,7 +25,7 @@ var store = storage.Memory{} var ( leafAlpha, leafAlphaLnk = encode(basicnode.NewString("alpha")) leafBeta, leafBetaLnk = encode(basicnode.NewString("beta")) - middleMapNode, middleMapNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype__Map{}, 3, func(na fluent.MapAssembler) { + middleMapNode, middleMapNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype.Map, 3, func(na fluent.MapAssembler) { na.AssembleEntry("foo").AssignBool(true) na.AssembleEntry("bar").AssignBool(false) na.AssembleEntry("nested").CreateMap(2, func(na fluent.MapAssembler) { @@ -32,13 +33,13 @@ var ( na.AssembleEntry("nonlink").AssignString("zoo") }) })) - middleListNode, middleListNodeLnk = encode(fluent.MustBuildList(basicnode.Prototype__List{}, 4, func(na fluent.ListAssembler) { + middleListNode, middleListNodeLnk = encode(fluent.MustBuildList(basicnode.Prototype.List, 4, func(na fluent.ListAssembler) { na.AssembleValue().AssignLink(leafAlphaLnk) na.AssembleValue().AssignLink(leafAlphaLnk) na.AssembleValue().AssignLink(leafBetaLnk) na.AssembleValue().AssignLink(leafAlphaLnk) })) - rootNode, rootNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { + rootNode, rootNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("linkedString").AssignLink(leafAlphaLnk) na.AssembleEntry("linkedMap").AssignLink(middleMapNodeLnk) @@ -49,7 +50,7 @@ var ( // encode hardcodes some encoding choices for ease of use in fixture generation; // just gimme a link and stuff the bytes in a map. // (also return the node again for convenient assignment.) -func encode(n ipld.Node) (ipld.Node, ipld.Link) { +func encode(n datamodel.Node) (datamodel.Node, datamodel.Link) { lp := cidlink.LinkPrototype{Prefix: cid.Prefix{ Version: 1, Codec: 0x0129, @@ -59,7 +60,7 @@ func encode(n ipld.Node) (ipld.Node, ipld.Link) { lsys := cidlink.DefaultLinkSystem() lsys.StorageWriteOpener = (&store).OpenWrite - lnk, err := lsys.Store(ipld.LinkContext{}, lp, n) + lnk, err := lsys.Store(linking.LinkContext{}, lp, n) if err != nil { panic(err) } @@ -69,25 +70,25 @@ func encode(n ipld.Node) (ipld.Node, ipld.Link) { // covers Focus used on one already-loaded Node; no link-loading exercised. func TestFocusSingleTree(t *testing.T) { t.Run("empty path on scalar node returns start node", func(t *testing.T) { - err := traversal.Focus(basicnode.NewString("x"), ipld.Path{}, func(prog traversal.Progress, n ipld.Node) error { + err := traversal.Focus(basicnode.NewString("x"), datamodel.Path{}, func(prog traversal.Progress, n datamodel.Node) error { Wish(t, n, ShouldEqual, basicnode.NewString("x")) - Wish(t, prog.Path.String(), ShouldEqual, ipld.Path{}.String()) + Wish(t, prog.Path.String(), ShouldEqual, datamodel.Path{}.String()) return nil }) Wish(t, err, ShouldEqual, nil) }) t.Run("one step path on map node works", func(t *testing.T) { - err := traversal.Focus(middleMapNode, ipld.ParsePath("foo"), func(prog traversal.Progress, n ipld.Node) error { + err := traversal.Focus(middleMapNode, datamodel.ParsePath("foo"), func(prog traversal.Progress, n datamodel.Node) error { Wish(t, n, ShouldEqual, basicnode.NewBool(true)) - Wish(t, prog.Path, ShouldEqual, ipld.ParsePath("foo")) + Wish(t, prog.Path, ShouldEqual, datamodel.ParsePath("foo")) return nil }) Wish(t, err, ShouldEqual, nil) }) t.Run("two step path on map node works", func(t *testing.T) { - err := traversal.Focus(middleMapNode, ipld.ParsePath("nested/nonlink"), func(prog traversal.Progress, n ipld.Node) error { + err := traversal.Focus(middleMapNode, datamodel.ParsePath("nested/nonlink"), func(prog traversal.Progress, n datamodel.Node) error { Wish(t, n, ShouldEqual, basicnode.NewString("zoo")) - Wish(t, prog.Path, ShouldEqual, ipld.ParsePath("nested/nonlink")) + Wish(t, prog.Path, ShouldEqual, datamodel.ParsePath("nested/nonlink")) return nil }) Wish(t, err, ShouldEqual, nil) @@ -98,17 +99,17 @@ func TestFocusSingleTree(t *testing.T) { // same fixtures as the test for Focus; just has fewer assertions, since Get does no progress tracking. func TestGetSingleTree(t *testing.T) { t.Run("empty path on scalar node returns start node", func(t *testing.T) { - n, err := traversal.Get(basicnode.NewString("x"), ipld.Path{}) + n, err := traversal.Get(basicnode.NewString("x"), datamodel.Path{}) Wish(t, err, ShouldEqual, nil) Wish(t, n, ShouldEqual, basicnode.NewString("x")) }) t.Run("one step path on map node works", func(t *testing.T) { - n, err := traversal.Get(middleMapNode, ipld.ParsePath("foo")) + n, err := traversal.Get(middleMapNode, datamodel.ParsePath("foo")) Wish(t, err, ShouldEqual, nil) Wish(t, n, ShouldEqual, basicnode.NewBool(true)) }) t.Run("two step path on map node works", func(t *testing.T) { - n, err := traversal.Get(middleMapNode, ipld.ParsePath("nested/nonlink")) + n, err := traversal.Get(middleMapNode, datamodel.ParsePath("nested/nonlink")) Wish(t, err, ShouldEqual, nil) Wish(t, n, ShouldEqual, basicnode.NewString("zoo")) }) @@ -117,14 +118,14 @@ func TestGetSingleTree(t *testing.T) { func TestFocusWithLinkLoading(t *testing.T) { t.Run("link traversal with no configured loader should fail", func(t *testing.T) { t.Run("terminal link should fail", func(t *testing.T) { - err := traversal.Focus(middleMapNode, ipld.ParsePath("nested/alink"), func(prog traversal.Progress, n ipld.Node) error { + err := traversal.Focus(middleMapNode, datamodel.ParsePath("nested/alink"), func(prog traversal.Progress, n datamodel.Node) error { t.Errorf("should not be reached; no way to load this path") return nil }) Wish(t, err.Error(), ShouldEqual, `error traversing node at "nested/alink": could not load link "`+leafAlphaLnk.String()+`": no LinkTargetNodePrototypeChooser configured`) }) t.Run("mid-path link should fail", func(t *testing.T) { - err := traversal.Focus(rootNode, ipld.ParsePath("linkedMap/nested/nonlink"), func(prog traversal.Progress, n ipld.Node) error { + err := traversal.Focus(rootNode, datamodel.ParsePath("linkedMap/nested/nonlink"), func(prog traversal.Progress, n datamodel.Node) error { t.Errorf("should not be reached; no way to load this path") return nil }) @@ -139,11 +140,11 @@ func TestFocusWithLinkLoading(t *testing.T) { LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.Focus(rootNode, ipld.ParsePath("linkedMap/nested/nonlink"), func(prog traversal.Progress, n ipld.Node) error { + }.Focus(rootNode, datamodel.ParsePath("linkedMap/nested/nonlink"), func(prog traversal.Progress, n datamodel.Node) error { Wish(t, n, ShouldEqual, basicnode.NewString("zoo")) - Wish(t, prog.Path, ShouldEqual, ipld.ParsePath("linkedMap/nested/nonlink")) + Wish(t, prog.Path, ShouldEqual, datamodel.ParsePath("linkedMap/nested/nonlink")) Wish(t, prog.LastBlock.Link, ShouldEqual, middleMapNodeLnk) - Wish(t, prog.LastBlock.Path, ShouldEqual, ipld.ParsePath("linkedMap")) + Wish(t, prog.LastBlock.Path, ShouldEqual, datamodel.ParsePath("linkedMap")) return nil }) Wish(t, err, ShouldEqual, nil) @@ -153,11 +154,11 @@ func TestFocusWithLinkLoading(t *testing.T) { func TestGetWithLinkLoading(t *testing.T) { t.Run("link traversal with no configured loader should fail", func(t *testing.T) { t.Run("terminal link should fail", func(t *testing.T) { - _, err := traversal.Get(middleMapNode, ipld.ParsePath("nested/alink")) + _, err := traversal.Get(middleMapNode, datamodel.ParsePath("nested/alink")) Wish(t, err.Error(), ShouldEqual, `error traversing node at "nested/alink": could not load link "`+leafAlphaLnk.String()+`": no LinkTargetNodePrototypeChooser configured`) }) t.Run("mid-path link should fail", func(t *testing.T) { - _, err := traversal.Get(rootNode, ipld.ParsePath("linkedMap/nested/nonlink")) + _, err := traversal.Get(rootNode, datamodel.ParsePath("linkedMap/nested/nonlink")) Wish(t, err.Error(), ShouldEqual, `error traversing node at "linkedMap": could not load link "`+middleMapNodeLnk.String()+`": no LinkTargetNodePrototypeChooser configured`) }) }) @@ -169,7 +170,7 @@ func TestGetWithLinkLoading(t *testing.T) { LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.Get(rootNode, ipld.ParsePath("linkedMap/nested/nonlink")) + }.Get(rootNode, datamodel.ParsePath("linkedMap/nested/nonlink")) Wish(t, err, ShouldEqual, nil) Wish(t, n, ShouldEqual, basicnode.NewString("zoo")) }) @@ -177,7 +178,7 @@ func TestGetWithLinkLoading(t *testing.T) { func TestFocusedTransform(t *testing.T) { t.Run("UpdateMapEntry", func(t *testing.T) { - n, err := traversal.FocusedTransform(rootNode, ipld.ParsePath("plain"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(rootNode, datamodel.ParsePath("plain"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "plain") Wish(t, must.String(prev), ShouldEqual, "olde string") nb := prev.Prototype().NewBuilder() @@ -185,7 +186,7 @@ func TestFocusedTransform(t *testing.T) { return nb.Build(), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) // updated value should be there Wish(t, must.Node(n.LookupByString("plain")), ShouldEqual, basicnode.NewString("new string!")) // everything else should be there @@ -196,13 +197,13 @@ func TestFocusedTransform(t *testing.T) { Wish(t, keys(n), ShouldEqual, []string{"plain", "linkedString", "linkedMap", "linkedList"}) }) t.Run("UpdateDeeperMap", func(t *testing.T) { - n, err := traversal.FocusedTransform(middleMapNode, ipld.ParsePath("nested/alink"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(middleMapNode, datamodel.ParsePath("nested/alink"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "nested/alink") Wish(t, prev, ShouldEqual, basicnode.NewLink(leafAlphaLnk)) return basicnode.NewString("new string!"), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) // updated value should be there Wish(t, must.Node(must.Node(n.LookupByString("nested")).LookupByString("alink")), ShouldEqual, basicnode.NewString("new string!")) // everything else in the parent map should should be there! @@ -212,31 +213,31 @@ func TestFocusedTransform(t *testing.T) { Wish(t, keys(n), ShouldEqual, []string{"foo", "bar", "nested"}) }) t.Run("AppendIfNotExists", func(t *testing.T) { - n, err := traversal.FocusedTransform(rootNode, ipld.ParsePath("newpart"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(rootNode, datamodel.ParsePath("newpart"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "newpart") - Wish(t, prev, ShouldEqual, nil) // REVIEW: should ipld.Absent be used here? I lean towards "no" but am unsure what's least surprising here. + Wish(t, prev, ShouldEqual, nil) // REVIEW: should datamodel.Absent be used here? I lean towards "no" but am unsure what's least surprising here. // An interesting thing to note about inserting a value this way is that you have no `prev.Prototype().NewBuilder()` to use if you wanted to. // But if that's an issue, then what you do is a focus or walk (transforming or not) to the parent node, get its child prototypes, and go from there. return basicnode.NewString("new string!"), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) // updated value should be there Wish(t, must.Node(n.LookupByString("newpart")), ShouldEqual, basicnode.NewString("new string!")) // everything should still be in the same order... with the new entry at the end. Wish(t, keys(n), ShouldEqual, []string{"plain", "linkedString", "linkedMap", "linkedList", "newpart"}) }) t.Run("CreateParents", func(t *testing.T) { - n, err := traversal.FocusedTransform(rootNode, ipld.ParsePath("newsection/newpart"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(rootNode, datamodel.ParsePath("newsection/newpart"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "newsection/newpart") - Wish(t, prev, ShouldEqual, nil) // REVIEW: should ipld.Absent be used here? I lean towards "no" but am unsure what's least surprising here. + Wish(t, prev, ShouldEqual, nil) // REVIEW: should datamodel.Absent be used here? I lean towards "no" but am unsure what's least surprising here. return basicnode.NewString("new string!"), nil }, true) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) // a new map node in the middle should've been created n2 := must.Node(n.LookupByString("newsection")) - Wish(t, n2.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n2.Kind(), ShouldEqual, datamodel.Kind_Map) // updated value should in there Wish(t, must.Node(n2.LookupByString("newpart")), ShouldEqual, basicnode.NewString("new string!")) // everything in the root map should still be in the same order... with the new entry at the end. @@ -245,20 +246,20 @@ func TestFocusedTransform(t *testing.T) { Wish(t, keys(n2), ShouldEqual, []string{"newpart"}) }) t.Run("CreateParentsRequiresPermission", func(t *testing.T) { - _, err := traversal.FocusedTransform(rootNode, ipld.ParsePath("newsection/newpart"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + _, err := traversal.FocusedTransform(rootNode, datamodel.ParsePath("newsection/newpart"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, true, ShouldEqual, false) // ought not be reached return nil, nil }, false) Wish(t, err, ShouldEqual, fmt.Errorf("transform: parent position at \"newsection\" did not exist (and createParents was false)")) }) t.Run("UpdateListEntry", func(t *testing.T) { - n, err := traversal.FocusedTransform(middleListNode, ipld.ParsePath("2"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(middleListNode, datamodel.ParsePath("2"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "2") Wish(t, prev, ShouldEqual, basicnode.NewLink(leafBetaLnk)) return basicnode.NewString("new string!"), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) // updated value should be there Wish(t, must.Node(n.LookupByIndex(2)), ShouldEqual, basicnode.NewString("new string!")) // everything else should be there @@ -268,27 +269,27 @@ func TestFocusedTransform(t *testing.T) { Wish(t, must.Node(n.LookupByIndex(3)), ShouldEqual, basicnode.NewLink(leafAlphaLnk)) }) t.Run("AppendToList", func(t *testing.T) { - n, err := traversal.FocusedTransform(middleListNode, ipld.ParsePath("-"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(middleListNode, datamodel.ParsePath("-"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "4") Wish(t, prev, ShouldEqual, nil) return basicnode.NewString("new string!"), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) // updated value should be there Wish(t, must.Node(n.LookupByIndex(4)), ShouldEqual, basicnode.NewString("new string!")) // everything else should be there Wish(t, n.Length(), ShouldEqual, int64(5)) }) t.Run("ListBounds", func(t *testing.T) { - _, err := traversal.FocusedTransform(middleListNode, ipld.ParsePath("4"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + _, err := traversal.FocusedTransform(middleListNode, datamodel.ParsePath("4"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, true, ShouldEqual, false) // ought not be reached return nil, nil }, false) Wish(t, err, ShouldEqual, fmt.Errorf("transform: cannot navigate path segment \"4\" at \"\" because it is beyond the list bounds")) }) t.Run("ReplaceRoot", func(t *testing.T) { // a fairly degenerate case and no reason to do this, but should work. - n, err := traversal.FocusedTransform(middleListNode, ipld.ParsePath(""), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + n, err := traversal.FocusedTransform(middleListNode, datamodel.ParsePath(""), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "") Wish(t, prev, ShouldEqual, middleListNode) nb := basicnode.Prototype.Any.NewBuilder() @@ -297,7 +298,7 @@ func TestFocusedTransform(t *testing.T) { return nb.Build(), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_List) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_List) Wish(t, n.Length(), ShouldEqual, int64(0)) }) } @@ -314,7 +315,7 @@ func TestFocusedTransformWithLinks(t *testing.T) { t.Run("UpdateMapBeyondLink", func(t *testing.T) { n, err := traversal.Progress{ Cfg: &cfg, - }.FocusedTransform(rootNode, ipld.ParsePath("linkedMap/nested/nonlink"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + }.FocusedTransform(rootNode, datamodel.ParsePath("linkedMap/nested/nonlink"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "linkedMap/nested/nonlink") Wish(t, must.String(prev), ShouldEqual, "zoo") Wish(t, progress.LastBlock.Path.String(), ShouldEqual, "linkedMap") @@ -324,7 +325,7 @@ func TestFocusedTransformWithLinks(t *testing.T) { return nb.Build(), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) // there should be a new object in our new storage! Wish(t, len(store2.Bag), ShouldEqual, 1) // cleanup for next test @@ -334,14 +335,14 @@ func TestFocusedTransformWithLinks(t *testing.T) { // This is replacing a link with a non-link. Doing so shouldn't hit storage. n, err := traversal.Progress{ Cfg: &cfg, - }.FocusedTransform(rootNode, ipld.ParsePath("linkedMap"), func(progress traversal.Progress, prev ipld.Node) (ipld.Node, error) { + }.FocusedTransform(rootNode, datamodel.ParsePath("linkedMap"), func(progress traversal.Progress, prev datamodel.Node) (datamodel.Node, error) { Wish(t, progress.Path.String(), ShouldEqual, "linkedMap") nb := prev.Prototype().NewBuilder() nb.AssignString("new string!") return nb.Build(), nil }, false) Wish(t, err, ShouldEqual, nil) - Wish(t, n.Kind(), ShouldEqual, ipld.Kind_Map) + Wish(t, n.Kind(), ShouldEqual, datamodel.Kind_Map) // there should be no new objects in our new storage! Wish(t, len(store2.Bag), ShouldEqual, 0) // cleanup for next test @@ -351,7 +352,7 @@ func TestFocusedTransformWithLinks(t *testing.T) { // link traverse to scalar // this is unspecifiable using the current path syntax! you'll just end up replacing the link with the scalar! } -func keys(n ipld.Node) []string { +func keys(n datamodel.Node) []string { v := make([]string, 0, n.Length()) for itr := n.MapIterator(); !itr.Done(); { k, _, _ := itr.Next() diff --git a/traversal/select_links.go b/traversal/select_links.go index 1e1dd932..9714fa83 100644 --- a/traversal/select_links.go +++ b/traversal/select_links.go @@ -1,7 +1,7 @@ package traversal import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // SelectLinks walks a Node tree and returns a slice of all Links encountered. @@ -22,15 +22,15 @@ import ( // If an identical link is found several times during the walk, // it is reported several times in the resulting list; // no deduplication is performed by this method. -func SelectLinks(n ipld.Node) ([]ipld.Link, error) { - var answer []ipld.Link +func SelectLinks(n datamodel.Node) ([]datamodel.Link, error) { + var answer []datamodel.Link err := accumulateLinks(&answer, n) return answer, err } -func accumulateLinks(a *[]ipld.Link, n ipld.Node) error { +func accumulateLinks(a *[]datamodel.Link, n datamodel.Node) error { switch n.Kind() { - case ipld.Kind_Map: + case datamodel.Kind_Map: for itr := n.MapIterator(); !itr.Done(); { _, v, err := itr.Next() if err != nil { @@ -38,7 +38,7 @@ func accumulateLinks(a *[]ipld.Link, n ipld.Node) error { } accumulateLinks(a, v) } - case ipld.Kind_List: + case datamodel.Kind_List: for itr := n.ListIterator(); !itr.Done(); { _, v, err := itr.Next() if err != nil { @@ -46,7 +46,7 @@ func accumulateLinks(a *[]ipld.Link, n ipld.Node) error { } accumulateLinks(a, v) } - case ipld.Kind_Link: + case datamodel.Kind_Link: lnk, _ := n.AsLink() *a = append(*a, lnk) } diff --git a/traversal/select_links_test.go b/traversal/select_links_test.go index d985a33a..37a44603 100644 --- a/traversal/select_links_test.go +++ b/traversal/select_links_test.go @@ -5,21 +5,21 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/traversal" ) func TestSelectLinks(t *testing.T) { t.Run("Scalar", func(t *testing.T) { lnks, _ := traversal.SelectLinks(leafAlpha) - Wish(t, lnks, ShouldEqual, []ipld.Link(nil)) + Wish(t, lnks, ShouldEqual, []datamodel.Link(nil)) }) t.Run("DeepMap", func(t *testing.T) { lnks, _ := traversal.SelectLinks(middleMapNode) - Wish(t, lnks, ShouldEqual, []ipld.Link{leafAlphaLnk}) + Wish(t, lnks, ShouldEqual, []datamodel.Link{leafAlphaLnk}) }) t.Run("List", func(t *testing.T) { lnks, _ := traversal.SelectLinks(rootNode) - Wish(t, lnks, ShouldEqual, []ipld.Link{leafAlphaLnk, middleMapNodeLnk, middleListNodeLnk}) + Wish(t, lnks, ShouldEqual, []datamodel.Link{leafAlphaLnk, middleMapNodeLnk, middleListNodeLnk}) }) } diff --git a/traversal/selector/builder/builder.go b/traversal/selector/builder/builder.go index 6ea95da3..bdff5d1e 100644 --- a/traversal/selector/builder/builder.go +++ b/traversal/selector/builder/builder.go @@ -1,15 +1,15 @@ package builder import ( - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - selector "github.com/ipld/go-ipld-prime/traversal/selector" + "github.com/ipld/go-ipld-prime/traversal/selector" ) // SelectorSpec is a specification for a selector that can build -// a selector ipld.Node or an actual parsed Selector +// a selector datamodel.Node or an actual parsed Selector type SelectorSpec interface { - Node() ipld.Node + Node() datamodel.Node Selector() (selector.Selector, error) } @@ -17,7 +17,7 @@ type SelectorSpec interface { // quickly. // // It serves two purposes: -// 1. Save the user of go-ipld-prime time and mental overhead with an easy +// 1. Save the user of go-ipld time and mental overhead with an easy // interface for making selector nodes in much less code without having to remember // the selector sigils // 2. Provide a level of protection from selector schema changes, at least in terms @@ -45,14 +45,14 @@ type ExploreFieldsSpecBuilder interface { } type selectorSpecBuilder struct { - np ipld.NodePrototype + np datamodel.NodePrototype } type selectorSpec struct { - n ipld.Node + n datamodel.Node } -func (ss selectorSpec) Node() ipld.Node { +func (ss selectorSpec) Node() datamodel.Node { return ss.n } @@ -61,8 +61,8 @@ func (ss selectorSpec) Selector() (selector.Selector, error) { } // NewSelectorSpecBuilder creates a SelectorSpecBuilder which will store -// data in the format determined by the given ipld.NodePrototype. -func NewSelectorSpecBuilder(np ipld.NodePrototype) SelectorSpecBuilder { +// data in the format determined by the given datamodel.NodePrototype. +func NewSelectorSpecBuilder(np datamodel.NodePrototype) SelectorSpecBuilder { return &selectorSpecBuilder{np} } diff --git a/traversal/selector/builder/builder_test.go b/traversal/selector/builder/builder_test.go index 011a074e..057242bf 100644 --- a/traversal/selector/builder/builder_test.go +++ b/traversal/selector/builder/builder_test.go @@ -4,13 +4,13 @@ import ( "testing" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/traversal/selector" . "github.com/warpfork/go-wish" ) func TestBuildingSelectors(t *testing.T) { - np := basicnode.Prototype__Any{} + np := basicnode.Prototype.Any ssb := NewSelectorSpecBuilder(np) t.Run("Matcher builds matcher nodes", func(t *testing.T) { sn := ssb.Matcher().Node() diff --git a/traversal/selector/condition.go b/traversal/selector/condition.go index 69d4a1cd..3d59cf49 100644 --- a/traversal/selector/condition.go +++ b/traversal/selector/condition.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) @@ -14,7 +14,7 @@ import ( // is sufficient for initial pressing use cases. type Condition struct { mode ConditionMode - match ipld.Node + match datamodel.Node } // A ConditionMode is the keyed representation for the union that is the condition @@ -24,11 +24,11 @@ const ( ConditionMode_Link ConditionMode = "/" ) -// Match decides if a given ipld.Node matches the condition. -func (c *Condition) Match(n ipld.Node) bool { +// Match decides if a given datamodel.Node matches the condition. +func (c *Condition) Match(n datamodel.Node) bool { switch c.mode { case ConditionMode_Link: - if n.Kind() != ipld.Kind_Link { + if n.Kind() != datamodel.Kind_Link { return false } lnk, err := n.AsLink() @@ -51,8 +51,8 @@ func (c *Condition) Match(n ipld.Node) bool { } // ParseCondition assembles a Condition from a condition selector node -func (pc ParseContext) ParseCondition(n ipld.Node) (Condition, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseCondition(n datamodel.Node) (Condition, error) { + if n.Kind() != datamodel.Kind_Map { return Condition{}, fmt.Errorf("selector spec parse rejected: condition body must be a map") } if n.Length() != 1 { diff --git a/traversal/selector/condition_test.go b/traversal/selector/condition_test.go index 34e9504d..8c375610 100644 --- a/traversal/selector/condition_test.go +++ b/traversal/selector/condition_test.go @@ -9,7 +9,7 @@ import ( "github.com/ipld/go-ipld-prime/fluent" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseCondition(t *testing.T) { @@ -19,13 +19,13 @@ func TestParseCondition(t *testing.T) { Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: condition body must be a map")) }) t.Run("parsing map node without field should error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 0, func(na fluent.MapAssembler) {}) + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 0, func(na fluent.MapAssembler) {}) _, err := ParseContext{}.ParseCondition(sn) Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: condition is a keyed union and thus must be single-entry map")) }) t.Run("parsing map node keyed to invalid type should error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(string(ConditionMode_Link)).AssignInt(0) }) _, err := ParseContext{}.ParseCondition(sn) @@ -33,7 +33,7 @@ func TestParseCondition(t *testing.T) { }) t.Run("parsing map node with condition field with valid selector node should parse", func(t *testing.T) { lnk := cidlink.Link{Cid: cid.Undef} - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(string(ConditionMode_Link)).AssignLink(lnk) }) s, err := ParseContext{}.ParseCondition(sn) diff --git a/traversal/selector/exploreAll.go b/traversal/selector/exploreAll.go index 056a7b57..a7749f8e 100644 --- a/traversal/selector/exploreAll.go +++ b/traversal/selector/exploreAll.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreAll is similar to a `*` -- it traverses all elements of an array, @@ -13,23 +13,23 @@ type ExploreAll struct { } // Interests for ExploreAll is nil (meaning traverse everything) -func (s ExploreAll) Interests() []ipld.PathSegment { +func (s ExploreAll) Interests() []datamodel.PathSegment { return nil } // Explore returns the node's selector for all fields -func (s ExploreAll) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { +func (s ExploreAll) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { return s.next, nil } // Decide always returns false because this is not a matcher -func (s ExploreAll) Decide(n ipld.Node) bool { +func (s ExploreAll) Decide(n datamodel.Node) bool { return false } // ParseExploreAll assembles a Selector from a ExploreAll selector node -func (pc ParseContext) ParseExploreAll(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseExploreAll(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } next, err := n.LookupByString(SelectorKey_Next) diff --git a/traversal/selector/exploreAll_test.go b/traversal/selector/exploreAll_test.go index 89dd03c7..75eb7aca 100644 --- a/traversal/selector/exploreAll_test.go +++ b/traversal/selector/exploreAll_test.go @@ -7,7 +7,7 @@ import ( . "github.com/warpfork/go-wish" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseExploreAll(t *testing.T) { @@ -17,20 +17,20 @@ func TestParseExploreAll(t *testing.T) { Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: selector body must be a map")) }) t.Run("parsing map node without next field should error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 0, func(na fluent.MapAssembler) {}) + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 0, func(na fluent.MapAssembler) {}) _, err := ParseContext{}.ParseExploreAll(sn) Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: next field must be present in ExploreAll selector")) }) t.Run("parsing map node without next field with invalid selector node should return child's error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Next).AssignInt(0) }) _, err := ParseContext{}.ParseExploreAll(sn) Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: selector is a keyed union and thus must be a map")) }) t.Run("parsing map node with next field with valid selector node should parse", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Next).CreateMap(1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Matcher).CreateMap(0, func(na fluent.MapAssembler) {}) }) diff --git a/traversal/selector/exploreFields.go b/traversal/selector/exploreFields.go index b3884847..96972814 100644 --- a/traversal/selector/exploreFields.go +++ b/traversal/selector/exploreFields.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreFields traverses named fields in a map (or equivalently, struct, if @@ -19,41 +19,41 @@ import ( // ExploreIndex or ExploreRange is more appropriate, however, and should be preferred. type ExploreFields struct { selections map[string]Selector - interests []ipld.PathSegment // keys of above; already boxed as that's the only way we consume them + interests []datamodel.PathSegment // keys of above; already boxed as that's the only way we consume them } // Interests for ExploreFields are the fields listed in the selector node -func (s ExploreFields) Interests() []ipld.PathSegment { +func (s ExploreFields) Interests() []datamodel.PathSegment { return s.interests } // Explore returns the selector for the given path if it is a field in // the selector node or nil if not -func (s ExploreFields) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { +func (s ExploreFields) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { return s.selections[p.String()], nil } // Decide always returns false because this is not a matcher -func (s ExploreFields) Decide(n ipld.Node) bool { +func (s ExploreFields) Decide(n datamodel.Node) bool { return false } // ParseExploreFields assembles a Selector // from a ExploreFields selector node -func (pc ParseContext) ParseExploreFields(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseExploreFields(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } fields, err := n.LookupByString(SelectorKey_Fields) if err != nil { return nil, fmt.Errorf("selector spec parse rejected: fields in ExploreFields selector must be present") } - if fields.Kind() != ipld.Kind_Map { + if fields.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: fields in ExploreFields selector must be a map") } x := ExploreFields{ make(map[string]Selector, fields.Length()), - make([]ipld.PathSegment, 0, fields.Length()), + make([]datamodel.PathSegment, 0, fields.Length()), } for itr := fields.MapIterator(); !itr.Done(); { kn, v, err := itr.Next() @@ -62,7 +62,7 @@ func (pc ParseContext) ParseExploreFields(n ipld.Node) (Selector, error) { } kstr, _ := kn.AsString() - x.interests = append(x.interests, ipld.PathSegmentOfString(kstr)) + x.interests = append(x.interests, datamodel.PathSegmentOfString(kstr)) x.selections[kstr], err = pc.ParseSelector(v) if err != nil { return nil, err diff --git a/traversal/selector/exploreFields_test.go b/traversal/selector/exploreFields_test.go index 5a24cfb5..fd1cae1c 100644 --- a/traversal/selector/exploreFields_test.go +++ b/traversal/selector/exploreFields_test.go @@ -6,9 +6,9 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseExploreFields(t *testing.T) { @@ -18,19 +18,19 @@ func TestParseExploreFields(t *testing.T) { Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: selector body must be a map")) }) t.Run("parsing map node without fields value should error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 0, func(na fluent.MapAssembler) {}) + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 0, func(na fluent.MapAssembler) {}) _, err := ParseContext{}.ParseExploreFields(sn) Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: fields in ExploreFields selector must be present")) }) t.Run("parsing map node with fields value that is not a map should error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Fields).AssignString("cheese") }) _, err := ParseContext{}.ParseExploreFields(sn) Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: fields in ExploreFields selector must be a map")) }) t.Run("parsing map node with selector node in fields that is invalid should return child's error", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Fields).CreateMap(1, func(na fluent.MapAssembler) { na.AssembleEntry("applesauce").AssignInt(0) }) @@ -39,7 +39,7 @@ func TestParseExploreFields(t *testing.T) { Wish(t, err, ShouldEqual, fmt.Errorf("selector spec parse rejected: selector is a keyed union and thus must be a map")) }) t.Run("parsing map node with fields value that is map of only valid selector node should parse", func(t *testing.T) { - sn := fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(na fluent.MapAssembler) { + sn := fluent.MustBuildMap(basicnode.Prototype.Map, 1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Fields).CreateMap(1, func(na fluent.MapAssembler) { na.AssembleEntry("applesauce").CreateMap(1, func(na fluent.MapAssembler) { na.AssembleEntry(SelectorKey_Matcher).CreateMap(0, func(na fluent.MapAssembler) {}) @@ -48,6 +48,6 @@ func TestParseExploreFields(t *testing.T) { }) s, err := ParseContext{}.ParseExploreFields(sn) Wish(t, err, ShouldEqual, nil) - Wish(t, s, ShouldEqual, ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []ipld.PathSegment{ipld.PathSegmentOfString("applesauce")}}) + Wish(t, s, ShouldEqual, ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []datamodel.PathSegment{datamodel.PathSegmentOfString("applesauce")}}) }) } diff --git a/traversal/selector/exploreIndex.go b/traversal/selector/exploreIndex.go index fc4db961..0c8edf16 100644 --- a/traversal/selector/exploreIndex.go +++ b/traversal/selector/exploreIndex.go @@ -3,25 +3,25 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreIndex traverses a specific index in a list, and applies a next // selector to the reached node. type ExploreIndex struct { - next Selector // selector for element we're interested in - interest [1]ipld.PathSegment // index of element we're interested in + next Selector // selector for element we're interested in + interest [1]datamodel.PathSegment // index of element we're interested in } // Interests for ExploreIndex is just the index specified by the selector node -func (s ExploreIndex) Interests() []ipld.PathSegment { +func (s ExploreIndex) Interests() []datamodel.PathSegment { return s.interest[:] } // Explore returns the node's selector if // the path matches the index for this selector or nil if not -func (s ExploreIndex) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { - if n.Kind() != ipld.Kind_List { +func (s ExploreIndex) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { + if n.Kind() != datamodel.Kind_List { return nil, nil } expectedIndex, expectedErr := p.Index() @@ -33,14 +33,14 @@ func (s ExploreIndex) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) } // Decide always returns false because this is not a matcher -func (s ExploreIndex) Decide(n ipld.Node) bool { +func (s ExploreIndex) Decide(n datamodel.Node) bool { return false } // ParseExploreIndex assembles a Selector // from a ExploreIndex selector node -func (pc ParseContext) ParseExploreIndex(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseExploreIndex(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } indexNode, err := n.LookupByString(SelectorKey_Index) @@ -59,5 +59,5 @@ func (pc ParseContext) ParseExploreIndex(n ipld.Node) (Selector, error) { if err != nil { return nil, err } - return ExploreIndex{selector, [1]ipld.PathSegment{ipld.PathSegmentOfInt(indexValue)}}, nil + return ExploreIndex{selector, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(indexValue)}}, nil } diff --git a/traversal/selector/exploreIndex_test.go b/traversal/selector/exploreIndex_test.go index 01ceb19b..ceff45f4 100644 --- a/traversal/selector/exploreIndex_test.go +++ b/traversal/selector/exploreIndex_test.go @@ -6,9 +6,9 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseExploreIndex(t *testing.T) { @@ -60,15 +60,15 @@ func TestParseExploreIndex(t *testing.T) { }) s, err := ParseContext{}.ParseExploreIndex(sn) Wish(t, err, ShouldEqual, nil) - Wish(t, s, ShouldEqual, ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}) + Wish(t, s, ShouldEqual, ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}) }) } func TestExploreIndexExplore(t *testing.T) { - s := ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(3)}} + s := ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(3)}} t.Run("exploring should return nil unless node is a list", func(t *testing.T) { n := fluent.MustBuildMap(basicnode.Prototype__Map{}, 0, func(na fluent.MapAssembler) {}) - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(3)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(3)) Wish(t, returnedSelector, ShouldEqual, nil) }) n := fluent.MustBuildList(basicnode.Prototype__List{}, 4, func(na fluent.ListAssembler) { @@ -78,15 +78,15 @@ func TestExploreIndexExplore(t *testing.T) { na.AssembleValue().AssignInt(3) }) t.Run("exploring should return nil when given a path segment with a different index", func(t *testing.T) { - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(2)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(2)) Wish(t, returnedSelector, ShouldEqual, nil) }) t.Run("exploring should return nil when given a path segment that isn't an index", func(t *testing.T) { - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfString("cheese")) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfString("cheese")) Wish(t, returnedSelector, ShouldEqual, nil) }) t.Run("exploring should return the next selector when given a path segment with the right index", func(t *testing.T) { - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(3)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(3)) Wish(t, returnedSelector, ShouldEqual, Matcher{}) }) } diff --git a/traversal/selector/exploreRange.go b/traversal/selector/exploreRange.go index 66bd56fb..73e356ba 100644 --- a/traversal/selector/exploreRange.go +++ b/traversal/selector/exploreRange.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreRange traverses a list, and for each element in the range specified, @@ -12,18 +12,18 @@ type ExploreRange struct { next Selector // selector for element we're interested in start int64 end int64 - interest []ipld.PathSegment // index of element we're interested in + interest []datamodel.PathSegment // index of element we're interested in } // Interests for ExploreRange are all path segments within the iteration range -func (s ExploreRange) Interests() []ipld.PathSegment { +func (s ExploreRange) Interests() []datamodel.PathSegment { return s.interest } // Explore returns the node's selector if // the path matches an index in the range of this selector -func (s ExploreRange) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { - if n.Kind() != ipld.Kind_List { +func (s ExploreRange) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { + if n.Kind() != datamodel.Kind_List { return nil, nil } index, err := p.Index() @@ -37,14 +37,14 @@ func (s ExploreRange) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) } // Decide always returns false because this is not a matcher -func (s ExploreRange) Decide(n ipld.Node) bool { +func (s ExploreRange) Decide(n datamodel.Node) bool { return false } // ParseExploreRange assembles a Selector // from a ExploreRange selector node -func (pc ParseContext) ParseExploreRange(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseExploreRange(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } startNode, err := n.LookupByString(SelectorKey_Start) @@ -78,10 +78,10 @@ func (pc ParseContext) ParseExploreRange(n ipld.Node) (Selector, error) { selector, startValue, endValue, - make([]ipld.PathSegment, 0, endValue-startValue), + make([]datamodel.PathSegment, 0, endValue-startValue), } for i := startValue; i < endValue; i++ { - x.interest = append(x.interest, ipld.PathSegmentOfInt(i)) + x.interest = append(x.interest, datamodel.PathSegmentOfInt(i)) } return x, nil } diff --git a/traversal/selector/exploreRange_test.go b/traversal/selector/exploreRange_test.go index 17a3cdfa..470acbd1 100644 --- a/traversal/selector/exploreRange_test.go +++ b/traversal/selector/exploreRange_test.go @@ -6,9 +6,9 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseExploreRange(t *testing.T) { @@ -98,15 +98,15 @@ func TestParseExploreRange(t *testing.T) { }) s, err := ParseContext{}.ParseExploreRange(sn) Wish(t, err, ShouldEqual, nil) - Wish(t, s, ShouldEqual, ExploreRange{Matcher{}, 2, 3, []ipld.PathSegment{ipld.PathSegmentOfInt(2)}}) + Wish(t, s, ShouldEqual, ExploreRange{Matcher{}, 2, 3, []datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}) }) } func TestExploreRangeExplore(t *testing.T) { - s := ExploreRange{Matcher{}, 3, 4, []ipld.PathSegment{ipld.PathSegmentOfInt(3)}} + s := ExploreRange{Matcher{}, 3, 4, []datamodel.PathSegment{datamodel.PathSegmentOfInt(3)}} t.Run("exploring should return nil unless node is a list", func(t *testing.T) { n := fluent.MustBuildMap(basicnode.Prototype__Map{}, 0, func(na fluent.MapAssembler) {}) - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(3)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(3)) Wish(t, returnedSelector, ShouldEqual, nil) }) n := fluent.MustBuildList(basicnode.Prototype__List{}, 4, func(na fluent.ListAssembler) { @@ -116,15 +116,15 @@ func TestExploreRangeExplore(t *testing.T) { na.AssembleValue().AssignInt(3) }) t.Run("exploring should return nil when given a path segment out of range", func(t *testing.T) { - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(2)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(2)) Wish(t, returnedSelector, ShouldEqual, nil) }) t.Run("exploring should return nil when given a path segment that isn't an index", func(t *testing.T) { - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfString("cheese")) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfString("cheese")) Wish(t, returnedSelector, ShouldEqual, nil) }) t.Run("exploring should return the next selector when given a path segment with index in range", func(t *testing.T) { - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(3)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(3)) Wish(t, returnedSelector, ShouldEqual, Matcher{}) }) } diff --git a/traversal/selector/exploreRecursive.go b/traversal/selector/exploreRecursive.go index 6d69aeed..287eda8e 100644 --- a/traversal/selector/exploreRecursive.go +++ b/traversal/selector/exploreRecursive.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreRecursive traverses some structure recursively. @@ -81,12 +81,12 @@ func RecursionLimitNone() RecursionLimit { } // Interests for ExploreRecursive is empty (meaning traverse everything) -func (s ExploreRecursive) Interests() []ipld.PathSegment { +func (s ExploreRecursive) Interests() []datamodel.PathSegment { return s.current.Interests() } // Explore returns the node's selector for all fields -func (s ExploreRecursive) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { +func (s ExploreRecursive) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { if s.stopAt != nil { target, err := n.LookupBySegment(p) if err != nil { @@ -161,7 +161,7 @@ func (s ExploreRecursive) replaceRecursiveEdge(nextSelector Selector, replacemen } // Decide if a node directly matches -func (s ExploreRecursive) Decide(n ipld.Node) bool { +func (s ExploreRecursive) Decide(n datamodel.Node) bool { return s.current.Decide(n) } @@ -178,8 +178,8 @@ func (erc *exploreRecursiveContext) Link(s Selector) bool { } // ParseExploreRecursive assembles a Selector from a ExploreRecursive selector node -func (pc ParseContext) ParseExploreRecursive(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseExploreRecursive(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } @@ -215,8 +215,8 @@ func (pc ParseContext) ParseExploreRecursive(n ipld.Node) (Selector, error) { return ExploreRecursive{selector, selector, limit, stopCondition}, nil } -func parseLimit(n ipld.Node) (RecursionLimit, error) { - if n.Kind() != ipld.Kind_Map { +func parseLimit(n datamodel.Node) (RecursionLimit, error) { + if n.Kind() != datamodel.Kind_Map { return RecursionLimit{}, fmt.Errorf("selector spec parse rejected: limit in ExploreRecursive is a keyed union and thus must be a map") } if n.Length() != 1 { diff --git a/traversal/selector/exploreRecursiveEdge.go b/traversal/selector/exploreRecursiveEdge.go index dacaeab9..75c74433 100644 --- a/traversal/selector/exploreRecursiveEdge.go +++ b/traversal/selector/exploreRecursiveEdge.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreRecursiveEdge is a special sentinel value which is used to mark @@ -17,24 +17,24 @@ import ( type ExploreRecursiveEdge struct{} // Interests should ultimately never get called for an ExploreRecursiveEdge selector -func (s ExploreRecursiveEdge) Interests() []ipld.PathSegment { +func (s ExploreRecursiveEdge) Interests() []datamodel.PathSegment { panic("Traversed Explore Recursive Edge Node With No Parent") } // Explore should ultimately never get called for an ExploreRecursiveEdge selector -func (s ExploreRecursiveEdge) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { +func (s ExploreRecursiveEdge) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { panic("Traversed Explore Recursive Edge Node With No Parent") } // Decide should ultimately never get called for an ExploreRecursiveEdge selector -func (s ExploreRecursiveEdge) Decide(n ipld.Node) bool { +func (s ExploreRecursiveEdge) Decide(n datamodel.Node) bool { panic("Traversed Explore Recursive Edge Node With No Parent") } // ParseExploreRecursiveEdge assembles a Selector // from a exploreRecursiveEdge selector node -func (pc ParseContext) ParseExploreRecursiveEdge(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseExploreRecursiveEdge(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } s := ExploreRecursiveEdge{} diff --git a/traversal/selector/exploreRecursive_test.go b/traversal/selector/exploreRecursive_test.go index 9dd6fe4d..3a275df9 100644 --- a/traversal/selector/exploreRecursive_test.go +++ b/traversal/selector/exploreRecursive_test.go @@ -7,10 +7,10 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseExploreRecursive(t *testing.T) { @@ -180,7 +180,7 @@ func TestExploreRecursiveExplore(t *testing.T) { var rs Selector t.Run("exploring should traverse until we get to maxDepth", func(t *testing.T) { parentsSelector := ExploreAll{recursiveEdge} - subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []ipld.PathSegment{ipld.PathSegmentOfString("Parents")}} + subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []datamodel.PathSegment{datamodel.PathSegmentOfString("Parents")}} rs = ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil} nodeString := `{ "Parents": [ @@ -202,28 +202,28 @@ func TestExploreRecursiveExplore(t *testing.T) { err := dagjson.Decode(nb, strings.NewReader(nodeString)) Wish(t, err, ShouldEqual, nil) rn := nb.Build() - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth - 2}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 2}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, nil) Wish(t, err, ShouldEqual, nil) @@ -231,7 +231,7 @@ func TestExploreRecursiveExplore(t *testing.T) { t.Run("exploring should traverse indefinitely if no depth specified", func(t *testing.T) { parentsSelector := ExploreAll{recursiveEdge} - subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []ipld.PathSegment{ipld.PathSegmentOfString("Parents")}} + subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []datamodel.PathSegment{datamodel.PathSegmentOfString("Parents")}} rs = ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_None, 0}, nil} nodeString := `{ "Parents": [ @@ -253,39 +253,39 @@ func TestExploreRecursiveExplore(t *testing.T) { err := dagjson.Decode(nb, strings.NewReader(nodeString)) Wish(t, err, ShouldEqual, nil) rn := nb.Build() - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_None, 0}, nil}) Wish(t, err, ShouldEqual, nil) }) t.Run("exploring should continue till we get to selector that returns nil on explore", func(t *testing.T) { - parentsSelector := ExploreIndex{recursiveEdge, [1]ipld.PathSegment{ipld.PathSegmentOfInt(1)}} - subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []ipld.PathSegment{ipld.PathSegmentOfString("Parents")}} + parentsSelector := ExploreIndex{recursiveEdge, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(1)}} + subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []datamodel.PathSegment{datamodel.PathSegmentOfString("Parents")}} rs = ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil} nodeString := `{ "Parents": { @@ -296,11 +296,11 @@ func TestExploreRecursiveExplore(t *testing.T) { err := dagjson.Decode(nb, strings.NewReader(nodeString)) Wish(t, err, ShouldEqual, nil) rn := nb.Build() - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) Wish(t, rs, ShouldEqual, nil) }) t.Run("exploring should work when there is nested recursion", func(t *testing.T) { @@ -309,9 +309,9 @@ func TestExploreRecursiveExplore(t *testing.T) { subTree := ExploreFields{map[string]Selector{ "Parents": parentsSelector, "Side": ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}, - }, []ipld.PathSegment{ - ipld.PathSegmentOfString("Parents"), - ipld.PathSegmentOfString("Side"), + }, []datamodel.PathSegment{ + datamodel.PathSegmentOfString("Parents"), + datamodel.PathSegmentOfString("Side"), }, } s := ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil} @@ -345,15 +345,15 @@ func TestExploreRecursiveExplore(t *testing.T) { // traverse down Parent nodes rn := n rs = s - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) @@ -361,19 +361,19 @@ func TestExploreRecursiveExplore(t *testing.T) { // traverse down top level Side tree (nested recursion) rn = n rs = s - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Side")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Side")) rn, err = rn.LookupByString("Side") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("real")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("real")) rn, err = rn.LookupByString("real") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("apple")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("apple")) rn, err = rn.LookupByString("apple") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 2}, nil}, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("sauce")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("sauce")) rn, err = rn.LookupByString("sauce") Wish(t, rs, ShouldEqual, nil) Wish(t, err, ShouldEqual, nil) @@ -381,30 +381,30 @@ func TestExploreRecursiveExplore(t *testing.T) { // traverse once down Parent (top level recursion) then down Side tree (nested recursion) rn = n rs = s - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Side")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Side")) rn, err = rn.LookupByString("Side") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("cheese")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("cheese")) rn, err = rn.LookupByString("cheese") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("whiz")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("whiz")) rn, err = rn.LookupByString("whiz") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreRecursive{sideSelector, sideSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 2}, nil}, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) }) t.Run("exploring should work with explore union and recursion", func(t *testing.T) { - parentsSelector := ExploreUnion{[]Selector{ExploreAll{Matcher{}}, ExploreIndex{recursiveEdge, [1]ipld.PathSegment{ipld.PathSegmentOfInt(0)}}}} - subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []ipld.PathSegment{ipld.PathSegmentOfString("Parents")}} + parentsSelector := ExploreUnion{[]Selector{ExploreAll{Matcher{}}, ExploreIndex{recursiveEdge, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(0)}}}} + subTree := ExploreFields{map[string]Selector{"Parents": parentsSelector}, []datamodel.PathSegment{datamodel.PathSegmentOfString("Parents")}} rs = ExploreRecursive{subTree, subTree, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil} nodeString := `{ "Parents": [ @@ -426,20 +426,20 @@ func TestExploreRecursiveExplore(t *testing.T) { err := dagjson.Decode(nb, strings.NewReader(nodeString)) Wish(t, err, ShouldEqual, nil) rn := nb.Build() - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreUnion{[]Selector{Matcher{}, subTree}}, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfString("Parents")) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfString("Parents")) rn, err = rn.LookupByString("Parents") Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, parentsSelector, RecursionLimit{RecursionLimit_Depth, maxDepth - 1}, nil}) Wish(t, err, ShouldEqual, nil) - rs, _ = rs.Explore(rn, ipld.PathSegmentOfInt(0)) + rs, _ = rs.Explore(rn, datamodel.PathSegmentOfInt(0)) rn, err = rn.LookupByIndex(0) Wish(t, rs, ShouldEqual, ExploreRecursive{subTree, ExploreUnion{[]Selector{Matcher{}, subTree}}, RecursionLimit{RecursionLimit_Depth, maxDepth - 2}, nil}) Wish(t, err, ShouldEqual, nil) diff --git a/traversal/selector/exploreUnion.go b/traversal/selector/exploreUnion.go index 67a90f60..95607873 100644 --- a/traversal/selector/exploreUnion.go +++ b/traversal/selector/exploreUnion.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // ExploreUnion allows selection to continue with two or more distinct selectors @@ -20,7 +20,7 @@ type ExploreUnion struct { // Interests for ExploreUnion is: // - nil (aka all) if any member selector has nil interests // - the union of values returned by all member selectors otherwise -func (s ExploreUnion) Interests() []ipld.PathSegment { +func (s ExploreUnion) Interests() []datamodel.PathSegment { // Check for any high-cardinality selectors first; if so, shortcircuit. // (n.b. we're assuming the 'Interests' method is cheap here.) for _, m := range s.Members { @@ -30,7 +30,7 @@ func (s ExploreUnion) Interests() []ipld.PathSegment { } // Accumulate the whitelist of interesting path segments. // TODO: Dedup? - v := []ipld.PathSegment{} + v := []datamodel.PathSegment{} for _, m := range s.Members { v = append(v, m.Interests()...) } @@ -42,7 +42,7 @@ func (s ExploreUnion) Interests() []ipld.PathSegment { // - a new union selector if more than one member returns a selector // - if exactly one member returns a selector, that selector // - nil if no members return a selector -func (s ExploreUnion) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { +func (s ExploreUnion) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { // TODO: memory efficient? nonNilResults := make([]Selector, 0, len(s.Members)) for _, member := range s.Members { @@ -65,7 +65,7 @@ func (s ExploreUnion) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) // Decide returns true for a Union selector if any of the member selectors // return true -func (s ExploreUnion) Decide(n ipld.Node) bool { +func (s ExploreUnion) Decide(n datamodel.Node) bool { for _, m := range s.Members { if m.Decide(n) { return true @@ -76,8 +76,8 @@ func (s ExploreUnion) Decide(n ipld.Node) bool { // ParseExploreUnion assembles a Selector // from an ExploreUnion selector node -func (pc ParseContext) ParseExploreUnion(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_List { +func (pc ParseContext) ParseExploreUnion(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_List { return nil, fmt.Errorf("selector spec parse rejected: explore union selector must be a list") } x := ExploreUnion{ diff --git a/traversal/selector/exploreUnion_test.go b/traversal/selector/exploreUnion_test.go index 84d7b1df..7a3a95be 100644 --- a/traversal/selector/exploreUnion_test.go +++ b/traversal/selector/exploreUnion_test.go @@ -6,9 +6,9 @@ import ( . "github.com/warpfork/go-wish" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" ) func TestParseExploreUnion(t *testing.T) { @@ -44,7 +44,7 @@ func TestParseExploreUnion(t *testing.T) { }) s, err := ParseContext{}.ParseExploreUnion(sn) Wish(t, err, ShouldEqual, nil) - Wish(t, s, ShouldEqual, ExploreUnion{[]Selector{Matcher{}, ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}}}) + Wish(t, s, ShouldEqual, ExploreUnion{[]Selector{Matcher{}, ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}}}) }) } @@ -56,26 +56,26 @@ func TestExploreUnionExplore(t *testing.T) { na.AssembleValue().AssignInt(3) }) t.Run("exploring should return nil if all member selectors return nil when explored", func(t *testing.T) { - s := ExploreUnion{[]Selector{Matcher{}, ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}}} - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(3)) + s := ExploreUnion{[]Selector{Matcher{}, ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}}} + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(3)) Wish(t, returnedSelector, ShouldEqual, nil) }) t.Run("if exactly one member selector returns a non-nil selector when explored, exploring should return that value", func(t *testing.T) { - s := ExploreUnion{[]Selector{Matcher{}, ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}}} + s := ExploreUnion{[]Selector{Matcher{}, ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}}} - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(2)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(2)) Wish(t, returnedSelector, ShouldEqual, Matcher{}) }) t.Run("exploring should return a new union selector if more than one member selector returns a non nil selector when explored", func(t *testing.T) { s := ExploreUnion{[]Selector{ Matcher{}, - ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}, - ExploreRange{Matcher{}, 2, 3, []ipld.PathSegment{ipld.PathSegmentOfInt(2)}}, - ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []ipld.PathSegment{ipld.PathSegmentOfString("applesauce")}}, + ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}, + ExploreRange{Matcher{}, 2, 3, []datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}, + ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []datamodel.PathSegment{datamodel.PathSegmentOfString("applesauce")}}, }} - returnedSelector, _ := s.Explore(n, ipld.PathSegmentOfInt(2)) + returnedSelector, _ := s.Explore(n, datamodel.PathSegmentOfInt(2)) Wish(t, returnedSelector, ShouldEqual, ExploreUnion{[]Selector{Matcher{}, Matcher{}}}) }) } @@ -85,17 +85,17 @@ func TestExploreUnionInterests(t *testing.T) { s := ExploreUnion{[]Selector{ ExploreAll{Matcher{}}, Matcher{}, - ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}, + ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}, }} - Wish(t, s.Interests(), ShouldEqual, []ipld.PathSegment(nil)) + Wish(t, s.Interests(), ShouldEqual, []datamodel.PathSegment(nil)) }) t.Run("if no member selector is high-cardinality, interests should be combination of member selectors interests", func(t *testing.T) { s := ExploreUnion{[]Selector{ - ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []ipld.PathSegment{ipld.PathSegmentOfString("applesauce")}}, + ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []datamodel.PathSegment{datamodel.PathSegmentOfString("applesauce")}}, Matcher{}, - ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}, + ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}, }} - Wish(t, s.Interests(), ShouldEqual, []ipld.PathSegment{ipld.PathSegmentOfString("applesauce"), ipld.PathSegmentOfInt(2)}) + Wish(t, s.Interests(), ShouldEqual, []datamodel.PathSegment{datamodel.PathSegmentOfString("applesauce"), datamodel.PathSegmentOfInt(2)}) }) } @@ -105,15 +105,15 @@ func TestExploreUnionDecide(t *testing.T) { s := ExploreUnion{[]Selector{ ExploreAll{Matcher{}}, Matcher{}, - ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}, + ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}, }} Wish(t, s.Decide(n), ShouldEqual, true) }) t.Run("if no member selector returns true, decide should be false", func(t *testing.T) { s := ExploreUnion{[]Selector{ - ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []ipld.PathSegment{ipld.PathSegmentOfString("applesauce")}}, + ExploreFields{map[string]Selector{"applesauce": Matcher{}}, []datamodel.PathSegment{datamodel.PathSegmentOfString("applesauce")}}, ExploreAll{Matcher{}}, - ExploreIndex{Matcher{}, [1]ipld.PathSegment{ipld.PathSegmentOfInt(2)}}, + ExploreIndex{Matcher{}, [1]datamodel.PathSegment{datamodel.PathSegmentOfInt(2)}}, }} Wish(t, s.Decide(n), ShouldEqual, false) }) diff --git a/traversal/selector/matcher.go b/traversal/selector/matcher.go index dcf51ad5..b8f64f68 100644 --- a/traversal/selector/matcher.go +++ b/traversal/selector/matcher.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Matcher marks a node to be included in the "result" set. @@ -20,26 +20,26 @@ type Matcher struct{} // Interests are empty for a matcher (for now) because // It is always just there to match, not explore further -func (s Matcher) Interests() []ipld.PathSegment { - return []ipld.PathSegment{} +func (s Matcher) Interests() []datamodel.PathSegment { + return []datamodel.PathSegment{} } // Explore will return nil because a matcher is a terminal selector -func (s Matcher) Explore(n ipld.Node, p ipld.PathSegment) (Selector, error) { +func (s Matcher) Explore(n datamodel.Node, p datamodel.PathSegment) (Selector, error) { return nil, nil } // Decide is always true for a match cause it's in the result set // TODO: Implement boolean logic for conditionals -func (s Matcher) Decide(n ipld.Node) bool { +func (s Matcher) Decide(n datamodel.Node) bool { return true } // ParseMatcher assembles a Selector // from a matcher selector node // TODO: Parse labels and conditions -func (pc ParseContext) ParseMatcher(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseMatcher(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector body must be a map") } return Matcher{}, nil diff --git a/traversal/selector/parse/selector_parse.go b/traversal/selector/parse/selector_parse.go index 28e4c485..3930d02b 100644 --- a/traversal/selector/parse/selector_parse.go +++ b/traversal/selector/parse/selector_parse.go @@ -9,20 +9,20 @@ package selectorparse import ( "strings" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" - "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/traversal/selector" ) // ParseJSONSelector accepts a string of json which will be parsed as a selector, -// and returns an ipld.Node of the parsed Data Model. -// The returned ipld.Node is suitable to hand to `selector.CompileSelector`, +// and returns an datamodel.Node of the parsed Data Model. +// The returned datamodel.Node is suitable to hand to `selector.CompileSelector`, // or, could be composed programmatically with other Data Model selector clauses // and then compiled later. // // The selector will be checked for compileability, and an error returned if it is not. -func ParseJSONSelector(jsonStr string) (ipld.Node, error) { +func ParseJSONSelector(jsonStr string) (datamodel.Node, error) { nb := basicnode.Prototype.Any.NewBuilder() if err := dagjson.Decode(nb, strings.NewReader(jsonStr)); err != nil { return nil, err diff --git a/traversal/selector/selector.go b/traversal/selector/selector.go index b54b9787..47f2e2ab 100644 --- a/traversal/selector/selector.go +++ b/traversal/selector/selector.go @@ -3,7 +3,7 @@ package selector import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" ) // Selector is a "compiled" and executable IPLD Selector. @@ -85,7 +85,7 @@ type Selector interface { // **or nil**, which indicates we're a high-cardinality or expression-based selection clause and thus we'll need all segments proposed to us. // // Traversal will call this before calling Explore, and use it to try to call Explore less often (or even avoid iterating on the data node at all). - Interests() []ipld.PathSegment + Interests() []datamodel.PathSegment // Explore is told about the node we're at, and the pathSegment inside it to consider, // and returns either nil, if we shouldn't explore that path any further, @@ -98,13 +98,13 @@ type Selector interface { // Remember that Explore does **not** iterate `node` itself; the visits to any children of `node` will be driven from the outside, by the traversal function. // (The Selector's job is just guiding that process by returning information.) // The architecture works this way so that a sufficiently clever traversal function could consider several reasons for exploring a node before deciding whether to do so. - Explore(node ipld.Node, child ipld.PathSegment) (subsequent Selector, err error) + Explore(node datamodel.Node, child datamodel.PathSegment) (subsequent Selector, err error) // Decide returns true if the subject node is "matched". // // Only "Matcher" clauses actually implement this in a way that ever returns "true". // See the Selector specs for discussion on "matched" vs "reached"/"visited" nodes. - Decide(node ipld.Node) bool + Decide(node datamodel.Node) bool } // REVIEW: do ParsedParent and ParseContext need to be exported? They're mostly used during the compilation process. @@ -120,27 +120,27 @@ type ParseContext struct { parentStack []ParsedParent } -// CompileSelector accepts an ipld.Node which should contain data that declares a Selector. -// The data layout expected for this declaration is documented in https://ipld.io/specs/selectors/ . +// CompileSelector accepts an datamodel.Node which should contain data that declares a Selector. +// The data layout expected for this declaration is documented in https://datamodel.io/specs/selectors/ . // // If the Selector is compiled successfully, it is returned. // Otherwise, if the given data Node doesn't match the expected shape for a Selector declaration, // or there are any other problems compiling the selector // (such as a recursion edge with no enclosing recursion declaration, etc), // then nil and an error will be returned. -func CompileSelector(dmt ipld.Node) (Selector, error) { +func CompileSelector(dmt datamodel.Node) (Selector, error) { return ParseContext{}.ParseSelector(dmt) } // ParseSelector is an alias for CompileSelector, and is deprecated. // Prefer CompileSelector. -func ParseSelector(dmt ipld.Node) (Selector, error) { +func ParseSelector(dmt datamodel.Node) (Selector, error) { return CompileSelector(dmt) } // ParseSelector creates a Selector from an IPLD Selector Node with the given context -func (pc ParseContext) ParseSelector(n ipld.Node) (Selector, error) { - if n.Kind() != ipld.Kind_Map { +func (pc ParseContext) ParseSelector(n datamodel.Node) (Selector, error) { + if n.Kind() != datamodel.Kind_Map { return nil, fmt.Errorf("selector spec parse rejected: selector is a keyed union and thus must be a map") } if n.Length() != 1 { @@ -184,25 +184,25 @@ func (pc ParseContext) PushParent(parent ParsedParent) ParseContext { // SegmentIterator iterates either a list or a map, generating PathSegments // instead of indexes or keys type SegmentIterator interface { - Next() (pathSegment ipld.PathSegment, value ipld.Node, err error) + Next() (pathSegment datamodel.PathSegment, value datamodel.Node, err error) Done() bool } // NewSegmentIterator generates a new iterator based on the node type -func NewSegmentIterator(n ipld.Node) SegmentIterator { - if n.Kind() == ipld.Kind_List { +func NewSegmentIterator(n datamodel.Node) SegmentIterator { + if n.Kind() == datamodel.Kind_List { return listSegmentIterator{n.ListIterator()} } return mapSegmentIterator{n.MapIterator()} } type listSegmentIterator struct { - ipld.ListIterator + datamodel.ListIterator } -func (lsi listSegmentIterator) Next() (pathSegment ipld.PathSegment, value ipld.Node, err error) { +func (lsi listSegmentIterator) Next() (pathSegment datamodel.PathSegment, value datamodel.Node, err error) { i, v, err := lsi.ListIterator.Next() - return ipld.PathSegmentOfInt(i), v, err + return datamodel.PathSegmentOfInt(i), v, err } func (lsi listSegmentIterator) Done() bool { @@ -210,16 +210,16 @@ func (lsi listSegmentIterator) Done() bool { } type mapSegmentIterator struct { - ipld.MapIterator + datamodel.MapIterator } -func (msi mapSegmentIterator) Next() (pathSegment ipld.PathSegment, value ipld.Node, err error) { +func (msi mapSegmentIterator) Next() (pathSegment datamodel.PathSegment, value datamodel.Node, err error) { k, v, err := msi.MapIterator.Next() if err != nil { - return ipld.PathSegment{}, v, err + return datamodel.PathSegment{}, v, err } kstr, _ := k.AsString() - return ipld.PathSegmentOfString(kstr), v, err + return datamodel.PathSegmentOfString(kstr), v, err } func (msi mapSegmentIterator) Done() bool { diff --git a/traversal/selector/spec_test.go b/traversal/selector/spec_test.go index b2d5280e..7a043930 100644 --- a/traversal/selector/spec_test.go +++ b/traversal/selector/spec_test.go @@ -8,11 +8,11 @@ import ( qt "github.com/frankban/quicktest" "github.com/warpfork/go-testmark" - "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" "github.com/ipld/go-ipld-prime/codec/json" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent/qp" - "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/traversal" "github.com/ipld/go-ipld-prime/traversal/selector/parse" ) @@ -58,15 +58,15 @@ func TestSpecFixtures(t *testing.T) { // at the end, we're actually going to... do that, and use string diffs for the final assertion // (because string diffing is actually really nice for aggregate feedback in a system like this); // and also that means we're ready to save updated serial data into the fixture files, if we did want to patch them. - var visitLogs []ipld.Node - traversal.WalkAdv(dataDmt, selector, func(prog traversal.Progress, n ipld.Node, reason traversal.VisitReason) error { + var visitLogs []datamodel.Node + traversal.WalkAdv(dataDmt, selector, func(prog traversal.Progress, n datamodel.Node, reason traversal.VisitReason) error { // Munge info about where we are into DMT shaped like the expectation records in the fixture. - visitEventDescr, err := qp.BuildMap(basicnode.Prototype.Any, 3, func(ma ipld.MapAssembler) { + visitEventDescr, err := qp.BuildMap(basicnode.Prototype.Any, 3, func(ma datamodel.MapAssembler) { qp.MapEntry(ma, "path", qp.String(prog.Path.String())) - qp.MapEntry(ma, "node", qp.Map(1, func(ma ipld.MapAssembler) { - qp.MapEntry(ma, n.Kind().String(), func(na ipld.NodeAssembler) { + qp.MapEntry(ma, "node", qp.Map(1, func(ma datamodel.MapAssembler) { + qp.MapEntry(ma, n.Kind().String(), func(na datamodel.NodeAssembler) { switch n.Kind() { - case ipld.Kind_Map, ipld.Kind_List: + case datamodel.Kind_Map, datamodel.Kind_List: na.AssignNull() default: na.AssignNode(n) diff --git a/traversal/walk.go b/traversal/walk.go index 7251f047..de040a01 100644 --- a/traversal/walk.go +++ b/traversal/walk.go @@ -3,7 +3,8 @@ package traversal import ( "fmt" - ipld "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/linking" "github.com/ipld/go-ipld-prime/traversal/selector" ) @@ -14,7 +15,7 @@ import ( // It cannot cross links automatically (since this requires configuration). // Use the equivalent WalkMatching function on the Progress structure // for more advanced and configurable walks. -func WalkMatching(n ipld.Node, s selector.Selector, fn VisitFn) error { +func WalkMatching(n datamodel.Node, s selector.Selector, fn VisitFn) error { return Progress{}.WalkMatching(n, s, fn) } @@ -26,7 +27,7 @@ func WalkMatching(n ipld.Node, s selector.Selector, fn VisitFn) error { // It cannot cross links automatically (since this requires configuration). // Use the equivalent WalkAdv function on the Progress structure // for more advanced and configurable walks. -func WalkAdv(n ipld.Node, s selector.Selector, fn AdvVisitFn) error { +func WalkAdv(n datamodel.Node, s selector.Selector, fn AdvVisitFn) error { return Progress{}.WalkAdv(n, s, fn) } @@ -38,7 +39,7 @@ func WalkAdv(n ipld.Node, s selector.Selector, fn AdvVisitFn) error { // It cannot cross links automatically (since this requires configuration). // Use the equivalent WalkTransforming function on the Progress structure // for more advanced and configurable walks. -func WalkTransforming(n ipld.Node, s selector.Selector, fn TransformFn) (ipld.Node, error) { +func WalkTransforming(n datamodel.Node, s selector.Selector, fn TransformFn) (datamodel.Node, error) { return Progress{}.WalkTransforming(n, s, fn) } @@ -65,9 +66,9 @@ func WalkTransforming(n ipld.Node, s selector.Selector, fn TransformFn) (ipld.No // the Path recorded of the traversal so far will continue to be extended, // and thus continued nested uses of Walk and Focus will see the fully contextualized Path. // -func (prog Progress) WalkMatching(n ipld.Node, s selector.Selector, fn VisitFn) error { +func (prog Progress) WalkMatching(n datamodel.Node, s selector.Selector, fn VisitFn) error { prog.init() - return prog.walkAdv(n, s, func(prog Progress, n ipld.Node, tr VisitReason) error { + return prog.walkAdv(n, s, func(prog Progress, n datamodel.Node, tr VisitReason) error { if tr != VisitReason_SelectionMatch { return nil } @@ -79,12 +80,12 @@ func (prog Progress) WalkMatching(n ipld.Node, s selector.Selector, fn VisitFn) // visited (not just matching nodes), together with the reason for the visit. // An AdvVisitFn is used instead of a VisitFn, so that the reason can be provided. // -func (prog Progress) WalkAdv(n ipld.Node, s selector.Selector, fn AdvVisitFn) error { +func (prog Progress) WalkAdv(n datamodel.Node, s selector.Selector, fn AdvVisitFn) error { prog.init() return prog.walkAdv(n, s, fn) } -func (prog Progress) walkAdv(n ipld.Node, s selector.Selector, fn AdvVisitFn) error { +func (prog Progress) walkAdv(n datamodel.Node, s selector.Selector, fn AdvVisitFn) error { if s.Decide(n) { if err := fn(prog, n, VisitReason_SelectionMatch); err != nil { return err @@ -96,7 +97,7 @@ func (prog Progress) walkAdv(n ipld.Node, s selector.Selector, fn AdvVisitFn) er } nk := n.Kind() switch nk { - case ipld.Kind_Map, ipld.Kind_List: // continue + case datamodel.Kind_Map, datamodel.Kind_List: // continue default: return nil } @@ -108,7 +109,7 @@ func (prog Progress) walkAdv(n ipld.Node, s selector.Selector, fn AdvVisitFn) er } -func (prog Progress) walkAdv_iterateAll(n ipld.Node, s selector.Selector, fn AdvVisitFn) error { +func (prog Progress) walkAdv_iterateAll(n datamodel.Node, s selector.Selector, fn AdvVisitFn) error { for itr := selector.NewSegmentIterator(n); !itr.Done(); { ps, v, err := itr.Next() if err != nil { @@ -121,7 +122,7 @@ func (prog Progress) walkAdv_iterateAll(n ipld.Node, s selector.Selector, fn Adv if sNext != nil { progNext := prog progNext.Path = prog.Path.AppendSegment(ps) - if v.Kind() == ipld.Kind_Link { + if v.Kind() == datamodel.Kind_Link { lnk, _ := v.AsLink() progNext.LastBlock.Path = progNext.Path progNext.LastBlock.Link = lnk @@ -143,7 +144,7 @@ func (prog Progress) walkAdv_iterateAll(n ipld.Node, s selector.Selector, fn Adv return nil } -func (prog Progress) walkAdv_iterateSelective(n ipld.Node, attn []ipld.PathSegment, s selector.Selector, fn AdvVisitFn) error { +func (prog Progress) walkAdv_iterateSelective(n datamodel.Node, attn []datamodel.PathSegment, s selector.Selector, fn AdvVisitFn) error { for _, ps := range attn { v, err := n.LookupBySegment(ps) if err != nil { @@ -156,7 +157,7 @@ func (prog Progress) walkAdv_iterateSelective(n ipld.Node, attn []ipld.PathSegme if sNext != nil { progNext := prog progNext.Path = prog.Path.AppendSegment(ps) - if v.Kind() == ipld.Kind_Link { + if v.Kind() == datamodel.Kind_Link { lnk, _ := v.AsLink() progNext.LastBlock.Path = progNext.Path progNext.LastBlock.Link = lnk @@ -178,12 +179,12 @@ func (prog Progress) walkAdv_iterateSelective(n ipld.Node, attn []ipld.PathSegme return nil } -func (prog Progress) loadLink(v ipld.Node, parent ipld.Node) (ipld.Node, error) { +func (prog Progress) loadLink(v datamodel.Node, parent datamodel.Node) (datamodel.Node, error) { lnk, err := v.AsLink() if err != nil { return nil, err } - lnkCtx := ipld.LinkContext{ + lnkCtx := linking.LinkContext{ Ctx: prog.Cfg.Ctx, LinkPath: prog.Path, LinkNode: v, @@ -224,6 +225,6 @@ func (prog Progress) loadLink(v ipld.Node, parent ipld.Node) (ipld.Node, error) // are chosen by asking the existing nodes about their prototype). // // This feature is not yet implemented. -func (prog Progress) WalkTransforming(n ipld.Node, s selector.Selector, fn TransformFn) (ipld.Node, error) { +func (prog Progress) WalkTransforming(n datamodel.Node, s selector.Selector, fn TransformFn) (datamodel.Node, error) { panic("TODO") } diff --git a/traversal/walk_test.go b/traversal/walk_test.go index dc521792..81c312c4 100644 --- a/traversal/walk_test.go +++ b/traversal/walk_test.go @@ -5,11 +5,11 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" _ "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/traversal" "github.com/ipld/go-ipld-prime/traversal/selector" "github.com/ipld/go-ipld-prime/traversal/selector/builder" @@ -19,7 +19,7 @@ import ( var ( leafAlpha, leafAlphaLnk = encode(basicnode.NewString("alpha")) leafBeta, leafBetaLnk = encode(basicnode.NewString("beta")) - middleMapNode, middleMapNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype__Map{}, 3, func(na fluent.MapAssembler) { + middleMapNode, middleMapNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype.Map, 3, func(na fluent.MapAssembler) { na.AssembleEntry("foo").AssignBool(true) na.AssembleEntry("bar").AssignBool(false) na.AssembleEntry("nested").CreateMap(2, func(na fluent.MapAssembler) { @@ -27,13 +27,13 @@ var ( na.AssembleEntry("nonlink").AssignString("zoo") }) })) - middleListNode, middleListNodeLnk = encode(fluent.MustBuildList(basicnode.Prototype__List{}, 4, func(na fluent.ListAssembler) { + middleListNode, middleListNodeLnk = encode(fluent.MustBuildList(basicnode.Prototype.List, 4, func(na fluent.ListAssembler) { na.AssembleValue().AssignLink(leafAlphaLnk) na.AssembleValue().AssignLink(leafAlphaLnk) na.AssembleValue().AssignLink(leafBetaLnk) na.AssembleValue().AssignLink(leafAlphaLnk) })) - rootNode, rootNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAssembler) { + rootNode, rootNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype.Map, 4, func(na fluent.MapAssembler) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("linkedString").AssignLink(leafAlphaLnk) na.AssembleEntry("linkedMap").AssignLink(middleMapNodeLnk) @@ -46,19 +46,19 @@ var ( // all cases here use one already-loaded Node; no link-loading exercised. func TestWalkMatching(t *testing.T) { - ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype__Any{}) + ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any) t.Run("traverse selecting true should visit the root", func(t *testing.T) { - err := traversal.WalkMatching(basicnode.NewString("x"), selector.Matcher{}, func(prog traversal.Progress, n ipld.Node) error { + err := traversal.WalkMatching(basicnode.NewString("x"), selector.Matcher{}, func(prog traversal.Progress, n datamodel.Node) error { Wish(t, n, ShouldEqual, basicnode.NewString("x")) - Wish(t, prog.Path.String(), ShouldEqual, ipld.Path{}.String()) + Wish(t, prog.Path.String(), ShouldEqual, datamodel.Path{}.String()) return nil }) Wish(t, err, ShouldEqual, nil) }) t.Run("traverse selecting true should visit only the root and no deeper", func(t *testing.T) { - err := traversal.WalkMatching(middleMapNode, selector.Matcher{}, func(prog traversal.Progress, n ipld.Node) error { + err := traversal.WalkMatching(middleMapNode, selector.Matcher{}, func(prog traversal.Progress, n datamodel.Node) error { Wish(t, n, ShouldEqual, middleMapNode) - Wish(t, prog.Path.String(), ShouldEqual, ipld.Path{}.String()) + Wish(t, prog.Path.String(), ShouldEqual, datamodel.Path{}.String()) return nil }) Wish(t, err, ShouldEqual, nil) @@ -71,7 +71,7 @@ func TestWalkMatching(t *testing.T) { s, err := ss.Selector() Require(t, err, ShouldEqual, nil) var order int - err = traversal.WalkMatching(middleMapNode, s, func(prog traversal.Progress, n ipld.Node) error { + err = traversal.WalkMatching(middleMapNode, s, func(prog traversal.Progress, n datamodel.Node) error { switch order { case 0: Wish(t, n, ShouldEqual, basicnode.NewBool(true)) @@ -96,7 +96,7 @@ func TestWalkMatching(t *testing.T) { s, err := ss.Selector() Require(t, err, ShouldEqual, nil) var order int - err = traversal.WalkMatching(middleMapNode, s, func(prog traversal.Progress, n ipld.Node) error { + err = traversal.WalkMatching(middleMapNode, s, func(prog traversal.Progress, n datamodel.Node) error { switch order { case 0: Wish(t, n, ShouldEqual, basicnode.NewBool(true)) @@ -125,7 +125,7 @@ func TestWalkMatching(t *testing.T) { LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.WalkMatching(middleMapNode, s, func(prog traversal.Progress, n ipld.Node) error { + }.WalkMatching(middleMapNode, s, func(prog traversal.Progress, n datamodel.Node) error { switch order { case 0: Wish(t, n, ShouldEqual, middleMapNode) @@ -137,7 +137,7 @@ func TestWalkMatching(t *testing.T) { Wish(t, n, ShouldEqual, basicnode.NewBool(false)) Wish(t, prog.Path.String(), ShouldEqual, "bar") case 3: - Wish(t, n, ShouldEqual, fluent.MustBuildMap(basicnode.Prototype__Map{}, 2, func(na fluent.MapAssembler) { + Wish(t, n, ShouldEqual, fluent.MustBuildMap(basicnode.Prototype.Map, 2, func(na fluent.MapAssembler) { na.AssembleEntry("alink").AssignLink(leafAlphaLnk) na.AssembleEntry("nonlink").AssignString("zoo") })) @@ -169,7 +169,7 @@ func TestWalkMatching(t *testing.T) { LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.WalkMatching(middleListNode, s, func(prog traversal.Progress, n ipld.Node) error { + }.WalkMatching(middleListNode, s, func(prog traversal.Progress, n datamodel.Node) error { switch order { case 0: Wish(t, n, ShouldEqual, basicnode.NewString("alpha")) @@ -212,7 +212,7 @@ func TestWalkMatching(t *testing.T) { LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.WalkMatching(rootNode, s, func(prog traversal.Progress, n ipld.Node) error { + }.WalkMatching(rootNode, s, func(prog traversal.Progress, n datamodel.Node) error { switch order { case 0: Wish(t, n, ShouldEqual, basicnode.NewString("alpha")) diff --git a/traversal/walk_with_stop_test.go b/traversal/walk_with_stop_test.go index 1a41dab7..40ef91e6 100644 --- a/traversal/walk_with_stop_test.go +++ b/traversal/walk_with_stop_test.go @@ -6,11 +6,11 @@ import ( . "github.com/warpfork/go-wish" - "github.com/ipld/go-ipld-prime" _ "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/ipld/go-ipld-prime/traversal" "github.com/ipld/go-ipld-prime/traversal/selector" "github.com/ipld/go-ipld-prime/traversal/selector/builder" @@ -44,7 +44,7 @@ var ( */ // ExploreRecursiveWithStop builds a recursive selector node with a stop condition -func ExploreRecursiveWithStop(limit selector.RecursionLimit, sequence builder.SelectorSpec, stopLnk ipld.Link) ipld.Node { +func ExploreRecursiveWithStop(limit selector.RecursionLimit, sequence builder.SelectorSpec, stopLnk datamodel.Link) datamodel.Node { np := basicnode.Prototype__Map{} return fluent.MustBuildMap(np, 1, func(na fluent.MapAssembler) { // RecursionLimit @@ -99,7 +99,7 @@ func TestStopAtLink(t *testing.T) { LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.WalkMatching(rootNode, s, func(prog traversal.Progress, n ipld.Node) error { + }.WalkMatching(rootNode, s, func(prog traversal.Progress, n datamodel.Node) error { // fmt.Println("Order", order, prog.Path.String()) switch order { case 0: @@ -128,7 +128,7 @@ func TestStopAtLink(t *testing.T) { // The stopAt condition is extremely appealing for these use cases, as we can // partially sync a chain using ExploreRecursive without having to sync the // chain from scratch if we are already partially synced -func mkChain() (ipld.Node, []ipld.Link) { +func mkChain() (datamodel.Node, []datamodel.Link) { leafAlpha, leafAlphaLnk = encode(basicnode.NewString("alpha")) leafBeta, leafBetaLnk = encode(basicnode.NewString("beta")) middleMapNode, middleMapNodeLnk = encode(fluent.MustBuildMap(basicnode.Prototype__Map{}, 3, func(na fluent.MapAssembler) { @@ -162,7 +162,7 @@ func mkChain() (ipld.Node, []ipld.Link) { na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("ch3").AssignLink(ch3Lnk) })) - return headNode, []ipld.Link{headLnk, ch3Lnk, ch2Lnk, ch1Lnk} + return headNode, []datamodel.Link{headLnk, ch3Lnk, ch2Lnk, ch1Lnk} } func TestStopInChain(t *testing.T) { @@ -177,7 +177,7 @@ func TestStopInChain(t *testing.T) { stopAtInChainTest(t, chainNode, nil, 17) } -func stopAtInChainTest(t *testing.T, chainNode ipld.Node, stopLnk ipld.Link, numSeen int) { +func stopAtInChainTest(t *testing.T, chainNode datamodel.Node, stopLnk datamodel.Link, numSeen int) { ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype__Any{}) t.Run(fmt.Sprintf("test ExploreRecursive stopAt in chain with stoplink: %s", stopLnk), func(t *testing.T) { s, err := selector.CompileSelector(ExploreRecursiveWithStop( @@ -195,7 +195,7 @@ func stopAtInChainTest(t *testing.T, chainNode ipld.Node, stopLnk ipld.Link, num LinkSystem: lsys, LinkTargetNodePrototypeChooser: basicnode.Chooser, }, - }.WalkMatching(chainNode, s, func(prog traversal.Progress, n ipld.Node) error { + }.WalkMatching(chainNode, s, func(prog traversal.Progress, n datamodel.Node) error { //fmt.Println("Order", order, prog.Path.String()) switch order { case 0: