ipldsch_satisfaction.go 93.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package dagpb

// Code generated by go-ipld-prime gengo.  DO NOT EDIT.

import (
	ipld "github.com/ipld/go-ipld-prime"
	"github.com/ipld/go-ipld-prime/node/mixins"
	"github.com/ipld/go-ipld-prime/schema"
)

func (n Bytes) Bytes() []byte {
	return n.x
}
func (_Bytes__Prototype) FromBytes(v []byte) (Bytes, error) {
	n := _Bytes{v}
	return &n, nil
}
18

19 20
type _Bytes__Maybe struct {
	m schema.Maybe
21
	v _Bytes
22 23 24 25 26 27 28 29 30 31 32 33 34 35
}
type MaybeBytes = *_Bytes__Maybe

func (m MaybeBytes) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybeBytes) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybeBytes) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybeBytes) AsNode() ipld.Node {
	switch m.m {
36 37 38 39 40 41 42 43
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return &m.v
	default:
		panic("unreachable")
44 45 46 47 48 49
	}
}
func (m MaybeBytes) Must() Bytes {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
50
	return &m.v
51
}
52

53 54
var _ ipld.Node = (Bytes)(&_Bytes{})
var _ schema.TypedNode = (Bytes)(&_Bytes{})
55

56 57
func (Bytes) Kind() ipld.Kind {
	return ipld.Kind_Bytes
58 59
}
func (Bytes) LookupByString(string) (ipld.Node, error) {
60
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.LookupByString("")
61 62
}
func (Bytes) LookupByNode(ipld.Node) (ipld.Node, error) {
63
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.LookupByNode(nil)
64
}
65
func (Bytes) LookupByIndex(idx int64) (ipld.Node, error) {
66
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.LookupByIndex(0)
67 68
}
func (Bytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
69
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.LookupBySegment(seg)
70 71 72 73 74 75 76
}
func (Bytes) MapIterator() ipld.MapIterator {
	return nil
}
func (Bytes) ListIterator() ipld.ListIterator {
	return nil
}
77
func (Bytes) Length() int64 {
78 79 80 81 82 83 84 85 86
	return -1
}
func (Bytes) IsAbsent() bool {
	return false
}
func (Bytes) IsNull() bool {
	return false
}
func (Bytes) AsBool() (bool, error) {
87
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.AsBool()
88
}
89
func (Bytes) AsInt() (int64, error) {
90
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.AsInt()
91 92
}
func (Bytes) AsFloat() (float64, error) {
93
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.AsFloat()
94 95
}
func (Bytes) AsString() (string, error) {
96
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.AsString()
97 98 99 100 101
}
func (n Bytes) AsBytes() ([]byte, error) {
	return n.x, nil
}
func (Bytes) AsLink() (ipld.Link, error) {
102
	return mixins.Bytes{TypeName: "dagpb.Bytes"}.AsLink()
103 104 105 106
}
func (Bytes) Prototype() ipld.NodePrototype {
	return _Bytes__Prototype{}
}
107

108 109 110 111 112 113 114
type _Bytes__Prototype struct{}

func (_Bytes__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _Bytes__Builder
	nb.Reset()
	return &nb
}
115

116 117 118
type _Bytes__Builder struct {
	_Bytes__Assembler
}
119

120 121 122 123 124 125 126 127 128 129 130
func (nb *_Bytes__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_Bytes__Builder) Reset() {
	var w _Bytes
	var m schema.Maybe
	*nb = _Bytes__Builder{_Bytes__Assembler{w: &w, m: &m}}
}
131

132 133 134 135 136 137
type _Bytes__Assembler struct {
	w *_Bytes
	m *schema.Maybe
}

func (na *_Bytes__Assembler) reset() {}
138
func (_Bytes__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
139
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.BeginMap(0)
140
}
141
func (_Bytes__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
142
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.BeginList(0)
143 144 145 146 147 148 149
}
func (na *_Bytes__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
150
		return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.AssignNull()
151 152 153 154 155 156
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	panic("unreachable")
}
func (_Bytes__Assembler) AssignBool(bool) error {
157
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.AssignBool(false)
158
}
159
func (_Bytes__Assembler) AssignInt(int64) error {
160
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.AssignInt(0)
161 162
}
func (_Bytes__Assembler) AssignFloat(float64) error {
163
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.AssignFloat(0)
164 165
}
func (_Bytes__Assembler) AssignString(string) error {
166
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.AssignString("")
167 168 169 170 171 172 173 174 175 176 177
}
func (na *_Bytes__Assembler) AssignBytes(v []byte) error {
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	na.w.x = v
	*na.m = schema.Maybe_Value
	return nil
}
func (_Bytes__Assembler) AssignLink(ipld.Link) error {
178
	return mixins.BytesAssembler{TypeName: "dagpb.Bytes"}.AssignLink(nil)
179
}
180
func (na *_Bytes__Assembler) AssignNode(v ipld.Node) error {
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_Bytes); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
	if v2, err := v.AsBytes(); err != nil {
		return err
	} else {
		return na.AssignBytes(v2)
	}
}
func (_Bytes__Assembler) Prototype() ipld.NodePrototype {
	return _Bytes__Prototype{}
}
func (Bytes) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n Bytes) Representation() ipld.Node {
	return (*_Bytes__Repr)(n)
}
208

209
type _Bytes__Repr = _Bytes
210

211
var _ ipld.Node = &_Bytes__Repr{}
212

213 214 215
type _Bytes__ReprPrototype = _Bytes__Prototype
type _Bytes__ReprAssembler = _Bytes__Assembler

216
func (n Int) Int() int64 {
217 218
	return n.x
}
219
func (_Int__Prototype) FromInt(v int64) (Int, error) {
220 221 222
	n := _Int{v}
	return &n, nil
}
223

224 225
type _Int__Maybe struct {
	m schema.Maybe
226
	v _Int
227 228 229 230 231 232 233 234 235 236 237 238 239 240
}
type MaybeInt = *_Int__Maybe

func (m MaybeInt) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybeInt) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybeInt) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybeInt) AsNode() ipld.Node {
	switch m.m {
241 242 243 244 245 246 247 248
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return &m.v
	default:
		panic("unreachable")
249 250 251 252 253 254
	}
}
func (m MaybeInt) Must() Int {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
255
	return &m.v
256
}
257

258 259
var _ ipld.Node = (Int)(&_Int{})
var _ schema.TypedNode = (Int)(&_Int{})
260

261 262
func (Int) Kind() ipld.Kind {
	return ipld.Kind_Int
263 264
}
func (Int) LookupByString(string) (ipld.Node, error) {
265
	return mixins.Int{TypeName: "dagpb.Int"}.LookupByString("")
266 267
}
func (Int) LookupByNode(ipld.Node) (ipld.Node, error) {
268
	return mixins.Int{TypeName: "dagpb.Int"}.LookupByNode(nil)
269
}
270
func (Int) LookupByIndex(idx int64) (ipld.Node, error) {
271
	return mixins.Int{TypeName: "dagpb.Int"}.LookupByIndex(0)
272 273
}
func (Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
274
	return mixins.Int{TypeName: "dagpb.Int"}.LookupBySegment(seg)
275 276 277 278 279 280 281
}
func (Int) MapIterator() ipld.MapIterator {
	return nil
}
func (Int) ListIterator() ipld.ListIterator {
	return nil
}
282
func (Int) Length() int64 {
283 284 285 286 287 288 289 290 291
	return -1
}
func (Int) IsAbsent() bool {
	return false
}
func (Int) IsNull() bool {
	return false
}
func (Int) AsBool() (bool, error) {
292
	return mixins.Int{TypeName: "dagpb.Int"}.AsBool()
293
}
294
func (n Int) AsInt() (int64, error) {
295 296 297
	return n.x, nil
}
func (Int) AsFloat() (float64, error) {
298
	return mixins.Int{TypeName: "dagpb.Int"}.AsFloat()
299 300
}
func (Int) AsString() (string, error) {
301
	return mixins.Int{TypeName: "dagpb.Int"}.AsString()
302 303
}
func (Int) AsBytes() ([]byte, error) {
304
	return mixins.Int{TypeName: "dagpb.Int"}.AsBytes()
305 306
}
func (Int) AsLink() (ipld.Link, error) {
307
	return mixins.Int{TypeName: "dagpb.Int"}.AsLink()
308 309 310 311
}
func (Int) Prototype() ipld.NodePrototype {
	return _Int__Prototype{}
}
312

313 314 315 316 317 318 319
type _Int__Prototype struct{}

func (_Int__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _Int__Builder
	nb.Reset()
	return &nb
}
320

321 322 323
type _Int__Builder struct {
	_Int__Assembler
}
324

325 326 327 328 329 330 331 332 333 334 335
func (nb *_Int__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_Int__Builder) Reset() {
	var w _Int
	var m schema.Maybe
	*nb = _Int__Builder{_Int__Assembler{w: &w, m: &m}}
}
336

337 338 339 340 341 342
type _Int__Assembler struct {
	w *_Int
	m *schema.Maybe
}

func (na *_Int__Assembler) reset() {}
343
func (_Int__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
344
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.BeginMap(0)
345
}
346
func (_Int__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
347
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.BeginList(0)
348 349 350 351 352 353 354
}
func (na *_Int__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
355
		return mixins.IntAssembler{TypeName: "dagpb.Int"}.AssignNull()
356 357 358 359 360 361
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	panic("unreachable")
}
func (_Int__Assembler) AssignBool(bool) error {
362
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.AssignBool(false)
363
}
364
func (na *_Int__Assembler) AssignInt(v int64) error {
365 366 367 368 369 370 371 372 373
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	na.w.x = v
	*na.m = schema.Maybe_Value
	return nil
}
func (_Int__Assembler) AssignFloat(float64) error {
374
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.AssignFloat(0)
375 376
}
func (_Int__Assembler) AssignString(string) error {
377
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.AssignString("")
378 379
}
func (_Int__Assembler) AssignBytes([]byte) error {
380
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.AssignBytes(nil)
381 382
}
func (_Int__Assembler) AssignLink(ipld.Link) error {
383
	return mixins.IntAssembler{TypeName: "dagpb.Int"}.AssignLink(nil)
384
}
385
func (na *_Int__Assembler) AssignNode(v ipld.Node) error {
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_Int); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
	if v2, err := v.AsInt(); err != nil {
		return err
	} else {
		return na.AssignInt(v2)
	}
}
func (_Int__Assembler) Prototype() ipld.NodePrototype {
	return _Int__Prototype{}
}
func (Int) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n Int) Representation() ipld.Node {
	return (*_Int__Repr)(n)
}
413

414
type _Int__Repr = _Int
415

416
var _ ipld.Node = &_Int__Repr{}
417

418 419 420 421 422 423 424 425 426 427
type _Int__ReprPrototype = _Int__Prototype
type _Int__ReprAssembler = _Int__Assembler

func (n Link) Link() ipld.Link {
	return n.x
}
func (_Link__Prototype) FromLink(v ipld.Link) (Link, error) {
	n := _Link{v}
	return &n, nil
}
428

429 430
type _Link__Maybe struct {
	m schema.Maybe
431
	v _Link
432 433 434 435 436 437 438 439 440 441 442 443 444 445
}
type MaybeLink = *_Link__Maybe

func (m MaybeLink) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybeLink) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybeLink) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybeLink) AsNode() ipld.Node {
	switch m.m {
446 447 448 449 450 451 452 453
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return &m.v
	default:
		panic("unreachable")
454 455 456 457 458 459
	}
}
func (m MaybeLink) Must() Link {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
460
	return &m.v
461
}
462

463 464
var _ ipld.Node = (Link)(&_Link{})
var _ schema.TypedNode = (Link)(&_Link{})
465

466 467
func (Link) Kind() ipld.Kind {
	return ipld.Kind_Link
468 469
}
func (Link) LookupByString(string) (ipld.Node, error) {
470
	return mixins.Link{TypeName: "dagpb.Link"}.LookupByString("")
471 472
}
func (Link) LookupByNode(ipld.Node) (ipld.Node, error) {
473
	return mixins.Link{TypeName: "dagpb.Link"}.LookupByNode(nil)
474
}
475
func (Link) LookupByIndex(idx int64) (ipld.Node, error) {
476
	return mixins.Link{TypeName: "dagpb.Link"}.LookupByIndex(0)
477 478
}
func (Link) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
479
	return mixins.Link{TypeName: "dagpb.Link"}.LookupBySegment(seg)
480 481 482 483 484 485 486
}
func (Link) MapIterator() ipld.MapIterator {
	return nil
}
func (Link) ListIterator() ipld.ListIterator {
	return nil
}
487
func (Link) Length() int64 {
488 489 490 491 492 493 494 495 496
	return -1
}
func (Link) IsAbsent() bool {
	return false
}
func (Link) IsNull() bool {
	return false
}
func (Link) AsBool() (bool, error) {
497
	return mixins.Link{TypeName: "dagpb.Link"}.AsBool()
498
}
499
func (Link) AsInt() (int64, error) {
500
	return mixins.Link{TypeName: "dagpb.Link"}.AsInt()
501 502
}
func (Link) AsFloat() (float64, error) {
503
	return mixins.Link{TypeName: "dagpb.Link"}.AsFloat()
504 505
}
func (Link) AsString() (string, error) {
506
	return mixins.Link{TypeName: "dagpb.Link"}.AsString()
507 508
}
func (Link) AsBytes() ([]byte, error) {
509
	return mixins.Link{TypeName: "dagpb.Link"}.AsBytes()
510 511 512 513 514 515 516
}
func (n Link) AsLink() (ipld.Link, error) {
	return n.x, nil
}
func (Link) Prototype() ipld.NodePrototype {
	return _Link__Prototype{}
}
517

518 519 520 521 522 523 524
type _Link__Prototype struct{}

func (_Link__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _Link__Builder
	nb.Reset()
	return &nb
}
525

526 527 528
type _Link__Builder struct {
	_Link__Assembler
}
529

530 531 532 533 534 535 536 537 538 539 540
func (nb *_Link__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_Link__Builder) Reset() {
	var w _Link
	var m schema.Maybe
	*nb = _Link__Builder{_Link__Assembler{w: &w, m: &m}}
}
541

542 543 544 545 546 547
type _Link__Assembler struct {
	w *_Link
	m *schema.Maybe
}

func (na *_Link__Assembler) reset() {}
548
func (_Link__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
549
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.BeginMap(0)
550
}
551
func (_Link__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
552
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.BeginList(0)
553 554 555 556 557 558 559
}
func (na *_Link__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
560
		return mixins.LinkAssembler{TypeName: "dagpb.Link"}.AssignNull()
561 562 563 564 565 566
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	panic("unreachable")
}
func (_Link__Assembler) AssignBool(bool) error {
567
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.AssignBool(false)
568
}
569
func (_Link__Assembler) AssignInt(int64) error {
570
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.AssignInt(0)
571 572
}
func (_Link__Assembler) AssignFloat(float64) error {
573
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.AssignFloat(0)
574 575
}
func (_Link__Assembler) AssignString(string) error {
576
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.AssignString("")
577 578
}
func (_Link__Assembler) AssignBytes([]byte) error {
579
	return mixins.LinkAssembler{TypeName: "dagpb.Link"}.AssignBytes(nil)
580 581 582 583 584 585 586 587 588 589
}
func (na *_Link__Assembler) AssignLink(v ipld.Link) error {
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	na.w.x = v
	*na.m = schema.Maybe_Value
	return nil
}
590
func (na *_Link__Assembler) AssignNode(v ipld.Node) error {
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_Link); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
	if v2, err := v.AsLink(); err != nil {
		return err
	} else {
		return na.AssignLink(v2)
	}
}
func (_Link__Assembler) Prototype() ipld.NodePrototype {
	return _Link__Prototype{}
}
func (Link) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n Link) Representation() ipld.Node {
	return (*_Link__Repr)(n)
}
618

619
type _Link__Repr = _Link
620

621
var _ ipld.Node = &_Link__Repr{}
622

623 624 625 626 627 628 629 630 631 632 633 634
type _Link__ReprPrototype = _Link__Prototype
type _Link__ReprAssembler = _Link__Assembler

func (n _PBLink) FieldHash() Link {
	return &n.Hash
}
func (n _PBLink) FieldName() MaybeString {
	return &n.Name
}
func (n _PBLink) FieldTsize() MaybeInt {
	return &n.Tsize
}
635

636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
type _PBLink__Maybe struct {
	m schema.Maybe
	v PBLink
}
type MaybePBLink = *_PBLink__Maybe

func (m MaybePBLink) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybePBLink) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybePBLink) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybePBLink) AsNode() ipld.Node {
	switch m.m {
653 654 655 656 657 658 659 660
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return m.v
	default:
		panic("unreachable")
661 662 663 664 665 666 667 668
	}
}
func (m MaybePBLink) Must() PBLink {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
	return m.v
}
669

670
var (
671 672
	fieldName__PBLink_Hash  = _String{"Hash"}
	fieldName__PBLink_Name  = _String{"Name"}
673 674 675 676
	fieldName__PBLink_Tsize = _String{"Tsize"}
)
var _ ipld.Node = (PBLink)(&_PBLink{})
var _ schema.TypedNode = (PBLink)(&_PBLink{})
677

678 679
func (PBLink) Kind() ipld.Kind {
	return ipld.Kind_Map
680 681 682 683 684 685 686 687 688
}
func (n PBLink) LookupByString(key string) (ipld.Node, error) {
	switch key {
	case "Hash":
		return &n.Hash, nil
	case "Name":
		if n.Name.m == schema.Maybe_Absent {
			return ipld.Absent, nil
		}
689
		return &n.Name.v, nil
690 691 692 693
	case "Tsize":
		if n.Tsize.m == schema.Maybe_Absent {
			return ipld.Absent, nil
		}
694
		return &n.Tsize.v, nil
695 696 697 698 699 700 701 702 703 704 705
	default:
		return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)}
	}
}
func (n PBLink) LookupByNode(key ipld.Node) (ipld.Node, error) {
	ks, err := key.AsString()
	if err != nil {
		return nil, err
	}
	return n.LookupByString(ks)
}
706
func (PBLink) LookupByIndex(idx int64) (ipld.Node, error) {
707
	return mixins.Map{TypeName: "dagpb.PBLink"}.LookupByIndex(0)
708 709 710 711 712 713 714 715 716
}
func (n PBLink) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
	return n.LookupByString(seg.String())
}
func (n PBLink) MapIterator() ipld.MapIterator {
	return &_PBLink__MapItr{n, 0}
}

type _PBLink__MapItr struct {
717 718
	n   PBLink
	idx int
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
}

func (itr *_PBLink__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
	if itr.idx >= 3 {
		return nil, nil, ipld.ErrIteratorOverread{}
	}
	switch itr.idx {
	case 0:
		k = &fieldName__PBLink_Hash
		v = &itr.n.Hash
	case 1:
		k = &fieldName__PBLink_Name
		if itr.n.Name.m == schema.Maybe_Absent {
			v = ipld.Absent
			break
		}
735
		v = &itr.n.Name.v
736 737 738 739 740 741
	case 2:
		k = &fieldName__PBLink_Tsize
		if itr.n.Tsize.m == schema.Maybe_Absent {
			v = ipld.Absent
			break
		}
742
		v = &itr.n.Tsize.v
743 744 745 746 747 748 749 750 751 752 753 754 755
	default:
		panic("unreachable")
	}
	itr.idx++
	return
}
func (itr *_PBLink__MapItr) Done() bool {
	return itr.idx >= 3
}

func (PBLink) ListIterator() ipld.ListIterator {
	return nil
}
756
func (PBLink) Length() int64 {
757 758 759 760 761 762 763 764 765
	return 3
}
func (PBLink) IsAbsent() bool {
	return false
}
func (PBLink) IsNull() bool {
	return false
}
func (PBLink) AsBool() (bool, error) {
766
	return mixins.Map{TypeName: "dagpb.PBLink"}.AsBool()
767
}
768
func (PBLink) AsInt() (int64, error) {
769
	return mixins.Map{TypeName: "dagpb.PBLink"}.AsInt()
770 771
}
func (PBLink) AsFloat() (float64, error) {
772
	return mixins.Map{TypeName: "dagpb.PBLink"}.AsFloat()
773 774
}
func (PBLink) AsString() (string, error) {
775
	return mixins.Map{TypeName: "dagpb.PBLink"}.AsString()
776 777
}
func (PBLink) AsBytes() ([]byte, error) {
778
	return mixins.Map{TypeName: "dagpb.PBLink"}.AsBytes()
779 780
}
func (PBLink) AsLink() (ipld.Link, error) {
781
	return mixins.Map{TypeName: "dagpb.PBLink"}.AsLink()
782 783 784 785
}
func (PBLink) Prototype() ipld.NodePrototype {
	return _PBLink__Prototype{}
}
786

787 788 789 790 791 792 793
type _PBLink__Prototype struct{}

func (_PBLink__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _PBLink__Builder
	nb.Reset()
	return &nb
}
794

795 796 797
type _PBLink__Builder struct {
	_PBLink__Assembler
}
798

799 800 801 802 803 804 805 806 807 808 809
func (nb *_PBLink__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_PBLink__Builder) Reset() {
	var w _PBLink
	var m schema.Maybe
	*nb = _PBLink__Builder{_PBLink__Assembler{w: &w, m: &m}}
}
810

811
type _PBLink__Assembler struct {
812 813
	w     *_PBLink
	m     *schema.Maybe
814
	state maState
815 816
	s     int
	f     int
817

818 819 820
	cm       schema.Maybe
	ca_Hash  _Link__Assembler
	ca_Name  _String__Assembler
821
	ca_Tsize _Int__Assembler
822
}
823 824 825 826 827 828 829 830 831 832

func (na *_PBLink__Assembler) reset() {
	na.state = maState_initial
	na.s = 0
	na.ca_Hash.reset()
	na.ca_Name.reset()
	na.ca_Tsize.reset()
}

var (
833 834 835 836
	fieldBit__PBLink_Hash        = 1 << 0
	fieldBit__PBLink_Name        = 1 << 1
	fieldBit__PBLink_Tsize       = 1 << 2
	fieldBits__PBLink_sufficient = 0 + 1<<0
837
)
838

839
func (na *_PBLink__Assembler) BeginMap(int64) (ipld.MapAssembler, error) {
840 841 842 843 844 845 846 847 848 849 850 851
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
	}
	*na.m = midvalue
	if na.w == nil {
		na.w = &_PBLink{}
	}
	return na, nil
}
852
func (_PBLink__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
853
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.BeginList(0)
854 855 856 857 858 859 860
}
func (na *_PBLink__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
861
		return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignNull()
862 863 864 865 866 867 868 869
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
	}
	panic("unreachable")
}
func (_PBLink__Assembler) AssignBool(bool) error {
870
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignBool(false)
871
}
872
func (_PBLink__Assembler) AssignInt(int64) error {
873
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignInt(0)
874 875
}
func (_PBLink__Assembler) AssignFloat(float64) error {
876
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignFloat(0)
877 878
}
func (_PBLink__Assembler) AssignString(string) error {
879
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignString("")
880 881
}
func (_PBLink__Assembler) AssignBytes([]byte) error {
882
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignBytes(nil)
883 884
}
func (_PBLink__Assembler) AssignLink(ipld.Link) error {
885
	return mixins.MapAssembler{TypeName: "dagpb.PBLink"}.AssignLink(nil)
886
}
887
func (na *_PBLink__Assembler) AssignNode(v ipld.Node) error {
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_PBLink); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		case midvalue:
			panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
		}
		if na.w == nil {
			na.w = v2
			*na.m = schema.Maybe_Value
			return nil
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
907
	if v.Kind() != ipld.Kind_Map {
908
		return ipld.ErrWrongKind{TypeName: "dagpb.PBLink", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()}
909 910 911 912 913 914 915
	}
	itr := v.MapIterator()
	for !itr.Done() {
		k, v, err := itr.Next()
		if err != nil {
			return err
		}
916
		if err := na.AssembleKey().AssignNode(k); err != nil {
917 918
			return err
		}
919
		if err := na.AssembleValue().AssignNode(v); err != nil {
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976
			return err
		}
	}
	return na.Finish()
}
func (_PBLink__Assembler) Prototype() ipld.NodePrototype {
	return _PBLink__Prototype{}
}
func (ma *_PBLink__Assembler) valueFinishTidy() bool {
	switch ma.f {
	case 0:
		switch ma.cm {
		case schema.Maybe_Value:
			ma.ca_Hash.w = nil
			ma.cm = schema.Maybe_Absent
			ma.state = maState_initial
			return true
		default:
			return false
		}
	case 1:
		switch ma.w.Name.m {
		case schema.Maybe_Value:
			ma.state = maState_initial
			return true
		default:
			return false
		}
	case 2:
		switch ma.w.Tsize.m {
		case schema.Maybe_Value:
			ma.state = maState_initial
			return true
		default:
			return false
		}
	default:
		panic("unreachable")
	}
}
func (ma *_PBLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleEntry cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleEntry cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleEntry cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished")
	}
	switch k {
	case "Hash":
977 978
		if ma.s&fieldBit__PBLink_Hash != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Hash}
979 980 981 982 983 984 985 986
		}
		ma.s += fieldBit__PBLink_Hash
		ma.state = maState_midValue
		ma.f = 0
		ma.ca_Hash.w = &ma.w.Hash
		ma.ca_Hash.m = &ma.cm
		return &ma.ca_Hash, nil
	case "Name":
987 988
		if ma.s&fieldBit__PBLink_Name != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Name}
989 990 991 992
		}
		ma.s += fieldBit__PBLink_Name
		ma.state = maState_midValue
		ma.f = 1
993
		ma.ca_Name.w = &ma.w.Name.v
994 995 996
		ma.ca_Name.m = &ma.w.Name.m
		return &ma.ca_Name, nil
	case "Tsize":
997 998
		if ma.s&fieldBit__PBLink_Tsize != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Tsize}
999 1000 1001 1002
		}
		ma.s += fieldBit__PBLink_Tsize
		ma.state = maState_midValue
		ma.f = 2
1003
		ma.ca_Tsize.w = &ma.w.Tsize.v
1004 1005 1006
		ma.ca_Tsize.m = &ma.w.Tsize.m
		return &ma.ca_Tsize, nil
	}
1007
	return nil, ipld.ErrInvalidKey{TypeName: "dagpb.PBLink", Key: &_String{k}}
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046
}
func (ma *_PBLink__Assembler) AssembleKey() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleKey cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleKey cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleKey cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleKey cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midKey
	return (*_PBLink__KeyAssembler)(ma)
}
func (ma *_PBLink__Assembler) AssembleValue() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		panic("invalid state: AssembleValue cannot be called when no key is primed")
	case maState_midKey:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		// carry on
	case maState_midValue:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling another value")
	case maState_finished:
		panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midValue
	switch ma.f {
	case 0:
		ma.ca_Hash.w = &ma.w.Hash
		ma.ca_Hash.m = &ma.cm
		return &ma.ca_Hash
	case 1:
1047
		ma.ca_Name.w = &ma.w.Name.v
1048 1049 1050
		ma.ca_Name.m = &ma.w.Name.m
		return &ma.ca_Name
	case 2:
1051
		ma.ca_Tsize.w = &ma.w.Tsize.v
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
		ma.ca_Tsize.m = &ma.w.Tsize.m
		return &ma.ca_Tsize
	default:
		panic("unreachable")
	}
}
func (ma *_PBLink__Assembler) Finish() error {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: Finish cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		panic("invalid state: Finish cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: Finish cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: Finish cannot be called on an assembler that's already finished")
	}
1073
	if ma.s&fieldBits__PBLink_sufficient != fieldBits__PBLink_sufficient {
1074
		err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
1075
		if ma.s&fieldBit__PBLink_Hash == 0 {
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
			err.Missing = append(err.Missing, "Hash")
		}
		return err
	}
	ma.state = maState_finished
	*ma.m = schema.Maybe_Value
	return nil
}
func (ma *_PBLink__Assembler) KeyPrototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (ma *_PBLink__Assembler) ValuePrototype(k string) ipld.NodePrototype {
	panic("todo structbuilder mapassembler valueprototype")
}
1090

1091
type _PBLink__KeyAssembler _PBLink__Assembler
1092

1093
func (_PBLink__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
1094
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.BeginMap(0)
1095
}
1096
func (_PBLink__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
1097
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.BeginList(0)
1098 1099
}
func (na *_PBLink__KeyAssembler) AssignNull() error {
1100
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.AssignNull()
1101 1102
}
func (_PBLink__KeyAssembler) AssignBool(bool) error {
1103
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.AssignBool(false)
1104
}
1105
func (_PBLink__KeyAssembler) AssignInt(int64) error {
1106
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.AssignInt(0)
1107 1108
}
func (_PBLink__KeyAssembler) AssignFloat(float64) error {
1109
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.AssignFloat(0)
1110 1111 1112 1113 1114 1115 1116
}
func (ka *_PBLink__KeyAssembler) AssignString(k string) error {
	if ka.state != maState_midKey {
		panic("misuse: KeyAssembler held beyond its valid lifetime")
	}
	switch k {
	case "Hash":
1117 1118
		if ka.s&fieldBit__PBLink_Hash != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Hash}
1119 1120 1121 1122 1123
		}
		ka.s += fieldBit__PBLink_Hash
		ka.state = maState_expectValue
		ka.f = 0
	case "Name":
1124 1125
		if ka.s&fieldBit__PBLink_Name != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Name}
1126 1127 1128 1129 1130
		}
		ka.s += fieldBit__PBLink_Name
		ka.state = maState_expectValue
		ka.f = 1
	case "Tsize":
1131 1132
		if ka.s&fieldBit__PBLink_Tsize != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Tsize}
1133 1134 1135 1136 1137
		}
		ka.s += fieldBit__PBLink_Tsize
		ka.state = maState_expectValue
		ka.f = 2
	default:
1138
		return ipld.ErrInvalidKey{TypeName: "dagpb.PBLink", Key: &_String{k}}
1139 1140 1141 1142
	}
	return nil
}
func (_PBLink__KeyAssembler) AssignBytes([]byte) error {
1143
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.AssignBytes(nil)
1144 1145
}
func (_PBLink__KeyAssembler) AssignLink(ipld.Link) error {
1146
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.KeyAssembler"}.AssignLink(nil)
1147
}
1148
func (ka *_PBLink__KeyAssembler) AssignNode(v ipld.Node) error {
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
	if v2, err := v.AsString(); err != nil {
		return err
	} else {
		return ka.AssignString(v2)
	}
}
func (_PBLink__KeyAssembler) Prototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (PBLink) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n PBLink) Representation() ipld.Node {
	return (*_PBLink__Repr)(n)
}
1164

1165
type _PBLink__Repr _PBLink
1166

1167
var (
1168 1169
	fieldName__PBLink_Hash_serial  = _String{"Hash"}
	fieldName__PBLink_Name_serial  = _String{"Name"}
1170 1171 1172
	fieldName__PBLink_Tsize_serial = _String{"Tsize"}
)
var _ ipld.Node = &_PBLink__Repr{}
1173

1174 1175
func (_PBLink__Repr) Kind() ipld.Kind {
	return ipld.Kind_Map
1176 1177 1178 1179 1180 1181 1182
}
func (n *_PBLink__Repr) LookupByString(key string) (ipld.Node, error) {
	switch key {
	case "Hash":
		return n.Hash.Representation(), nil
	case "Name":
		if n.Name.m == schema.Maybe_Absent {
1183
			return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)}
1184 1185 1186 1187
		}
		return n.Name.v.Representation(), nil
	case "Tsize":
		if n.Tsize.m == schema.Maybe_Absent {
1188
			return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)}
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
		}
		return n.Tsize.v.Representation(), nil
	default:
		return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)}
	}
}
func (n *_PBLink__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) {
	ks, err := key.AsString()
	if err != nil {
		return nil, err
	}
	return n.LookupByString(ks)
}
1202
func (_PBLink__Repr) LookupByIndex(idx int64) (ipld.Node, error) {
1203
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.LookupByIndex(0)
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
}
func (n _PBLink__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
	return n.LookupByString(seg.String())
}
func (n *_PBLink__Repr) MapIterator() ipld.MapIterator {
	end := 3
	if n.Tsize.m == schema.Maybe_Absent {
		end = 2
	} else {
		goto done
	}
	if n.Name.m == schema.Maybe_Absent {
		end = 1
	} else {
		goto done
	}
done:
	return &_PBLink__ReprMapItr{n, 0, end}
}

type _PBLink__ReprMapItr struct {
	n   *_PBLink__Repr
	idx int
	end int
}

func (itr *_PBLink__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
1231 1232
advance:
	if itr.idx >= 3 {
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
		return nil, nil, ipld.ErrIteratorOverread{}
	}
	switch itr.idx {
	case 0:
		k = &fieldName__PBLink_Hash_serial
		v = itr.n.Hash.Representation()
	case 1:
		k = &fieldName__PBLink_Name_serial
		if itr.n.Name.m == schema.Maybe_Absent {
			itr.idx++
			goto advance
		}
		v = itr.n.Name.v.Representation()
	case 2:
		k = &fieldName__PBLink_Tsize_serial
		if itr.n.Tsize.m == schema.Maybe_Absent {
			itr.idx++
			goto advance
		}
		v = itr.n.Tsize.v.Representation()
	default:
		panic("unreachable")
	}
	itr.idx++
	return
}
func (itr *_PBLink__ReprMapItr) Done() bool {
	return itr.idx >= itr.end
}
func (_PBLink__Repr) ListIterator() ipld.ListIterator {
	return nil
}
1265
func (rn *_PBLink__Repr) Length() int64 {
1266 1267 1268 1269 1270 1271 1272
	l := 3
	if rn.Name.m == schema.Maybe_Absent {
		l--
	}
	if rn.Tsize.m == schema.Maybe_Absent {
		l--
	}
1273
	return int64(l)
1274 1275 1276 1277 1278 1279 1280 1281
}
func (_PBLink__Repr) IsAbsent() bool {
	return false
}
func (_PBLink__Repr) IsNull() bool {
	return false
}
func (_PBLink__Repr) AsBool() (bool, error) {
1282
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.AsBool()
1283
}
1284
func (_PBLink__Repr) AsInt() (int64, error) {
1285
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.AsInt()
1286 1287
}
func (_PBLink__Repr) AsFloat() (float64, error) {
1288
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.AsFloat()
1289 1290
}
func (_PBLink__Repr) AsString() (string, error) {
1291
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.AsString()
1292 1293
}
func (_PBLink__Repr) AsBytes() ([]byte, error) {
1294
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.AsBytes()
1295 1296
}
func (_PBLink__Repr) AsLink() (ipld.Link, error) {
1297
	return mixins.Map{TypeName: "dagpb.PBLink.Repr"}.AsLink()
1298 1299 1300 1301
}
func (_PBLink__Repr) Prototype() ipld.NodePrototype {
	return _PBLink__ReprPrototype{}
}
1302

1303 1304 1305 1306 1307 1308 1309
type _PBLink__ReprPrototype struct{}

func (_PBLink__ReprPrototype) NewBuilder() ipld.NodeBuilder {
	var nb _PBLink__ReprBuilder
	nb.Reset()
	return &nb
}
1310

1311 1312 1313
type _PBLink__ReprBuilder struct {
	_PBLink__ReprAssembler
}
1314

1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325
func (nb *_PBLink__ReprBuilder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_PBLink__ReprBuilder) Reset() {
	var w _PBLink
	var m schema.Maybe
	*nb = _PBLink__ReprBuilder{_PBLink__ReprAssembler{w: &w, m: &m}}
}
1326

1327
type _PBLink__ReprAssembler struct {
1328 1329
	w     *_PBLink
	m     *schema.Maybe
1330
	state maState
1331 1332
	s     int
	f     int
1333

1334 1335 1336
	cm       schema.Maybe
	ca_Hash  _Link__ReprAssembler
	ca_Name  _String__ReprAssembler
1337
	ca_Tsize _Int__ReprAssembler
1338
}
1339 1340 1341 1342 1343 1344 1345 1346

func (na *_PBLink__ReprAssembler) reset() {
	na.state = maState_initial
	na.s = 0
	na.ca_Hash.reset()
	na.ca_Name.reset()
	na.ca_Tsize.reset()
}
1347
func (na *_PBLink__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) {
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
	}
	*na.m = midvalue
	if na.w == nil {
		na.w = &_PBLink{}
	}
	return na, nil
}
1360
func (_PBLink__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
1361
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.BeginList(0)
1362 1363 1364 1365 1366 1367 1368
}
func (na *_PBLink__ReprAssembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
1369
		return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr.Repr"}.AssignNull()
1370 1371 1372 1373 1374 1375 1376 1377
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
	}
	panic("unreachable")
}
func (_PBLink__ReprAssembler) AssignBool(bool) error {
1378
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.AssignBool(false)
1379
}
1380
func (_PBLink__ReprAssembler) AssignInt(int64) error {
1381
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.AssignInt(0)
1382 1383
}
func (_PBLink__ReprAssembler) AssignFloat(float64) error {
1384
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.AssignFloat(0)
1385 1386
}
func (_PBLink__ReprAssembler) AssignString(string) error {
1387
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.AssignString("")
1388 1389
}
func (_PBLink__ReprAssembler) AssignBytes([]byte) error {
1390
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.AssignBytes(nil)
1391 1392
}
func (_PBLink__ReprAssembler) AssignLink(ipld.Link) error {
1393
	return mixins.MapAssembler{TypeName: "dagpb.PBLink.Repr"}.AssignLink(nil)
1394
}
1395
func (na *_PBLink__ReprAssembler) AssignNode(v ipld.Node) error {
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_PBLink); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		case midvalue:
			panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
		}
		if na.w == nil {
			na.w = v2
			*na.m = schema.Maybe_Value
			return nil
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
1415
	if v.Kind() != ipld.Kind_Map {
1416
		return ipld.ErrWrongKind{TypeName: "dagpb.PBLink.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()}
1417 1418 1419 1420 1421 1422 1423
	}
	itr := v.MapIterator()
	for !itr.Done() {
		k, v, err := itr.Next()
		if err != nil {
			return err
		}
1424
		if err := na.AssembleKey().AssignNode(k); err != nil {
1425 1426
			return err
		}
1427
		if err := na.AssembleValue().AssignNode(v); err != nil {
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
			return err
		}
	}
	return na.Finish()
}
func (_PBLink__ReprAssembler) Prototype() ipld.NodePrototype {
	return _PBLink__ReprPrototype{}
}
func (ma *_PBLink__ReprAssembler) valueFinishTidy() bool {
	switch ma.f {
	case 0:
		switch ma.cm {
1440 1441
		case schema.Maybe_Value:
			ma.cm = schema.Maybe_Absent
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483
			ma.state = maState_initial
			return true
		default:
			return false
		}
	case 1:
		switch ma.w.Name.m {
		case schema.Maybe_Value:
			ma.state = maState_initial
			return true
		default:
			return false
		}
	case 2:
		switch ma.w.Tsize.m {
		case schema.Maybe_Value:
			ma.state = maState_initial
			return true
		default:
			return false
		}
	default:
		panic("unreachable")
	}
}
func (ma *_PBLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleEntry cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleEntry cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleEntry cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished")
	}
	switch k {
	case "Hash":
1484 1485
		if ma.s&fieldBit__PBLink_Hash != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Hash_serial}
1486 1487 1488 1489 1490 1491 1492 1493
		}
		ma.s += fieldBit__PBLink_Hash
		ma.state = maState_midValue
		ma.f = 0
		ma.ca_Hash.w = &ma.w.Hash
		ma.ca_Hash.m = &ma.cm
		return &ma.ca_Hash, nil
	case "Name":
1494 1495
		if ma.s&fieldBit__PBLink_Name != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Name_serial}
1496 1497 1498 1499
		}
		ma.s += fieldBit__PBLink_Name
		ma.state = maState_midValue
		ma.f = 1
1500
		ma.ca_Name.w = &ma.w.Name.v
1501
		ma.ca_Name.m = &ma.w.Name.m
1502

1503 1504
		return &ma.ca_Name, nil
	case "Tsize":
1505 1506
		if ma.s&fieldBit__PBLink_Tsize != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Tsize_serial}
1507 1508 1509 1510
		}
		ma.s += fieldBit__PBLink_Tsize
		ma.state = maState_midValue
		ma.f = 2
1511
		ma.ca_Tsize.w = &ma.w.Tsize.v
1512
		ma.ca_Tsize.m = &ma.w.Tsize.m
1513

1514 1515 1516
		return &ma.ca_Tsize, nil
	default:
	}
1517
	return nil, ipld.ErrInvalidKey{TypeName: "dagpb.PBLink.Repr", Key: &_String{k}}
1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556
}
func (ma *_PBLink__ReprAssembler) AssembleKey() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleKey cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleKey cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleKey cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleKey cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midKey
	return (*_PBLink__ReprKeyAssembler)(ma)
}
func (ma *_PBLink__ReprAssembler) AssembleValue() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		panic("invalid state: AssembleValue cannot be called when no key is primed")
	case maState_midKey:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		// carry on
	case maState_midValue:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling another value")
	case maState_finished:
		panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midValue
	switch ma.f {
	case 0:
		ma.ca_Hash.w = &ma.w.Hash
		ma.ca_Hash.m = &ma.cm
		return &ma.ca_Hash
	case 1:
1557
		ma.ca_Name.w = &ma.w.Name.v
1558
		ma.ca_Name.m = &ma.w.Name.m
1559

1560 1561
		return &ma.ca_Name
	case 2:
1562
		ma.ca_Tsize.w = &ma.w.Tsize.v
1563
		ma.ca_Tsize.m = &ma.w.Tsize.m
1564

1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
		return &ma.ca_Tsize
	default:
		panic("unreachable")
	}
}
func (ma *_PBLink__ReprAssembler) Finish() error {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: Finish cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		panic("invalid state: Finish cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: Finish cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: Finish cannot be called on an assembler that's already finished")
	}
1585
	if ma.s&fieldBits__PBLink_sufficient != fieldBits__PBLink_sufficient {
1586
		err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
1587
		if ma.s&fieldBit__PBLink_Hash == 0 {
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601
			err.Missing = append(err.Missing, "Hash")
		}
		return err
	}
	ma.state = maState_finished
	*ma.m = schema.Maybe_Value
	return nil
}
func (ma *_PBLink__ReprAssembler) KeyPrototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (ma *_PBLink__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype {
	panic("todo structbuilder mapassembler repr valueprototype")
}
1602

1603
type _PBLink__ReprKeyAssembler _PBLink__ReprAssembler
1604

1605
func (_PBLink__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
1606
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.BeginMap(0)
1607
}
1608
func (_PBLink__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
1609
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.BeginList(0)
1610 1611
}
func (na *_PBLink__ReprKeyAssembler) AssignNull() error {
1612
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.AssignNull()
1613 1614
}
func (_PBLink__ReprKeyAssembler) AssignBool(bool) error {
1615
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.AssignBool(false)
1616
}
1617
func (_PBLink__ReprKeyAssembler) AssignInt(int64) error {
1618
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.AssignInt(0)
1619 1620
}
func (_PBLink__ReprKeyAssembler) AssignFloat(float64) error {
1621
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.AssignFloat(0)
1622 1623 1624 1625 1626 1627 1628
}
func (ka *_PBLink__ReprKeyAssembler) AssignString(k string) error {
	if ka.state != maState_midKey {
		panic("misuse: KeyAssembler held beyond its valid lifetime")
	}
	switch k {
	case "Hash":
1629 1630
		if ka.s&fieldBit__PBLink_Hash != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Hash_serial}
1631 1632 1633 1634
		}
		ka.s += fieldBit__PBLink_Hash
		ka.state = maState_expectValue
		ka.f = 0
1635
		return nil
1636
	case "Name":
1637 1638
		if ka.s&fieldBit__PBLink_Name != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Name_serial}
1639 1640 1641 1642
		}
		ka.s += fieldBit__PBLink_Name
		ka.state = maState_expectValue
		ka.f = 1
1643
		return nil
1644
	case "Tsize":
1645 1646
		if ka.s&fieldBit__PBLink_Tsize != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBLink_Tsize_serial}
1647 1648 1649 1650
		}
		ka.s += fieldBit__PBLink_Tsize
		ka.state = maState_expectValue
		ka.f = 2
1651
		return nil
1652
	}
1653
	return ipld.ErrInvalidKey{TypeName: "dagpb.PBLink.Repr", Key: &_String{k}}
1654 1655
}
func (_PBLink__ReprKeyAssembler) AssignBytes([]byte) error {
1656
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.AssignBytes(nil)
1657 1658
}
func (_PBLink__ReprKeyAssembler) AssignLink(ipld.Link) error {
1659
	return mixins.StringAssembler{TypeName: "dagpb.PBLink.Repr.KeyAssembler"}.AssignLink(nil)
1660
}
1661
func (ka *_PBLink__ReprKeyAssembler) AssignNode(v ipld.Node) error {
1662 1663 1664 1665 1666 1667 1668 1669 1670 1671
	if v2, err := v.AsString(); err != nil {
		return err
	} else {
		return ka.AssignString(v2)
	}
}
func (_PBLink__ReprKeyAssembler) Prototype() ipld.NodePrototype {
	return _String__Prototype{}
}

1672
func (n *_PBLinks) Lookup(idx int64) PBLink {
1673 1674 1675 1676 1677 1678
	if n.Length() <= idx {
		return nil
	}
	v := &n.x[idx]
	return v
}
1679
func (n *_PBLinks) LookupMaybe(idx int64) MaybePBLink {
1680 1681 1682 1683 1684 1685 1686 1687 1688 1689
	if n.Length() <= idx {
		return nil
	}
	v := &n.x[idx]
	return &_PBLink__Maybe{
		m: schema.Maybe_Value,
		v: v,
	}
}

1690 1691
var _PBLinks__valueAbsent = _PBLink__Maybe{m: schema.Maybe_Absent}

1692 1693 1694 1695 1696
func (n PBLinks) Iterator() *PBLinks__Itr {
	return &PBLinks__Itr{n, 0}
}

type PBLinks__Itr struct {
1697 1698
	n   PBLinks
	idx int
1699 1700
}

1701
func (itr *PBLinks__Itr) Next() (idx int64, v PBLink) {
1702 1703 1704
	if itr.idx >= len(itr.n.x) {
		return -1, nil
	}
1705
	idx = int64(itr.idx)
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
	v = &itr.n.x[itr.idx]
	itr.idx++
	return
}
func (itr *PBLinks__Itr) Done() bool {
	return itr.idx >= len(itr.n.x)
}

type _PBLinks__Maybe struct {
	m schema.Maybe
1716
	v _PBLinks
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730
}
type MaybePBLinks = *_PBLinks__Maybe

func (m MaybePBLinks) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybePBLinks) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybePBLinks) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybePBLinks) AsNode() ipld.Node {
	switch m.m {
1731 1732 1733 1734 1735 1736 1737 1738
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return &m.v
	default:
		panic("unreachable")
1739 1740 1741 1742 1743 1744
	}
}
func (m MaybePBLinks) Must() PBLinks {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
1745
	return &m.v
1746
}
1747

1748 1749
var _ ipld.Node = (PBLinks)(&_PBLinks{})
var _ schema.TypedNode = (PBLinks)(&_PBLinks{})
1750

1751 1752
func (PBLinks) Kind() ipld.Kind {
	return ipld.Kind_List
1753 1754
}
func (PBLinks) LookupByString(string) (ipld.Node, error) {
1755
	return mixins.List{TypeName: "dagpb.PBLinks"}.LookupByString("")
1756 1757 1758 1759 1760 1761 1762 1763
}
func (n PBLinks) LookupByNode(k ipld.Node) (ipld.Node, error) {
	idx, err := k.AsInt()
	if err != nil {
		return nil, err
	}
	return n.LookupByIndex(idx)
}
1764
func (n PBLinks) LookupByIndex(idx int64) (ipld.Node, error) {
1765
	if n.Length() <= idx {
1766
		return nil, ipld.ErrNotExists{Segment: ipld.PathSegmentOfInt(idx)}
1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785
	}
	v := &n.x[idx]
	return v, nil
}
func (n PBLinks) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
	i, err := seg.Index()
	if err != nil {
		return nil, ipld.ErrInvalidSegmentForList{TypeName: "dagpb.PBLinks", TroubleSegment: seg, Reason: err}
	}
	return n.LookupByIndex(i)
}
func (PBLinks) MapIterator() ipld.MapIterator {
	return nil
}
func (n PBLinks) ListIterator() ipld.ListIterator {
	return &_PBLinks__ListItr{n, 0}
}

type _PBLinks__ListItr struct {
1786 1787
	n   PBLinks
	idx int
1788 1789
}

1790
func (itr *_PBLinks__ListItr) Next() (idx int64, v ipld.Node, _ error) {
1791 1792 1793
	if itr.idx >= len(itr.n.x) {
		return -1, nil, ipld.ErrIteratorOverread{}
	}
1794
	idx = int64(itr.idx)
1795 1796 1797 1798 1799 1800 1801 1802 1803
	x := &itr.n.x[itr.idx]
	v = x
	itr.idx++
	return
}
func (itr *_PBLinks__ListItr) Done() bool {
	return itr.idx >= len(itr.n.x)
}

1804 1805
func (n PBLinks) Length() int64 {
	return int64(len(n.x))
1806 1807 1808 1809 1810 1811 1812 1813
}
func (PBLinks) IsAbsent() bool {
	return false
}
func (PBLinks) IsNull() bool {
	return false
}
func (PBLinks) AsBool() (bool, error) {
1814
	return mixins.List{TypeName: "dagpb.PBLinks"}.AsBool()
1815
}
1816
func (PBLinks) AsInt() (int64, error) {
1817
	return mixins.List{TypeName: "dagpb.PBLinks"}.AsInt()
1818 1819
}
func (PBLinks) AsFloat() (float64, error) {
1820
	return mixins.List{TypeName: "dagpb.PBLinks"}.AsFloat()
1821 1822
}
func (PBLinks) AsString() (string, error) {
1823
	return mixins.List{TypeName: "dagpb.PBLinks"}.AsString()
1824 1825
}
func (PBLinks) AsBytes() ([]byte, error) {
1826
	return mixins.List{TypeName: "dagpb.PBLinks"}.AsBytes()
1827 1828
}
func (PBLinks) AsLink() (ipld.Link, error) {
1829
	return mixins.List{TypeName: "dagpb.PBLinks"}.AsLink()
1830 1831 1832 1833
}
func (PBLinks) Prototype() ipld.NodePrototype {
	return _PBLinks__Prototype{}
}
1834

1835 1836 1837 1838 1839 1840 1841
type _PBLinks__Prototype struct{}

func (_PBLinks__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _PBLinks__Builder
	nb.Reset()
	return &nb
}
1842

1843 1844 1845
type _PBLinks__Builder struct {
	_PBLinks__Assembler
}
1846

1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
func (nb *_PBLinks__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_PBLinks__Builder) Reset() {
	var w _PBLinks
	var m schema.Maybe
	*nb = _PBLinks__Builder{_PBLinks__Assembler{w: &w, m: &m}}
}
1858

1859
type _PBLinks__Assembler struct {
1860 1861
	w     *_PBLinks
	m     *schema.Maybe
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
	state laState

	cm schema.Maybe
	va _PBLink__Assembler
}

func (na *_PBLinks__Assembler) reset() {
	na.state = laState_initial
	na.va.reset()
}
1872
func (_PBLinks__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
1873
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.BeginMap(0)
1874
}
1875
func (na *_PBLinks__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
	}
	*na.m = midvalue
	if sizeHint < 0 {
		sizeHint = 0
	}
	if sizeHint > 0 {
		na.w.x = make([]_PBLink, 0, sizeHint)
	}
	return na, nil
}
func (na *_PBLinks__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
1897
		return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignNull()
1898 1899 1900 1901 1902 1903 1904 1905
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
	}
	panic("unreachable")
}
func (_PBLinks__Assembler) AssignBool(bool) error {
1906
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignBool(false)
1907
}
1908
func (_PBLinks__Assembler) AssignInt(int64) error {
1909
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignInt(0)
1910 1911
}
func (_PBLinks__Assembler) AssignFloat(float64) error {
1912
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignFloat(0)
1913 1914
}
func (_PBLinks__Assembler) AssignString(string) error {
1915
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignString("")
1916 1917
}
func (_PBLinks__Assembler) AssignBytes([]byte) error {
1918
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignBytes(nil)
1919 1920
}
func (_PBLinks__Assembler) AssignLink(ipld.Link) error {
1921
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks"}.AssignLink(nil)
1922
}
1923
func (na *_PBLinks__Assembler) AssignNode(v ipld.Node) error {
1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_PBLinks); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		case midvalue:
			panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
1938
	if v.Kind() != ipld.Kind_List {
1939
		return ipld.ErrWrongKind{TypeName: "dagpb.PBLinks", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()}
1940 1941 1942 1943 1944 1945 1946
	}
	itr := v.ListIterator()
	for !itr.Done() {
		_, v, err := itr.Next()
		if err != nil {
			return err
		}
1947
		if err := na.AssembleValue().AssignNode(v); err != nil {
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
			return err
		}
	}
	return na.Finish()
}
func (_PBLinks__Assembler) Prototype() ipld.NodePrototype {
	return _PBLinks__Prototype{}
}
func (la *_PBLinks__Assembler) valueFinishTidy() bool {
	switch la.cm {
	case schema.Maybe_Value:
		la.va.w = nil
		la.cm = schema.Maybe_Absent
		la.state = laState_initial
		la.va.reset()
		return true
	default:
		return false
	}
}
func (la *_PBLinks__Assembler) AssembleValue() ipld.NodeAssembler {
	switch la.state {
	case laState_initial:
		// carry on
	case laState_midValue:
		if !la.valueFinishTidy() {
			panic("invalid state: AssembleValue cannot be called when still in the middle of assembling the previous value")
		} // if tidy success: carry on
	case laState_finished:
		panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
	}
	la.w.x = append(la.w.x, _PBLink{})
	la.state = laState_midValue
	row := &la.w.x[len(la.w.x)-1]
	la.va.w = row
	la.va.m = &la.cm
	return &la.va
}
func (la *_PBLinks__Assembler) Finish() error {
	switch la.state {
	case laState_initial:
		// carry on
	case laState_midValue:
		if !la.valueFinishTidy() {
			panic("invalid state: Finish cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case laState_finished:
		panic("invalid state: Finish cannot be called on an assembler that's already finished")
	}
	la.state = laState_finished
	*la.m = schema.Maybe_Value
	return nil
}
2001
func (la *_PBLinks__Assembler) ValuePrototype(_ int64) ipld.NodePrototype {
2002 2003 2004 2005 2006 2007 2008 2009
	return _PBLink__Prototype{}
}
func (PBLinks) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n PBLinks) Representation() ipld.Node {
	return (*_PBLinks__Repr)(n)
}
2010

2011
type _PBLinks__Repr _PBLinks
2012

2013
var _ ipld.Node = &_PBLinks__Repr{}
2014

2015 2016
func (_PBLinks__Repr) Kind() ipld.Kind {
	return ipld.Kind_List
2017 2018
}
func (_PBLinks__Repr) LookupByString(string) (ipld.Node, error) {
2019
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.LookupByString("")
2020 2021 2022 2023 2024 2025 2026 2027
}
func (nr *_PBLinks__Repr) LookupByNode(k ipld.Node) (ipld.Node, error) {
	v, err := (PBLinks)(nr).LookupByNode(k)
	if err != nil || v == ipld.Null {
		return v, err
	}
	return v.(PBLink).Representation(), nil
}
2028
func (nr *_PBLinks__Repr) LookupByIndex(idx int64) (ipld.Node, error) {
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050
	v, err := (PBLinks)(nr).LookupByIndex(idx)
	if err != nil || v == ipld.Null {
		return v, err
	}
	return v.(PBLink).Representation(), nil
}
func (n _PBLinks__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
	i, err := seg.Index()
	if err != nil {
		return nil, ipld.ErrInvalidSegmentForList{TypeName: "dagpb.PBLinks.Repr", TroubleSegment: seg, Reason: err}
	}
	return n.LookupByIndex(i)
}
func (_PBLinks__Repr) MapIterator() ipld.MapIterator {
	return nil
}
func (nr *_PBLinks__Repr) ListIterator() ipld.ListIterator {
	return &_PBLinks__ReprListItr{(PBLinks)(nr), 0}
}

type _PBLinks__ReprListItr _PBLinks__ListItr

2051
func (itr *_PBLinks__ReprListItr) Next() (idx int64, v ipld.Node, err error) {
2052 2053 2054 2055 2056 2057 2058 2059 2060 2061
	idx, v, err = (*_PBLinks__ListItr)(itr).Next()
	if err != nil || v == ipld.Null {
		return
	}
	return idx, v.(PBLink).Representation(), nil
}
func (itr *_PBLinks__ReprListItr) Done() bool {
	return (*_PBLinks__ListItr)(itr).Done()
}

2062 2063
func (rn *_PBLinks__Repr) Length() int64 {
	return int64(len(rn.x))
2064 2065 2066 2067 2068 2069 2070 2071
}
func (_PBLinks__Repr) IsAbsent() bool {
	return false
}
func (_PBLinks__Repr) IsNull() bool {
	return false
}
func (_PBLinks__Repr) AsBool() (bool, error) {
2072
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.AsBool()
2073
}
2074
func (_PBLinks__Repr) AsInt() (int64, error) {
2075
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.AsInt()
2076 2077
}
func (_PBLinks__Repr) AsFloat() (float64, error) {
2078
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.AsFloat()
2079 2080
}
func (_PBLinks__Repr) AsString() (string, error) {
2081
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.AsString()
2082 2083
}
func (_PBLinks__Repr) AsBytes() ([]byte, error) {
2084
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.AsBytes()
2085 2086
}
func (_PBLinks__Repr) AsLink() (ipld.Link, error) {
2087
	return mixins.List{TypeName: "dagpb.PBLinks.Repr"}.AsLink()
2088 2089 2090 2091
}
func (_PBLinks__Repr) Prototype() ipld.NodePrototype {
	return _PBLinks__ReprPrototype{}
}
2092

2093 2094 2095 2096 2097 2098 2099
type _PBLinks__ReprPrototype struct{}

func (_PBLinks__ReprPrototype) NewBuilder() ipld.NodeBuilder {
	var nb _PBLinks__ReprBuilder
	nb.Reset()
	return &nb
}
2100

2101 2102 2103
type _PBLinks__ReprBuilder struct {
	_PBLinks__ReprAssembler
}
2104

2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115
func (nb *_PBLinks__ReprBuilder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_PBLinks__ReprBuilder) Reset() {
	var w _PBLinks
	var m schema.Maybe
	*nb = _PBLinks__ReprBuilder{_PBLinks__ReprAssembler{w: &w, m: &m}}
}
2116

2117
type _PBLinks__ReprAssembler struct {
2118 2119
	w     *_PBLinks
	m     *schema.Maybe
2120 2121 2122 2123 2124 2125 2126 2127 2128 2129
	state laState

	cm schema.Maybe
	va _PBLink__ReprAssembler
}

func (na *_PBLinks__ReprAssembler) reset() {
	na.state = laState_initial
	na.va.reset()
}
2130
func (_PBLinks__ReprAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
2131
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.BeginMap(0)
2132
}
2133
func (na *_PBLinks__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
	}
	*na.m = midvalue
	if sizeHint < 0 {
		sizeHint = 0
	}
	if sizeHint > 0 {
		na.w.x = make([]_PBLink, 0, sizeHint)
	}
	return na, nil
}
func (na *_PBLinks__ReprAssembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
2155
		return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr.Repr"}.AssignNull()
2156 2157 2158 2159 2160 2161 2162 2163
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
	}
	panic("unreachable")
}
func (_PBLinks__ReprAssembler) AssignBool(bool) error {
2164
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.AssignBool(false)
2165
}
2166
func (_PBLinks__ReprAssembler) AssignInt(int64) error {
2167
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.AssignInt(0)
2168 2169
}
func (_PBLinks__ReprAssembler) AssignFloat(float64) error {
2170
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.AssignFloat(0)
2171 2172
}
func (_PBLinks__ReprAssembler) AssignString(string) error {
2173
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.AssignString("")
2174 2175
}
func (_PBLinks__ReprAssembler) AssignBytes([]byte) error {
2176
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.AssignBytes(nil)
2177 2178
}
func (_PBLinks__ReprAssembler) AssignLink(ipld.Link) error {
2179
	return mixins.ListAssembler{TypeName: "dagpb.PBLinks.Repr"}.AssignLink(nil)
2180
}
2181
func (na *_PBLinks__ReprAssembler) AssignNode(v ipld.Node) error {
2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_PBLinks); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		case midvalue:
			panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
2196
	if v.Kind() != ipld.Kind_List {
2197
		return ipld.ErrWrongKind{TypeName: "dagpb.PBLinks.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustList, ActualKind: v.Kind()}
2198 2199 2200 2201 2202 2203 2204
	}
	itr := v.ListIterator()
	for !itr.Done() {
		_, v, err := itr.Next()
		if err != nil {
			return err
		}
2205
		if err := na.AssembleValue().AssignNode(v); err != nil {
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
			return err
		}
	}
	return na.Finish()
}
func (_PBLinks__ReprAssembler) Prototype() ipld.NodePrototype {
	return _PBLinks__ReprPrototype{}
}
func (la *_PBLinks__ReprAssembler) valueFinishTidy() bool {
	switch la.cm {
	case schema.Maybe_Value:
		la.va.w = nil
		la.cm = schema.Maybe_Absent
		la.state = laState_initial
		la.va.reset()
		return true
	default:
		return false
	}
}
func (la *_PBLinks__ReprAssembler) AssembleValue() ipld.NodeAssembler {
	switch la.state {
	case laState_initial:
		// carry on
	case laState_midValue:
		if !la.valueFinishTidy() {
			panic("invalid state: AssembleValue cannot be called when still in the middle of assembling the previous value")
		} // if tidy success: carry on
	case laState_finished:
		panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
	}
	la.w.x = append(la.w.x, _PBLink{})
	la.state = laState_midValue
	row := &la.w.x[len(la.w.x)-1]
	la.va.w = row
	la.va.m = &la.cm
	return &la.va
}
func (la *_PBLinks__ReprAssembler) Finish() error {
	switch la.state {
	case laState_initial:
		// carry on
	case laState_midValue:
		if !la.valueFinishTidy() {
			panic("invalid state: Finish cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case laState_finished:
		panic("invalid state: Finish cannot be called on an assembler that's already finished")
	}
	la.state = laState_finished
	*la.m = schema.Maybe_Value
	return nil
}
2259
func (la *_PBLinks__ReprAssembler) ValuePrototype(_ int64) ipld.NodePrototype {
2260 2261 2262 2263 2264 2265 2266 2267 2268
	return _PBLink__ReprPrototype{}
}

func (n _PBNode) FieldLinks() PBLinks {
	return &n.Links
}
func (n _PBNode) FieldData() MaybeBytes {
	return &n.Data
}
2269

2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286
type _PBNode__Maybe struct {
	m schema.Maybe
	v PBNode
}
type MaybePBNode = *_PBNode__Maybe

func (m MaybePBNode) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybePBNode) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybePBNode) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybePBNode) AsNode() ipld.Node {
	switch m.m {
2287 2288 2289 2290 2291 2292 2293 2294
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return m.v
	default:
		panic("unreachable")
2295 2296 2297 2298 2299 2300 2301 2302
	}
}
func (m MaybePBNode) Must() PBNode {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
	return m.v
}
2303

2304 2305
var (
	fieldName__PBNode_Links = _String{"Links"}
2306
	fieldName__PBNode_Data  = _String{"Data"}
2307 2308 2309
)
var _ ipld.Node = (PBNode)(&_PBNode{})
var _ schema.TypedNode = (PBNode)(&_PBNode{})
2310

2311 2312
func (PBNode) Kind() ipld.Kind {
	return ipld.Kind_Map
2313 2314 2315 2316 2317 2318 2319 2320 2321
}
func (n PBNode) LookupByString(key string) (ipld.Node, error) {
	switch key {
	case "Links":
		return &n.Links, nil
	case "Data":
		if n.Data.m == schema.Maybe_Absent {
			return ipld.Absent, nil
		}
2322
		return &n.Data.v, nil
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333
	default:
		return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)}
	}
}
func (n PBNode) LookupByNode(key ipld.Node) (ipld.Node, error) {
	ks, err := key.AsString()
	if err != nil {
		return nil, err
	}
	return n.LookupByString(ks)
}
2334
func (PBNode) LookupByIndex(idx int64) (ipld.Node, error) {
2335
	return mixins.Map{TypeName: "dagpb.PBNode"}.LookupByIndex(0)
2336 2337 2338 2339 2340 2341 2342 2343 2344
}
func (n PBNode) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
	return n.LookupByString(seg.String())
}
func (n PBNode) MapIterator() ipld.MapIterator {
	return &_PBNode__MapItr{n, 0}
}

type _PBNode__MapItr struct {
2345 2346
	n   PBNode
	idx int
2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362
}

func (itr *_PBNode__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
	if itr.idx >= 2 {
		return nil, nil, ipld.ErrIteratorOverread{}
	}
	switch itr.idx {
	case 0:
		k = &fieldName__PBNode_Links
		v = &itr.n.Links
	case 1:
		k = &fieldName__PBNode_Data
		if itr.n.Data.m == schema.Maybe_Absent {
			v = ipld.Absent
			break
		}
2363
		v = &itr.n.Data.v
2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376
	default:
		panic("unreachable")
	}
	itr.idx++
	return
}
func (itr *_PBNode__MapItr) Done() bool {
	return itr.idx >= 2
}

func (PBNode) ListIterator() ipld.ListIterator {
	return nil
}
2377
func (PBNode) Length() int64 {
2378 2379 2380 2381 2382 2383 2384 2385 2386
	return 2
}
func (PBNode) IsAbsent() bool {
	return false
}
func (PBNode) IsNull() bool {
	return false
}
func (PBNode) AsBool() (bool, error) {
2387
	return mixins.Map{TypeName: "dagpb.PBNode"}.AsBool()
2388
}
2389
func (PBNode) AsInt() (int64, error) {
2390
	return mixins.Map{TypeName: "dagpb.PBNode"}.AsInt()
2391 2392
}
func (PBNode) AsFloat() (float64, error) {
2393
	return mixins.Map{TypeName: "dagpb.PBNode"}.AsFloat()
2394 2395
}
func (PBNode) AsString() (string, error) {
2396
	return mixins.Map{TypeName: "dagpb.PBNode"}.AsString()
2397 2398
}
func (PBNode) AsBytes() ([]byte, error) {
2399
	return mixins.Map{TypeName: "dagpb.PBNode"}.AsBytes()
2400 2401
}
func (PBNode) AsLink() (ipld.Link, error) {
2402
	return mixins.Map{TypeName: "dagpb.PBNode"}.AsLink()
2403 2404 2405 2406
}
func (PBNode) Prototype() ipld.NodePrototype {
	return _PBNode__Prototype{}
}
2407

2408 2409 2410 2411 2412 2413 2414
type _PBNode__Prototype struct{}

func (_PBNode__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _PBNode__Builder
	nb.Reset()
	return &nb
}
2415

2416 2417 2418
type _PBNode__Builder struct {
	_PBNode__Assembler
}
2419

2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430
func (nb *_PBNode__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_PBNode__Builder) Reset() {
	var w _PBNode
	var m schema.Maybe
	*nb = _PBNode__Builder{_PBNode__Assembler{w: &w, m: &m}}
}
2431

2432
type _PBNode__Assembler struct {
2433 2434
	w     *_PBNode
	m     *schema.Maybe
2435
	state maState
2436 2437
	s     int
	f     int
2438

2439
	cm       schema.Maybe
2440
	ca_Links _PBLinks__Assembler
2441 2442
	ca_Data  _Bytes__Assembler
}
2443 2444 2445 2446 2447 2448 2449 2450 2451

func (na *_PBNode__Assembler) reset() {
	na.state = maState_initial
	na.s = 0
	na.ca_Links.reset()
	na.ca_Data.reset()
}

var (
2452 2453 2454
	fieldBit__PBNode_Links       = 1 << 0
	fieldBit__PBNode_Data        = 1 << 1
	fieldBits__PBNode_sufficient = 0 + 1<<0
2455
)
2456

2457
func (na *_PBNode__Assembler) BeginMap(int64) (ipld.MapAssembler, error) {
2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
	}
	*na.m = midvalue
	if na.w == nil {
		na.w = &_PBNode{}
	}
	return na, nil
}
2470
func (_PBNode__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
2471
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.BeginList(0)
2472 2473 2474 2475 2476 2477 2478
}
func (na *_PBNode__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
2479
		return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignNull()
2480 2481 2482 2483 2484 2485 2486 2487
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
	}
	panic("unreachable")
}
func (_PBNode__Assembler) AssignBool(bool) error {
2488
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignBool(false)
2489
}
2490
func (_PBNode__Assembler) AssignInt(int64) error {
2491
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignInt(0)
2492 2493
}
func (_PBNode__Assembler) AssignFloat(float64) error {
2494
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignFloat(0)
2495 2496
}
func (_PBNode__Assembler) AssignString(string) error {
2497
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignString("")
2498 2499
}
func (_PBNode__Assembler) AssignBytes([]byte) error {
2500
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignBytes(nil)
2501 2502
}
func (_PBNode__Assembler) AssignLink(ipld.Link) error {
2503
	return mixins.MapAssembler{TypeName: "dagpb.PBNode"}.AssignLink(nil)
2504
}
2505
func (na *_PBNode__Assembler) AssignNode(v ipld.Node) error {
2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_PBNode); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		case midvalue:
			panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
		}
		if na.w == nil {
			na.w = v2
			*na.m = schema.Maybe_Value
			return nil
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
2525
	if v.Kind() != ipld.Kind_Map {
2526
		return ipld.ErrWrongKind{TypeName: "dagpb.PBNode", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()}
2527 2528 2529 2530 2531 2532 2533
	}
	itr := v.MapIterator()
	for !itr.Done() {
		k, v, err := itr.Next()
		if err != nil {
			return err
		}
2534
		if err := na.AssembleKey().AssignNode(k); err != nil {
2535 2536
			return err
		}
2537
		if err := na.AssembleValue().AssignNode(v); err != nil {
2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586
			return err
		}
	}
	return na.Finish()
}
func (_PBNode__Assembler) Prototype() ipld.NodePrototype {
	return _PBNode__Prototype{}
}
func (ma *_PBNode__Assembler) valueFinishTidy() bool {
	switch ma.f {
	case 0:
		switch ma.cm {
		case schema.Maybe_Value:
			ma.ca_Links.w = nil
			ma.cm = schema.Maybe_Absent
			ma.state = maState_initial
			return true
		default:
			return false
		}
	case 1:
		switch ma.w.Data.m {
		case schema.Maybe_Value:
			ma.state = maState_initial
			return true
		default:
			return false
		}
	default:
		panic("unreachable")
	}
}
func (ma *_PBNode__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleEntry cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleEntry cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleEntry cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished")
	}
	switch k {
	case "Links":
2587 2588
		if ma.s&fieldBit__PBNode_Links != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Links}
2589 2590 2591 2592 2593 2594 2595 2596
		}
		ma.s += fieldBit__PBNode_Links
		ma.state = maState_midValue
		ma.f = 0
		ma.ca_Links.w = &ma.w.Links
		ma.ca_Links.m = &ma.cm
		return &ma.ca_Links, nil
	case "Data":
2597 2598
		if ma.s&fieldBit__PBNode_Data != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Data}
2599 2600 2601 2602
		}
		ma.s += fieldBit__PBNode_Data
		ma.state = maState_midValue
		ma.f = 1
2603
		ma.ca_Data.w = &ma.w.Data.v
2604 2605 2606
		ma.ca_Data.m = &ma.w.Data.m
		return &ma.ca_Data, nil
	}
2607
	return nil, ipld.ErrInvalidKey{TypeName: "dagpb.PBNode", Key: &_String{k}}
2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646
}
func (ma *_PBNode__Assembler) AssembleKey() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleKey cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleKey cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleKey cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleKey cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midKey
	return (*_PBNode__KeyAssembler)(ma)
}
func (ma *_PBNode__Assembler) AssembleValue() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		panic("invalid state: AssembleValue cannot be called when no key is primed")
	case maState_midKey:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		// carry on
	case maState_midValue:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling another value")
	case maState_finished:
		panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midValue
	switch ma.f {
	case 0:
		ma.ca_Links.w = &ma.w.Links
		ma.ca_Links.m = &ma.cm
		return &ma.ca_Links
	case 1:
2647
		ma.ca_Data.w = &ma.w.Data.v
2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668
		ma.ca_Data.m = &ma.w.Data.m
		return &ma.ca_Data
	default:
		panic("unreachable")
	}
}
func (ma *_PBNode__Assembler) Finish() error {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: Finish cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		panic("invalid state: Finish cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: Finish cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: Finish cannot be called on an assembler that's already finished")
	}
2669
	if ma.s&fieldBits__PBNode_sufficient != fieldBits__PBNode_sufficient {
2670
		err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
2671
		if ma.s&fieldBit__PBNode_Links == 0 {
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685
			err.Missing = append(err.Missing, "Links")
		}
		return err
	}
	ma.state = maState_finished
	*ma.m = schema.Maybe_Value
	return nil
}
func (ma *_PBNode__Assembler) KeyPrototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (ma *_PBNode__Assembler) ValuePrototype(k string) ipld.NodePrototype {
	panic("todo structbuilder mapassembler valueprototype")
}
2686

2687
type _PBNode__KeyAssembler _PBNode__Assembler
2688

2689
func (_PBNode__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
2690
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.BeginMap(0)
2691
}
2692
func (_PBNode__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
2693
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.BeginList(0)
2694 2695
}
func (na *_PBNode__KeyAssembler) AssignNull() error {
2696
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.AssignNull()
2697 2698
}
func (_PBNode__KeyAssembler) AssignBool(bool) error {
2699
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.AssignBool(false)
2700
}
2701
func (_PBNode__KeyAssembler) AssignInt(int64) error {
2702
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.AssignInt(0)
2703 2704
}
func (_PBNode__KeyAssembler) AssignFloat(float64) error {
2705
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.AssignFloat(0)
2706 2707 2708 2709 2710 2711 2712
}
func (ka *_PBNode__KeyAssembler) AssignString(k string) error {
	if ka.state != maState_midKey {
		panic("misuse: KeyAssembler held beyond its valid lifetime")
	}
	switch k {
	case "Links":
2713 2714
		if ka.s&fieldBit__PBNode_Links != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Links}
2715 2716 2717 2718 2719
		}
		ka.s += fieldBit__PBNode_Links
		ka.state = maState_expectValue
		ka.f = 0
	case "Data":
2720 2721
		if ka.s&fieldBit__PBNode_Data != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Data}
2722 2723 2724 2725 2726
		}
		ka.s += fieldBit__PBNode_Data
		ka.state = maState_expectValue
		ka.f = 1
	default:
2727
		return ipld.ErrInvalidKey{TypeName: "dagpb.PBNode", Key: &_String{k}}
2728 2729 2730 2731
	}
	return nil
}
func (_PBNode__KeyAssembler) AssignBytes([]byte) error {
2732
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.AssignBytes(nil)
2733 2734
}
func (_PBNode__KeyAssembler) AssignLink(ipld.Link) error {
2735
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.KeyAssembler"}.AssignLink(nil)
2736
}
2737
func (ka *_PBNode__KeyAssembler) AssignNode(v ipld.Node) error {
2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752
	if v2, err := v.AsString(); err != nil {
		return err
	} else {
		return ka.AssignString(v2)
	}
}
func (_PBNode__KeyAssembler) Prototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (PBNode) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n PBNode) Representation() ipld.Node {
	return (*_PBNode__Repr)(n)
}
2753

2754
type _PBNode__Repr _PBNode
2755

2756 2757
var (
	fieldName__PBNode_Links_serial = _String{"Links"}
2758
	fieldName__PBNode_Data_serial  = _String{"Data"}
2759 2760
)
var _ ipld.Node = &_PBNode__Repr{}
2761

2762 2763
func (_PBNode__Repr) Kind() ipld.Kind {
	return ipld.Kind_Map
2764 2765 2766 2767 2768 2769 2770
}
func (n *_PBNode__Repr) LookupByString(key string) (ipld.Node, error) {
	switch key {
	case "Links":
		return n.Links.Representation(), nil
	case "Data":
		if n.Data.m == schema.Maybe_Absent {
2771
			return ipld.Absent, ipld.ErrNotExists{Segment: ipld.PathSegmentOfString(key)}
2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784
		}
		return n.Data.v.Representation(), nil
	default:
		return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)}
	}
}
func (n *_PBNode__Repr) LookupByNode(key ipld.Node) (ipld.Node, error) {
	ks, err := key.AsString()
	if err != nil {
		return nil, err
	}
	return n.LookupByString(ks)
}
2785
func (_PBNode__Repr) LookupByIndex(idx int64) (ipld.Node, error) {
2786
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.LookupByIndex(0)
2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
}
func (n _PBNode__Repr) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
	return n.LookupByString(seg.String())
}
func (n *_PBNode__Repr) MapIterator() ipld.MapIterator {
	end := 2
	if n.Data.m == schema.Maybe_Absent {
		end = 1
	} else {
		goto done
	}
done:
	return &_PBNode__ReprMapItr{n, 0, end}
}

type _PBNode__ReprMapItr struct {
	n   *_PBNode__Repr
	idx int
	end int
}

func (itr *_PBNode__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
2809 2810
advance:
	if itr.idx >= 2 {
2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835
		return nil, nil, ipld.ErrIteratorOverread{}
	}
	switch itr.idx {
	case 0:
		k = &fieldName__PBNode_Links_serial
		v = itr.n.Links.Representation()
	case 1:
		k = &fieldName__PBNode_Data_serial
		if itr.n.Data.m == schema.Maybe_Absent {
			itr.idx++
			goto advance
		}
		v = itr.n.Data.v.Representation()
	default:
		panic("unreachable")
	}
	itr.idx++
	return
}
func (itr *_PBNode__ReprMapItr) Done() bool {
	return itr.idx >= itr.end
}
func (_PBNode__Repr) ListIterator() ipld.ListIterator {
	return nil
}
2836
func (rn *_PBNode__Repr) Length() int64 {
2837 2838 2839 2840
	l := 2
	if rn.Data.m == schema.Maybe_Absent {
		l--
	}
2841
	return int64(l)
2842 2843 2844 2845 2846 2847 2848 2849
}
func (_PBNode__Repr) IsAbsent() bool {
	return false
}
func (_PBNode__Repr) IsNull() bool {
	return false
}
func (_PBNode__Repr) AsBool() (bool, error) {
2850
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.AsBool()
2851
}
2852
func (_PBNode__Repr) AsInt() (int64, error) {
2853
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.AsInt()
2854 2855
}
func (_PBNode__Repr) AsFloat() (float64, error) {
2856
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.AsFloat()
2857 2858
}
func (_PBNode__Repr) AsString() (string, error) {
2859
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.AsString()
2860 2861
}
func (_PBNode__Repr) AsBytes() ([]byte, error) {
2862
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.AsBytes()
2863 2864
}
func (_PBNode__Repr) AsLink() (ipld.Link, error) {
2865
	return mixins.Map{TypeName: "dagpb.PBNode.Repr"}.AsLink()
2866 2867 2868 2869
}
func (_PBNode__Repr) Prototype() ipld.NodePrototype {
	return _PBNode__ReprPrototype{}
}
2870

2871 2872 2873 2874 2875 2876 2877
type _PBNode__ReprPrototype struct{}

func (_PBNode__ReprPrototype) NewBuilder() ipld.NodeBuilder {
	var nb _PBNode__ReprBuilder
	nb.Reset()
	return &nb
}
2878

2879 2880 2881
type _PBNode__ReprBuilder struct {
	_PBNode__ReprAssembler
}
2882

2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893
func (nb *_PBNode__ReprBuilder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_PBNode__ReprBuilder) Reset() {
	var w _PBNode
	var m schema.Maybe
	*nb = _PBNode__ReprBuilder{_PBNode__ReprAssembler{w: &w, m: &m}}
}
2894

2895
type _PBNode__ReprAssembler struct {
2896 2897
	w     *_PBNode
	m     *schema.Maybe
2898
	state maState
2899 2900
	s     int
	f     int
2901

2902
	cm       schema.Maybe
2903
	ca_Links _PBLinks__ReprAssembler
2904 2905
	ca_Data  _Bytes__ReprAssembler
}
2906 2907 2908 2909 2910 2911 2912

func (na *_PBNode__ReprAssembler) reset() {
	na.state = maState_initial
	na.s = 0
	na.ca_Links.reset()
	na.ca_Data.reset()
}
2913
func (na *_PBNode__ReprAssembler) BeginMap(int64) (ipld.MapAssembler, error) {
2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
	}
	*na.m = midvalue
	if na.w == nil {
		na.w = &_PBNode{}
	}
	return na, nil
}
2926
func (_PBNode__ReprAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
2927
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.BeginList(0)
2928 2929 2930 2931 2932 2933 2934
}
func (na *_PBNode__ReprAssembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
2935
		return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr.Repr"}.AssignNull()
2936 2937 2938 2939 2940 2941 2942 2943
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	case midvalue:
		panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
	}
	panic("unreachable")
}
func (_PBNode__ReprAssembler) AssignBool(bool) error {
2944
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.AssignBool(false)
2945
}
2946
func (_PBNode__ReprAssembler) AssignInt(int64) error {
2947
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.AssignInt(0)
2948 2949
}
func (_PBNode__ReprAssembler) AssignFloat(float64) error {
2950
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.AssignFloat(0)
2951 2952
}
func (_PBNode__ReprAssembler) AssignString(string) error {
2953
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.AssignString("")
2954 2955
}
func (_PBNode__ReprAssembler) AssignBytes([]byte) error {
2956
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.AssignBytes(nil)
2957 2958
}
func (_PBNode__ReprAssembler) AssignLink(ipld.Link) error {
2959
	return mixins.MapAssembler{TypeName: "dagpb.PBNode.Repr"}.AssignLink(nil)
2960
}
2961
func (na *_PBNode__ReprAssembler) AssignNode(v ipld.Node) error {
2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_PBNode); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		case midvalue:
			panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
		}
		if na.w == nil {
			na.w = v2
			*na.m = schema.Maybe_Value
			return nil
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
2981
	if v.Kind() != ipld.Kind_Map {
2982
		return ipld.ErrWrongKind{TypeName: "dagpb.PBNode.Repr", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()}
2983 2984 2985 2986 2987 2988 2989
	}
	itr := v.MapIterator()
	for !itr.Done() {
		k, v, err := itr.Next()
		if err != nil {
			return err
		}
2990
		if err := na.AssembleKey().AssignNode(k); err != nil {
2991 2992
			return err
		}
2993
		if err := na.AssembleValue().AssignNode(v); err != nil {
2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005
			return err
		}
	}
	return na.Finish()
}
func (_PBNode__ReprAssembler) Prototype() ipld.NodePrototype {
	return _PBNode__ReprPrototype{}
}
func (ma *_PBNode__ReprAssembler) valueFinishTidy() bool {
	switch ma.f {
	case 0:
		switch ma.cm {
3006 3007
		case schema.Maybe_Value:
			ma.cm = schema.Maybe_Absent
3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041
			ma.state = maState_initial
			return true
		default:
			return false
		}
	case 1:
		switch ma.w.Data.m {
		case schema.Maybe_Value:
			ma.state = maState_initial
			return true
		default:
			return false
		}
	default:
		panic("unreachable")
	}
}
func (ma *_PBNode__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, error) {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleEntry cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleEntry cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleEntry cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished")
	}
	switch k {
	case "Links":
3042 3043
		if ma.s&fieldBit__PBNode_Links != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Links_serial}
3044 3045 3046 3047 3048 3049 3050 3051
		}
		ma.s += fieldBit__PBNode_Links
		ma.state = maState_midValue
		ma.f = 0
		ma.ca_Links.w = &ma.w.Links
		ma.ca_Links.m = &ma.cm
		return &ma.ca_Links, nil
	case "Data":
3052 3053
		if ma.s&fieldBit__PBNode_Data != 0 {
			return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Data_serial}
3054 3055 3056 3057
		}
		ma.s += fieldBit__PBNode_Data
		ma.state = maState_midValue
		ma.f = 1
3058
		ma.ca_Data.w = &ma.w.Data.v
3059
		ma.ca_Data.m = &ma.w.Data.m
3060

3061 3062 3063
		return &ma.ca_Data, nil
	default:
	}
3064
	return nil, ipld.ErrInvalidKey{TypeName: "dagpb.PBNode.Repr", Key: &_String{k}}
3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103
}
func (ma *_PBNode__ReprAssembler) AssembleKey() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: AssembleKey cannot be called when in the middle of assembling another key")
	case maState_expectValue:
		panic("invalid state: AssembleKey cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: AssembleKey cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: AssembleKey cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midKey
	return (*_PBNode__ReprKeyAssembler)(ma)
}
func (ma *_PBNode__ReprAssembler) AssembleValue() ipld.NodeAssembler {
	switch ma.state {
	case maState_initial:
		panic("invalid state: AssembleValue cannot be called when no key is primed")
	case maState_midKey:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		// carry on
	case maState_midValue:
		panic("invalid state: AssembleValue cannot be called when in the middle of assembling another value")
	case maState_finished:
		panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
	}
	ma.state = maState_midValue
	switch ma.f {
	case 0:
		ma.ca_Links.w = &ma.w.Links
		ma.ca_Links.m = &ma.cm
		return &ma.ca_Links
	case 1:
3104
		ma.ca_Data.w = &ma.w.Data.v
3105
		ma.ca_Data.m = &ma.w.Data.m
3106

3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126
		return &ma.ca_Data
	default:
		panic("unreachable")
	}
}
func (ma *_PBNode__ReprAssembler) Finish() error {
	switch ma.state {
	case maState_initial:
		// carry on
	case maState_midKey:
		panic("invalid state: Finish cannot be called when in the middle of assembling a key")
	case maState_expectValue:
		panic("invalid state: Finish cannot be called when expecting start of value assembly")
	case maState_midValue:
		if !ma.valueFinishTidy() {
			panic("invalid state: Finish cannot be called when in the middle of assembling a value")
		} // if tidy success: carry on
	case maState_finished:
		panic("invalid state: Finish cannot be called on an assembler that's already finished")
	}
3127
	if ma.s&fieldBits__PBNode_sufficient != fieldBits__PBNode_sufficient {
3128
		err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
3129
		if ma.s&fieldBit__PBNode_Links == 0 {
3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143
			err.Missing = append(err.Missing, "Links")
		}
		return err
	}
	ma.state = maState_finished
	*ma.m = schema.Maybe_Value
	return nil
}
func (ma *_PBNode__ReprAssembler) KeyPrototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (ma *_PBNode__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype {
	panic("todo structbuilder mapassembler repr valueprototype")
}
3144

3145
type _PBNode__ReprKeyAssembler _PBNode__ReprAssembler
3146

3147
func (_PBNode__ReprKeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
3148
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.BeginMap(0)
3149
}
3150
func (_PBNode__ReprKeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
3151
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.BeginList(0)
3152 3153
}
func (na *_PBNode__ReprKeyAssembler) AssignNull() error {
3154
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.AssignNull()
3155 3156
}
func (_PBNode__ReprKeyAssembler) AssignBool(bool) error {
3157
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.AssignBool(false)
3158
}
3159
func (_PBNode__ReprKeyAssembler) AssignInt(int64) error {
3160
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.AssignInt(0)
3161 3162
}
func (_PBNode__ReprKeyAssembler) AssignFloat(float64) error {
3163
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.AssignFloat(0)
3164 3165 3166 3167 3168 3169 3170
}
func (ka *_PBNode__ReprKeyAssembler) AssignString(k string) error {
	if ka.state != maState_midKey {
		panic("misuse: KeyAssembler held beyond its valid lifetime")
	}
	switch k {
	case "Links":
3171 3172
		if ka.s&fieldBit__PBNode_Links != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Links_serial}
3173 3174 3175 3176
		}
		ka.s += fieldBit__PBNode_Links
		ka.state = maState_expectValue
		ka.f = 0
3177
		return nil
3178
	case "Data":
3179 3180
		if ka.s&fieldBit__PBNode_Data != 0 {
			return ipld.ErrRepeatedMapKey{Key: &fieldName__PBNode_Data_serial}
3181 3182 3183 3184
		}
		ka.s += fieldBit__PBNode_Data
		ka.state = maState_expectValue
		ka.f = 1
3185
		return nil
3186
	}
3187
	return ipld.ErrInvalidKey{TypeName: "dagpb.PBNode.Repr", Key: &_String{k}}
3188 3189
}
func (_PBNode__ReprKeyAssembler) AssignBytes([]byte) error {
3190
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.AssignBytes(nil)
3191 3192
}
func (_PBNode__ReprKeyAssembler) AssignLink(ipld.Link) error {
3193
	return mixins.StringAssembler{TypeName: "dagpb.PBNode.Repr.KeyAssembler"}.AssignLink(nil)
3194
}
3195
func (ka *_PBNode__ReprKeyAssembler) AssignNode(v ipld.Node) error {
3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216
	if v2, err := v.AsString(); err != nil {
		return err
	} else {
		return ka.AssignString(v2)
	}
}
func (_PBNode__ReprKeyAssembler) Prototype() ipld.NodePrototype {
	return _String__Prototype{}
}

func (n String) String() string {
	return n.x
}
func (_String__Prototype) fromString(w *_String, v string) error {
	*w = _String{v}
	return nil
}
func (_String__Prototype) FromString(v string) (String, error) {
	n := _String{v}
	return &n, nil
}
3217

3218 3219
type _String__Maybe struct {
	m schema.Maybe
3220
	v _String
3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234
}
type MaybeString = *_String__Maybe

func (m MaybeString) IsNull() bool {
	return m.m == schema.Maybe_Null
}
func (m MaybeString) IsAbsent() bool {
	return m.m == schema.Maybe_Absent
}
func (m MaybeString) Exists() bool {
	return m.m == schema.Maybe_Value
}
func (m MaybeString) AsNode() ipld.Node {
	switch m.m {
3235 3236 3237 3238 3239 3240 3241 3242
	case schema.Maybe_Absent:
		return ipld.Absent
	case schema.Maybe_Null:
		return ipld.Null
	case schema.Maybe_Value:
		return &m.v
	default:
		panic("unreachable")
3243 3244 3245 3246 3247 3248
	}
}
func (m MaybeString) Must() String {
	if !m.Exists() {
		panic("unbox of a maybe rejected")
	}
3249
	return &m.v
3250
}
3251

3252 3253
var _ ipld.Node = (String)(&_String{})
var _ schema.TypedNode = (String)(&_String{})
3254

3255 3256
func (String) Kind() ipld.Kind {
	return ipld.Kind_String
3257 3258
}
func (String) LookupByString(string) (ipld.Node, error) {
3259
	return mixins.String{TypeName: "dagpb.String"}.LookupByString("")
3260 3261
}
func (String) LookupByNode(ipld.Node) (ipld.Node, error) {
3262
	return mixins.String{TypeName: "dagpb.String"}.LookupByNode(nil)
3263
}
3264
func (String) LookupByIndex(idx int64) (ipld.Node, error) {
3265
	return mixins.String{TypeName: "dagpb.String"}.LookupByIndex(0)
3266 3267
}
func (String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
3268
	return mixins.String{TypeName: "dagpb.String"}.LookupBySegment(seg)
3269 3270 3271 3272 3273 3274 3275
}
func (String) MapIterator() ipld.MapIterator {
	return nil
}
func (String) ListIterator() ipld.ListIterator {
	return nil
}
3276
func (String) Length() int64 {
3277 3278 3279 3280 3281 3282 3283 3284 3285
	return -1
}
func (String) IsAbsent() bool {
	return false
}
func (String) IsNull() bool {
	return false
}
func (String) AsBool() (bool, error) {
3286
	return mixins.String{TypeName: "dagpb.String"}.AsBool()
3287
}
3288
func (String) AsInt() (int64, error) {
3289
	return mixins.String{TypeName: "dagpb.String"}.AsInt()
3290 3291
}
func (String) AsFloat() (float64, error) {
3292
	return mixins.String{TypeName: "dagpb.String"}.AsFloat()
3293 3294 3295 3296 3297
}
func (n String) AsString() (string, error) {
	return n.x, nil
}
func (String) AsBytes() ([]byte, error) {
3298
	return mixins.String{TypeName: "dagpb.String"}.AsBytes()
3299 3300
}
func (String) AsLink() (ipld.Link, error) {
3301
	return mixins.String{TypeName: "dagpb.String"}.AsLink()
3302 3303 3304 3305
}
func (String) Prototype() ipld.NodePrototype {
	return _String__Prototype{}
}
3306

3307 3308 3309 3310 3311 3312 3313
type _String__Prototype struct{}

func (_String__Prototype) NewBuilder() ipld.NodeBuilder {
	var nb _String__Builder
	nb.Reset()
	return &nb
}
3314

3315 3316 3317
type _String__Builder struct {
	_String__Assembler
}
3318

3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329
func (nb *_String__Builder) Build() ipld.Node {
	if *nb.m != schema.Maybe_Value {
		panic("invalid state: cannot call Build on an assembler that's not finished")
	}
	return nb.w
}
func (nb *_String__Builder) Reset() {
	var w _String
	var m schema.Maybe
	*nb = _String__Builder{_String__Assembler{w: &w, m: &m}}
}
3330

3331 3332 3333 3334 3335 3336
type _String__Assembler struct {
	w *_String
	m *schema.Maybe
}

func (na *_String__Assembler) reset() {}
3337
func (_String__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
3338
	return mixins.StringAssembler{TypeName: "dagpb.String"}.BeginMap(0)
3339
}
3340
func (_String__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
3341
	return mixins.StringAssembler{TypeName: "dagpb.String"}.BeginList(0)
3342 3343 3344 3345 3346 3347 3348
}
func (na *_String__Assembler) AssignNull() error {
	switch *na.m {
	case allowNull:
		*na.m = schema.Maybe_Null
		return nil
	case schema.Maybe_Absent:
3349
		return mixins.StringAssembler{TypeName: "dagpb.String"}.AssignNull()
3350 3351 3352 3353 3354 3355
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	panic("unreachable")
}
func (_String__Assembler) AssignBool(bool) error {
3356
	return mixins.StringAssembler{TypeName: "dagpb.String"}.AssignBool(false)
3357
}
3358
func (_String__Assembler) AssignInt(int64) error {
3359
	return mixins.StringAssembler{TypeName: "dagpb.String"}.AssignInt(0)
3360 3361
}
func (_String__Assembler) AssignFloat(float64) error {
3362
	return mixins.StringAssembler{TypeName: "dagpb.String"}.AssignFloat(0)
3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373
}
func (na *_String__Assembler) AssignString(v string) error {
	switch *na.m {
	case schema.Maybe_Value, schema.Maybe_Null:
		panic("invalid state: cannot assign into assembler that's already finished")
	}
	na.w.x = v
	*na.m = schema.Maybe_Value
	return nil
}
func (_String__Assembler) AssignBytes([]byte) error {
3374
	return mixins.StringAssembler{TypeName: "dagpb.String"}.AssignBytes(nil)
3375 3376
}
func (_String__Assembler) AssignLink(ipld.Link) error {
3377
	return mixins.StringAssembler{TypeName: "dagpb.String"}.AssignLink(nil)
3378
}
3379
func (na *_String__Assembler) AssignNode(v ipld.Node) error {
3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406
	if v.IsNull() {
		return na.AssignNull()
	}
	if v2, ok := v.(*_String); ok {
		switch *na.m {
		case schema.Maybe_Value, schema.Maybe_Null:
			panic("invalid state: cannot assign into assembler that's already finished")
		}
		*na.w = *v2
		*na.m = schema.Maybe_Value
		return nil
	}
	if v2, err := v.AsString(); err != nil {
		return err
	} else {
		return na.AssignString(v2)
	}
}
func (_String__Assembler) Prototype() ipld.NodePrototype {
	return _String__Prototype{}
}
func (String) Type() schema.Type {
	return nil /*TODO:typelit*/
}
func (n String) Representation() ipld.Node {
	return (*_String__Repr)(n)
}
3407

3408
type _String__Repr = _String
3409

3410
var _ ipld.Node = &_String__Repr{}
3411

3412 3413
type _String__ReprPrototype = _String__Prototype
type _String__ReprAssembler = _String__Assembler