forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 3package tangled 4 5import ( 6 "fmt" 7 "io" 8 "math" 9 "sort" 10 11 cid "github.com/ipfs/go-cid" 12 cbg "github.com/whyrusleeping/cbor-gen" 13 xerrors "golang.org/x/xerrors" 14) 15 16var _ = xerrors.Errorf 17var _ = cid.Undef 18var _ = math.E 19var _ = sort.Sort 20 21func (t *FeedStar) MarshalCBOR(w io.Writer) error { 22 if t == nil { 23 _, err := w.Write(cbg.CborNull) 24 return err 25 } 26 27 cw := cbg.NewCborWriter(w) 28 29 if _, err := cw.Write([]byte{163}); err != nil { 30 return err 31 } 32 33 // t.LexiconTypeID (string) (string) 34 if len("$type") > 1000000 { 35 return xerrors.Errorf("Value in field \"$type\" was too long") 36 } 37 38 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 39 return err 40 } 41 if _, err := cw.WriteString(string("$type")); err != nil { 42 return err 43 } 44 45 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.feed.star"))); err != nil { 46 return err 47 } 48 if _, err := cw.WriteString(string("sh.tangled.feed.star")); err != nil { 49 return err 50 } 51 52 // t.Subject (string) (string) 53 if len("subject") > 1000000 { 54 return xerrors.Errorf("Value in field \"subject\" was too long") 55 } 56 57 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 58 return err 59 } 60 if _, err := cw.WriteString(string("subject")); err != nil { 61 return err 62 } 63 64 if len(t.Subject) > 1000000 { 65 return xerrors.Errorf("Value in field t.Subject was too long") 66 } 67 68 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { 69 return err 70 } 71 if _, err := cw.WriteString(string(t.Subject)); err != nil { 72 return err 73 } 74 75 // t.CreatedAt (string) (string) 76 if len("createdAt") > 1000000 { 77 return xerrors.Errorf("Value in field \"createdAt\" was too long") 78 } 79 80 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 81 return err 82 } 83 if _, err := cw.WriteString(string("createdAt")); err != nil { 84 return err 85 } 86 87 if len(t.CreatedAt) > 1000000 { 88 return xerrors.Errorf("Value in field t.CreatedAt was too long") 89 } 90 91 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 92 return err 93 } 94 if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 95 return err 96 } 97 return nil 98} 99 100func (t *FeedStar) UnmarshalCBOR(r io.Reader) (err error) { 101 *t = FeedStar{} 102 103 cr := cbg.NewCborReader(r) 104 105 maj, extra, err := cr.ReadHeader() 106 if err != nil { 107 return err 108 } 109 defer func() { 110 if err == io.EOF { 111 err = io.ErrUnexpectedEOF 112 } 113 }() 114 115 if maj != cbg.MajMap { 116 return fmt.Errorf("cbor input should be of type map") 117 } 118 119 if extra > cbg.MaxLength { 120 return fmt.Errorf("FeedStar: map struct too large (%d)", extra) 121 } 122 123 n := extra 124 125 nameBuf := make([]byte, 9) 126 for i := uint64(0); i < n; i++ { 127 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 128 if err != nil { 129 return err 130 } 131 132 if !ok { 133 // Field doesn't exist on this type, so ignore it 134 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 135 return err 136 } 137 continue 138 } 139 140 switch string(nameBuf[:nameLen]) { 141 // t.LexiconTypeID (string) (string) 142 case "$type": 143 144 { 145 sval, err := cbg.ReadStringWithMax(cr, 1000000) 146 if err != nil { 147 return err 148 } 149 150 t.LexiconTypeID = string(sval) 151 } 152 // t.Subject (string) (string) 153 case "subject": 154 155 { 156 sval, err := cbg.ReadStringWithMax(cr, 1000000) 157 if err != nil { 158 return err 159 } 160 161 t.Subject = string(sval) 162 } 163 // t.CreatedAt (string) (string) 164 case "createdAt": 165 166 { 167 sval, err := cbg.ReadStringWithMax(cr, 1000000) 168 if err != nil { 169 return err 170 } 171 172 t.CreatedAt = string(sval) 173 } 174 175 default: 176 // Field doesn't exist on this type, so ignore it 177 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 178 return err 179 } 180 } 181 } 182 183 return nil 184} 185func (t *GraphFollow) MarshalCBOR(w io.Writer) error { 186 if t == nil { 187 _, err := w.Write(cbg.CborNull) 188 return err 189 } 190 191 cw := cbg.NewCborWriter(w) 192 193 if _, err := cw.Write([]byte{163}); err != nil { 194 return err 195 } 196 197 // t.LexiconTypeID (string) (string) 198 if len("$type") > 1000000 { 199 return xerrors.Errorf("Value in field \"$type\" was too long") 200 } 201 202 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 203 return err 204 } 205 if _, err := cw.WriteString(string("$type")); err != nil { 206 return err 207 } 208 209 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.graph.follow"))); err != nil { 210 return err 211 } 212 if _, err := cw.WriteString(string("sh.tangled.graph.follow")); err != nil { 213 return err 214 } 215 216 // t.Subject (string) (string) 217 if len("subject") > 1000000 { 218 return xerrors.Errorf("Value in field \"subject\" was too long") 219 } 220 221 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 222 return err 223 } 224 if _, err := cw.WriteString(string("subject")); err != nil { 225 return err 226 } 227 228 if len(t.Subject) > 1000000 { 229 return xerrors.Errorf("Value in field t.Subject was too long") 230 } 231 232 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { 233 return err 234 } 235 if _, err := cw.WriteString(string(t.Subject)); err != nil { 236 return err 237 } 238 239 // t.CreatedAt (string) (string) 240 if len("createdAt") > 1000000 { 241 return xerrors.Errorf("Value in field \"createdAt\" was too long") 242 } 243 244 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 245 return err 246 } 247 if _, err := cw.WriteString(string("createdAt")); err != nil { 248 return err 249 } 250 251 if len(t.CreatedAt) > 1000000 { 252 return xerrors.Errorf("Value in field t.CreatedAt was too long") 253 } 254 255 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 256 return err 257 } 258 if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 259 return err 260 } 261 return nil 262} 263 264func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { 265 *t = GraphFollow{} 266 267 cr := cbg.NewCborReader(r) 268 269 maj, extra, err := cr.ReadHeader() 270 if err != nil { 271 return err 272 } 273 defer func() { 274 if err == io.EOF { 275 err = io.ErrUnexpectedEOF 276 } 277 }() 278 279 if maj != cbg.MajMap { 280 return fmt.Errorf("cbor input should be of type map") 281 } 282 283 if extra > cbg.MaxLength { 284 return fmt.Errorf("GraphFollow: map struct too large (%d)", extra) 285 } 286 287 n := extra 288 289 nameBuf := make([]byte, 9) 290 for i := uint64(0); i < n; i++ { 291 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 292 if err != nil { 293 return err 294 } 295 296 if !ok { 297 // Field doesn't exist on this type, so ignore it 298 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 299 return err 300 } 301 continue 302 } 303 304 switch string(nameBuf[:nameLen]) { 305 // t.LexiconTypeID (string) (string) 306 case "$type": 307 308 { 309 sval, err := cbg.ReadStringWithMax(cr, 1000000) 310 if err != nil { 311 return err 312 } 313 314 t.LexiconTypeID = string(sval) 315 } 316 // t.Subject (string) (string) 317 case "subject": 318 319 { 320 sval, err := cbg.ReadStringWithMax(cr, 1000000) 321 if err != nil { 322 return err 323 } 324 325 t.Subject = string(sval) 326 } 327 // t.CreatedAt (string) (string) 328 case "createdAt": 329 330 { 331 sval, err := cbg.ReadStringWithMax(cr, 1000000) 332 if err != nil { 333 return err 334 } 335 336 t.CreatedAt = string(sval) 337 } 338 339 default: 340 // Field doesn't exist on this type, so ignore it 341 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 342 return err 343 } 344 } 345 } 346 347 return nil 348} 349func (t *KnotMember) MarshalCBOR(w io.Writer) error { 350 if t == nil { 351 _, err := w.Write(cbg.CborNull) 352 return err 353 } 354 355 cw := cbg.NewCborWriter(w) 356 fieldCount := 4 357 358 if t.AddedAt == nil { 359 fieldCount-- 360 } 361 362 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 363 return err 364 } 365 366 // t.LexiconTypeID (string) (string) 367 if len("$type") > 1000000 { 368 return xerrors.Errorf("Value in field \"$type\" was too long") 369 } 370 371 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 372 return err 373 } 374 if _, err := cw.WriteString(string("$type")); err != nil { 375 return err 376 } 377 378 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.knot.member"))); err != nil { 379 return err 380 } 381 if _, err := cw.WriteString(string("sh.tangled.knot.member")); err != nil { 382 return err 383 } 384 385 // t.Domain (string) (string) 386 if len("domain") > 1000000 { 387 return xerrors.Errorf("Value in field \"domain\" was too long") 388 } 389 390 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("domain"))); err != nil { 391 return err 392 } 393 if _, err := cw.WriteString(string("domain")); err != nil { 394 return err 395 } 396 397 if len(t.Domain) > 1000000 { 398 return xerrors.Errorf("Value in field t.Domain was too long") 399 } 400 401 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Domain))); err != nil { 402 return err 403 } 404 if _, err := cw.WriteString(string(t.Domain)); err != nil { 405 return err 406 } 407 408 // t.Member (string) (string) 409 if len("member") > 1000000 { 410 return xerrors.Errorf("Value in field \"member\" was too long") 411 } 412 413 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("member"))); err != nil { 414 return err 415 } 416 if _, err := cw.WriteString(string("member")); err != nil { 417 return err 418 } 419 420 if len(t.Member) > 1000000 { 421 return xerrors.Errorf("Value in field t.Member was too long") 422 } 423 424 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Member))); err != nil { 425 return err 426 } 427 if _, err := cw.WriteString(string(t.Member)); err != nil { 428 return err 429 } 430 431 // t.AddedAt (string) (string) 432 if t.AddedAt != nil { 433 434 if len("addedAt") > 1000000 { 435 return xerrors.Errorf("Value in field \"addedAt\" was too long") 436 } 437 438 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("addedAt"))); err != nil { 439 return err 440 } 441 if _, err := cw.WriteString(string("addedAt")); err != nil { 442 return err 443 } 444 445 if t.AddedAt == nil { 446 if _, err := cw.Write(cbg.CborNull); err != nil { 447 return err 448 } 449 } else { 450 if len(*t.AddedAt) > 1000000 { 451 return xerrors.Errorf("Value in field t.AddedAt was too long") 452 } 453 454 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.AddedAt))); err != nil { 455 return err 456 } 457 if _, err := cw.WriteString(string(*t.AddedAt)); err != nil { 458 return err 459 } 460 } 461 } 462 return nil 463} 464 465func (t *KnotMember) UnmarshalCBOR(r io.Reader) (err error) { 466 *t = KnotMember{} 467 468 cr := cbg.NewCborReader(r) 469 470 maj, extra, err := cr.ReadHeader() 471 if err != nil { 472 return err 473 } 474 defer func() { 475 if err == io.EOF { 476 err = io.ErrUnexpectedEOF 477 } 478 }() 479 480 if maj != cbg.MajMap { 481 return fmt.Errorf("cbor input should be of type map") 482 } 483 484 if extra > cbg.MaxLength { 485 return fmt.Errorf("KnotMember: map struct too large (%d)", extra) 486 } 487 488 n := extra 489 490 nameBuf := make([]byte, 7) 491 for i := uint64(0); i < n; i++ { 492 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 493 if err != nil { 494 return err 495 } 496 497 if !ok { 498 // Field doesn't exist on this type, so ignore it 499 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 500 return err 501 } 502 continue 503 } 504 505 switch string(nameBuf[:nameLen]) { 506 // t.LexiconTypeID (string) (string) 507 case "$type": 508 509 { 510 sval, err := cbg.ReadStringWithMax(cr, 1000000) 511 if err != nil { 512 return err 513 } 514 515 t.LexiconTypeID = string(sval) 516 } 517 // t.Domain (string) (string) 518 case "domain": 519 520 { 521 sval, err := cbg.ReadStringWithMax(cr, 1000000) 522 if err != nil { 523 return err 524 } 525 526 t.Domain = string(sval) 527 } 528 // t.Member (string) (string) 529 case "member": 530 531 { 532 sval, err := cbg.ReadStringWithMax(cr, 1000000) 533 if err != nil { 534 return err 535 } 536 537 t.Member = string(sval) 538 } 539 // t.AddedAt (string) (string) 540 case "addedAt": 541 542 { 543 b, err := cr.ReadByte() 544 if err != nil { 545 return err 546 } 547 if b != cbg.CborNull[0] { 548 if err := cr.UnreadByte(); err != nil { 549 return err 550 } 551 552 sval, err := cbg.ReadStringWithMax(cr, 1000000) 553 if err != nil { 554 return err 555 } 556 557 t.AddedAt = (*string)(&sval) 558 } 559 } 560 561 default: 562 // Field doesn't exist on this type, so ignore it 563 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 564 return err 565 } 566 } 567 } 568 569 return nil 570} 571func (t *PublicKey) MarshalCBOR(w io.Writer) error { 572 if t == nil { 573 _, err := w.Write(cbg.CborNull) 574 return err 575 } 576 577 cw := cbg.NewCborWriter(w) 578 579 if _, err := cw.Write([]byte{164}); err != nil { 580 return err 581 } 582 583 // t.Key (string) (string) 584 if len("key") > 1000000 { 585 return xerrors.Errorf("Value in field \"key\" was too long") 586 } 587 588 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { 589 return err 590 } 591 if _, err := cw.WriteString(string("key")); err != nil { 592 return err 593 } 594 595 if len(t.Key) > 1000000 { 596 return xerrors.Errorf("Value in field t.Key was too long") 597 } 598 599 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { 600 return err 601 } 602 if _, err := cw.WriteString(string(t.Key)); err != nil { 603 return err 604 } 605 606 // t.Name (string) (string) 607 if len("name") > 1000000 { 608 return xerrors.Errorf("Value in field \"name\" was too long") 609 } 610 611 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { 612 return err 613 } 614 if _, err := cw.WriteString(string("name")); err != nil { 615 return err 616 } 617 618 if len(t.Name) > 1000000 { 619 return xerrors.Errorf("Value in field t.Name was too long") 620 } 621 622 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { 623 return err 624 } 625 if _, err := cw.WriteString(string(t.Name)); err != nil { 626 return err 627 } 628 629 // t.LexiconTypeID (string) (string) 630 if len("$type") > 1000000 { 631 return xerrors.Errorf("Value in field \"$type\" was too long") 632 } 633 634 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 635 return err 636 } 637 if _, err := cw.WriteString(string("$type")); err != nil { 638 return err 639 } 640 641 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.publicKey"))); err != nil { 642 return err 643 } 644 if _, err := cw.WriteString(string("sh.tangled.publicKey")); err != nil { 645 return err 646 } 647 648 // t.Created (string) (string) 649 if len("created") > 1000000 { 650 return xerrors.Errorf("Value in field \"created\" was too long") 651 } 652 653 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("created"))); err != nil { 654 return err 655 } 656 if _, err := cw.WriteString(string("created")); err != nil { 657 return err 658 } 659 660 if len(t.Created) > 1000000 { 661 return xerrors.Errorf("Value in field t.Created was too long") 662 } 663 664 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Created))); err != nil { 665 return err 666 } 667 if _, err := cw.WriteString(string(t.Created)); err != nil { 668 return err 669 } 670 return nil 671} 672 673func (t *PublicKey) UnmarshalCBOR(r io.Reader) (err error) { 674 *t = PublicKey{} 675 676 cr := cbg.NewCborReader(r) 677 678 maj, extra, err := cr.ReadHeader() 679 if err != nil { 680 return err 681 } 682 defer func() { 683 if err == io.EOF { 684 err = io.ErrUnexpectedEOF 685 } 686 }() 687 688 if maj != cbg.MajMap { 689 return fmt.Errorf("cbor input should be of type map") 690 } 691 692 if extra > cbg.MaxLength { 693 return fmt.Errorf("PublicKey: map struct too large (%d)", extra) 694 } 695 696 n := extra 697 698 nameBuf := make([]byte, 7) 699 for i := uint64(0); i < n; i++ { 700 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 701 if err != nil { 702 return err 703 } 704 705 if !ok { 706 // Field doesn't exist on this type, so ignore it 707 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 708 return err 709 } 710 continue 711 } 712 713 switch string(nameBuf[:nameLen]) { 714 // t.Key (string) (string) 715 case "key": 716 717 { 718 sval, err := cbg.ReadStringWithMax(cr, 1000000) 719 if err != nil { 720 return err 721 } 722 723 t.Key = string(sval) 724 } 725 // t.Name (string) (string) 726 case "name": 727 728 { 729 sval, err := cbg.ReadStringWithMax(cr, 1000000) 730 if err != nil { 731 return err 732 } 733 734 t.Name = string(sval) 735 } 736 // t.LexiconTypeID (string) (string) 737 case "$type": 738 739 { 740 sval, err := cbg.ReadStringWithMax(cr, 1000000) 741 if err != nil { 742 return err 743 } 744 745 t.LexiconTypeID = string(sval) 746 } 747 // t.Created (string) (string) 748 case "created": 749 750 { 751 sval, err := cbg.ReadStringWithMax(cr, 1000000) 752 if err != nil { 753 return err 754 } 755 756 t.Created = string(sval) 757 } 758 759 default: 760 // Field doesn't exist on this type, so ignore it 761 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 762 return err 763 } 764 } 765 } 766 767 return nil 768} 769func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { 770 if t == nil { 771 _, err := w.Write(cbg.CborNull) 772 return err 773 } 774 775 cw := cbg.NewCborWriter(w) 776 fieldCount := 7 777 778 if t.Body == nil { 779 fieldCount-- 780 } 781 782 if t.CommentId == nil { 783 fieldCount-- 784 } 785 786 if t.CreatedAt == nil { 787 fieldCount-- 788 } 789 790 if t.Owner == nil { 791 fieldCount-- 792 } 793 794 if t.Repo == nil { 795 fieldCount-- 796 } 797 798 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 799 return err 800 } 801 802 // t.Body (string) (string) 803 if t.Body != nil { 804 805 if len("body") > 1000000 { 806 return xerrors.Errorf("Value in field \"body\" was too long") 807 } 808 809 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { 810 return err 811 } 812 if _, err := cw.WriteString(string("body")); err != nil { 813 return err 814 } 815 816 if t.Body == nil { 817 if _, err := cw.Write(cbg.CborNull); err != nil { 818 return err 819 } 820 } else { 821 if len(*t.Body) > 1000000 { 822 return xerrors.Errorf("Value in field t.Body was too long") 823 } 824 825 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { 826 return err 827 } 828 if _, err := cw.WriteString(string(*t.Body)); err != nil { 829 return err 830 } 831 } 832 } 833 834 // t.Repo (string) (string) 835 if t.Repo != nil { 836 837 if len("repo") > 1000000 { 838 return xerrors.Errorf("Value in field \"repo\" was too long") 839 } 840 841 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 842 return err 843 } 844 if _, err := cw.WriteString(string("repo")); err != nil { 845 return err 846 } 847 848 if t.Repo == nil { 849 if _, err := cw.Write(cbg.CborNull); err != nil { 850 return err 851 } 852 } else { 853 if len(*t.Repo) > 1000000 { 854 return xerrors.Errorf("Value in field t.Repo was too long") 855 } 856 857 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { 858 return err 859 } 860 if _, err := cw.WriteString(string(*t.Repo)); err != nil { 861 return err 862 } 863 } 864 } 865 866 // t.LexiconTypeID (string) (string) 867 if len("$type") > 1000000 { 868 return xerrors.Errorf("Value in field \"$type\" was too long") 869 } 870 871 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 872 return err 873 } 874 if _, err := cw.WriteString(string("$type")); err != nil { 875 return err 876 } 877 878 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.comment"))); err != nil { 879 return err 880 } 881 if _, err := cw.WriteString(string("sh.tangled.repo.issue.comment")); err != nil { 882 return err 883 } 884 885 // t.Issue (string) (string) 886 if len("issue") > 1000000 { 887 return xerrors.Errorf("Value in field \"issue\" was too long") 888 } 889 890 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { 891 return err 892 } 893 if _, err := cw.WriteString(string("issue")); err != nil { 894 return err 895 } 896 897 if len(t.Issue) > 1000000 { 898 return xerrors.Errorf("Value in field t.Issue was too long") 899 } 900 901 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { 902 return err 903 } 904 if _, err := cw.WriteString(string(t.Issue)); err != nil { 905 return err 906 } 907 908 // t.Owner (string) (string) 909 if t.Owner != nil { 910 911 if len("owner") > 1000000 { 912 return xerrors.Errorf("Value in field \"owner\" was too long") 913 } 914 915 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 916 return err 917 } 918 if _, err := cw.WriteString(string("owner")); err != nil { 919 return err 920 } 921 922 if t.Owner == nil { 923 if _, err := cw.Write(cbg.CborNull); err != nil { 924 return err 925 } 926 } else { 927 if len(*t.Owner) > 1000000 { 928 return xerrors.Errorf("Value in field t.Owner was too long") 929 } 930 931 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Owner))); err != nil { 932 return err 933 } 934 if _, err := cw.WriteString(string(*t.Owner)); err != nil { 935 return err 936 } 937 } 938 } 939 940 // t.CommentId (int64) (int64) 941 if t.CommentId != nil { 942 943 if len("commentId") > 1000000 { 944 return xerrors.Errorf("Value in field \"commentId\" was too long") 945 } 946 947 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commentId"))); err != nil { 948 return err 949 } 950 if _, err := cw.WriteString(string("commentId")); err != nil { 951 return err 952 } 953 954 if t.CommentId == nil { 955 if _, err := cw.Write(cbg.CborNull); err != nil { 956 return err 957 } 958 } else { 959 if *t.CommentId >= 0 { 960 if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.CommentId)); err != nil { 961 return err 962 } 963 } else { 964 if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.CommentId-1)); err != nil { 965 return err 966 } 967 } 968 } 969 970 } 971 972 // t.CreatedAt (string) (string) 973 if t.CreatedAt != nil { 974 975 if len("createdAt") > 1000000 { 976 return xerrors.Errorf("Value in field \"createdAt\" was too long") 977 } 978 979 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 980 return err 981 } 982 if _, err := cw.WriteString(string("createdAt")); err != nil { 983 return err 984 } 985 986 if t.CreatedAt == nil { 987 if _, err := cw.Write(cbg.CborNull); err != nil { 988 return err 989 } 990 } else { 991 if len(*t.CreatedAt) > 1000000 { 992 return xerrors.Errorf("Value in field t.CreatedAt was too long") 993 } 994 995 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CreatedAt))); err != nil { 996 return err 997 } 998 if _, err := cw.WriteString(string(*t.CreatedAt)); err != nil { 999 return err 1000 } 1001 } 1002 } 1003 return nil 1004} 1005 1006func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { 1007 *t = RepoIssueComment{} 1008 1009 cr := cbg.NewCborReader(r) 1010 1011 maj, extra, err := cr.ReadHeader() 1012 if err != nil { 1013 return err 1014 } 1015 defer func() { 1016 if err == io.EOF { 1017 err = io.ErrUnexpectedEOF 1018 } 1019 }() 1020 1021 if maj != cbg.MajMap { 1022 return fmt.Errorf("cbor input should be of type map") 1023 } 1024 1025 if extra > cbg.MaxLength { 1026 return fmt.Errorf("RepoIssueComment: map struct too large (%d)", extra) 1027 } 1028 1029 n := extra 1030 1031 nameBuf := make([]byte, 9) 1032 for i := uint64(0); i < n; i++ { 1033 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1034 if err != nil { 1035 return err 1036 } 1037 1038 if !ok { 1039 // Field doesn't exist on this type, so ignore it 1040 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1041 return err 1042 } 1043 continue 1044 } 1045 1046 switch string(nameBuf[:nameLen]) { 1047 // t.Body (string) (string) 1048 case "body": 1049 1050 { 1051 b, err := cr.ReadByte() 1052 if err != nil { 1053 return err 1054 } 1055 if b != cbg.CborNull[0] { 1056 if err := cr.UnreadByte(); err != nil { 1057 return err 1058 } 1059 1060 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1061 if err != nil { 1062 return err 1063 } 1064 1065 t.Body = (*string)(&sval) 1066 } 1067 } 1068 // t.Repo (string) (string) 1069 case "repo": 1070 1071 { 1072 b, err := cr.ReadByte() 1073 if err != nil { 1074 return err 1075 } 1076 if b != cbg.CborNull[0] { 1077 if err := cr.UnreadByte(); err != nil { 1078 return err 1079 } 1080 1081 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1082 if err != nil { 1083 return err 1084 } 1085 1086 t.Repo = (*string)(&sval) 1087 } 1088 } 1089 // t.LexiconTypeID (string) (string) 1090 case "$type": 1091 1092 { 1093 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1094 if err != nil { 1095 return err 1096 } 1097 1098 t.LexiconTypeID = string(sval) 1099 } 1100 // t.Issue (string) (string) 1101 case "issue": 1102 1103 { 1104 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1105 if err != nil { 1106 return err 1107 } 1108 1109 t.Issue = string(sval) 1110 } 1111 // t.Owner (string) (string) 1112 case "owner": 1113 1114 { 1115 b, err := cr.ReadByte() 1116 if err != nil { 1117 return err 1118 } 1119 if b != cbg.CborNull[0] { 1120 if err := cr.UnreadByte(); err != nil { 1121 return err 1122 } 1123 1124 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1125 if err != nil { 1126 return err 1127 } 1128 1129 t.Owner = (*string)(&sval) 1130 } 1131 } 1132 // t.CommentId (int64) (int64) 1133 case "commentId": 1134 { 1135 1136 b, err := cr.ReadByte() 1137 if err != nil { 1138 return err 1139 } 1140 if b != cbg.CborNull[0] { 1141 if err := cr.UnreadByte(); err != nil { 1142 return err 1143 } 1144 maj, extra, err := cr.ReadHeader() 1145 if err != nil { 1146 return err 1147 } 1148 var extraI int64 1149 switch maj { 1150 case cbg.MajUnsignedInt: 1151 extraI = int64(extra) 1152 if extraI < 0 { 1153 return fmt.Errorf("int64 positive overflow") 1154 } 1155 case cbg.MajNegativeInt: 1156 extraI = int64(extra) 1157 if extraI < 0 { 1158 return fmt.Errorf("int64 negative overflow") 1159 } 1160 extraI = -1 - extraI 1161 default: 1162 return fmt.Errorf("wrong type for int64 field: %d", maj) 1163 } 1164 1165 t.CommentId = (*int64)(&extraI) 1166 } 1167 } 1168 // t.CreatedAt (string) (string) 1169 case "createdAt": 1170 1171 { 1172 b, err := cr.ReadByte() 1173 if err != nil { 1174 return err 1175 } 1176 if b != cbg.CborNull[0] { 1177 if err := cr.UnreadByte(); err != nil { 1178 return err 1179 } 1180 1181 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1182 if err != nil { 1183 return err 1184 } 1185 1186 t.CreatedAt = (*string)(&sval) 1187 } 1188 } 1189 1190 default: 1191 // Field doesn't exist on this type, so ignore it 1192 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 1193 return err 1194 } 1195 } 1196 } 1197 1198 return nil 1199} 1200func (t *RepoIssueState) MarshalCBOR(w io.Writer) error { 1201 if t == nil { 1202 _, err := w.Write(cbg.CborNull) 1203 return err 1204 } 1205 1206 cw := cbg.NewCborWriter(w) 1207 fieldCount := 3 1208 1209 if t.State == nil { 1210 fieldCount-- 1211 } 1212 1213 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 1214 return err 1215 } 1216 1217 // t.LexiconTypeID (string) (string) 1218 if len("$type") > 1000000 { 1219 return xerrors.Errorf("Value in field \"$type\" was too long") 1220 } 1221 1222 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 1223 return err 1224 } 1225 if _, err := cw.WriteString(string("$type")); err != nil { 1226 return err 1227 } 1228 1229 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.state"))); err != nil { 1230 return err 1231 } 1232 if _, err := cw.WriteString(string("sh.tangled.repo.issue.state")); err != nil { 1233 return err 1234 } 1235 1236 // t.Issue (string) (string) 1237 if len("issue") > 1000000 { 1238 return xerrors.Errorf("Value in field \"issue\" was too long") 1239 } 1240 1241 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { 1242 return err 1243 } 1244 if _, err := cw.WriteString(string("issue")); err != nil { 1245 return err 1246 } 1247 1248 if len(t.Issue) > 1000000 { 1249 return xerrors.Errorf("Value in field t.Issue was too long") 1250 } 1251 1252 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { 1253 return err 1254 } 1255 if _, err := cw.WriteString(string(t.Issue)); err != nil { 1256 return err 1257 } 1258 1259 // t.State (string) (string) 1260 if t.State != nil { 1261 1262 if len("state") > 1000000 { 1263 return xerrors.Errorf("Value in field \"state\" was too long") 1264 } 1265 1266 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil { 1267 return err 1268 } 1269 if _, err := cw.WriteString(string("state")); err != nil { 1270 return err 1271 } 1272 1273 if t.State == nil { 1274 if _, err := cw.Write(cbg.CborNull); err != nil { 1275 return err 1276 } 1277 } else { 1278 if len(*t.State) > 1000000 { 1279 return xerrors.Errorf("Value in field t.State was too long") 1280 } 1281 1282 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.State))); err != nil { 1283 return err 1284 } 1285 if _, err := cw.WriteString(string(*t.State)); err != nil { 1286 return err 1287 } 1288 } 1289 } 1290 return nil 1291} 1292 1293func (t *RepoIssueState) UnmarshalCBOR(r io.Reader) (err error) { 1294 *t = RepoIssueState{} 1295 1296 cr := cbg.NewCborReader(r) 1297 1298 maj, extra, err := cr.ReadHeader() 1299 if err != nil { 1300 return err 1301 } 1302 defer func() { 1303 if err == io.EOF { 1304 err = io.ErrUnexpectedEOF 1305 } 1306 }() 1307 1308 if maj != cbg.MajMap { 1309 return fmt.Errorf("cbor input should be of type map") 1310 } 1311 1312 if extra > cbg.MaxLength { 1313 return fmt.Errorf("RepoIssueState: map struct too large (%d)", extra) 1314 } 1315 1316 n := extra 1317 1318 nameBuf := make([]byte, 5) 1319 for i := uint64(0); i < n; i++ { 1320 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1321 if err != nil { 1322 return err 1323 } 1324 1325 if !ok { 1326 // Field doesn't exist on this type, so ignore it 1327 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1328 return err 1329 } 1330 continue 1331 } 1332 1333 switch string(nameBuf[:nameLen]) { 1334 // t.LexiconTypeID (string) (string) 1335 case "$type": 1336 1337 { 1338 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1339 if err != nil { 1340 return err 1341 } 1342 1343 t.LexiconTypeID = string(sval) 1344 } 1345 // t.Issue (string) (string) 1346 case "issue": 1347 1348 { 1349 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1350 if err != nil { 1351 return err 1352 } 1353 1354 t.Issue = string(sval) 1355 } 1356 // t.State (string) (string) 1357 case "state": 1358 1359 { 1360 b, err := cr.ReadByte() 1361 if err != nil { 1362 return err 1363 } 1364 if b != cbg.CborNull[0] { 1365 if err := cr.UnreadByte(); err != nil { 1366 return err 1367 } 1368 1369 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1370 if err != nil { 1371 return err 1372 } 1373 1374 t.State = (*string)(&sval) 1375 } 1376 } 1377 1378 default: 1379 // Field doesn't exist on this type, so ignore it 1380 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 1381 return err 1382 } 1383 } 1384 } 1385 1386 return nil 1387} 1388func (t *RepoIssue) MarshalCBOR(w io.Writer) error { 1389 if t == nil { 1390 _, err := w.Write(cbg.CborNull) 1391 return err 1392 } 1393 1394 cw := cbg.NewCborWriter(w) 1395 fieldCount := 7 1396 1397 if t.Body == nil { 1398 fieldCount-- 1399 } 1400 1401 if t.CreatedAt == nil { 1402 fieldCount-- 1403 } 1404 1405 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 1406 return err 1407 } 1408 1409 // t.Body (string) (string) 1410 if t.Body != nil { 1411 1412 if len("body") > 1000000 { 1413 return xerrors.Errorf("Value in field \"body\" was too long") 1414 } 1415 1416 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { 1417 return err 1418 } 1419 if _, err := cw.WriteString(string("body")); err != nil { 1420 return err 1421 } 1422 1423 if t.Body == nil { 1424 if _, err := cw.Write(cbg.CborNull); err != nil { 1425 return err 1426 } 1427 } else { 1428 if len(*t.Body) > 1000000 { 1429 return xerrors.Errorf("Value in field t.Body was too long") 1430 } 1431 1432 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { 1433 return err 1434 } 1435 if _, err := cw.WriteString(string(*t.Body)); err != nil { 1436 return err 1437 } 1438 } 1439 } 1440 1441 // t.Repo (string) (string) 1442 if len("repo") > 1000000 { 1443 return xerrors.Errorf("Value in field \"repo\" was too long") 1444 } 1445 1446 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 1447 return err 1448 } 1449 if _, err := cw.WriteString(string("repo")); err != nil { 1450 return err 1451 } 1452 1453 if len(t.Repo) > 1000000 { 1454 return xerrors.Errorf("Value in field t.Repo was too long") 1455 } 1456 1457 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { 1458 return err 1459 } 1460 if _, err := cw.WriteString(string(t.Repo)); err != nil { 1461 return err 1462 } 1463 1464 // t.LexiconTypeID (string) (string) 1465 if len("$type") > 1000000 { 1466 return xerrors.Errorf("Value in field \"$type\" was too long") 1467 } 1468 1469 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 1470 return err 1471 } 1472 if _, err := cw.WriteString(string("$type")); err != nil { 1473 return err 1474 } 1475 1476 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil { 1477 return err 1478 } 1479 if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil { 1480 return err 1481 } 1482 1483 // t.Owner (string) (string) 1484 if len("owner") > 1000000 { 1485 return xerrors.Errorf("Value in field \"owner\" was too long") 1486 } 1487 1488 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 1489 return err 1490 } 1491 if _, err := cw.WriteString(string("owner")); err != nil { 1492 return err 1493 } 1494 1495 if len(t.Owner) > 1000000 { 1496 return xerrors.Errorf("Value in field t.Owner was too long") 1497 } 1498 1499 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { 1500 return err 1501 } 1502 if _, err := cw.WriteString(string(t.Owner)); err != nil { 1503 return err 1504 } 1505 1506 // t.Title (string) (string) 1507 if len("title") > 1000000 { 1508 return xerrors.Errorf("Value in field \"title\" was too long") 1509 } 1510 1511 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil { 1512 return err 1513 } 1514 if _, err := cw.WriteString(string("title")); err != nil { 1515 return err 1516 } 1517 1518 if len(t.Title) > 1000000 { 1519 return xerrors.Errorf("Value in field t.Title was too long") 1520 } 1521 1522 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil { 1523 return err 1524 } 1525 if _, err := cw.WriteString(string(t.Title)); err != nil { 1526 return err 1527 } 1528 1529 // t.IssueId (int64) (int64) 1530 if len("issueId") > 1000000 { 1531 return xerrors.Errorf("Value in field \"issueId\" was too long") 1532 } 1533 1534 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil { 1535 return err 1536 } 1537 if _, err := cw.WriteString(string("issueId")); err != nil { 1538 return err 1539 } 1540 1541 if t.IssueId >= 0 { 1542 if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil { 1543 return err 1544 } 1545 } else { 1546 if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil { 1547 return err 1548 } 1549 } 1550 1551 // t.CreatedAt (string) (string) 1552 if t.CreatedAt != nil { 1553 1554 if len("createdAt") > 1000000 { 1555 return xerrors.Errorf("Value in field \"createdAt\" was too long") 1556 } 1557 1558 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 1559 return err 1560 } 1561 if _, err := cw.WriteString(string("createdAt")); err != nil { 1562 return err 1563 } 1564 1565 if t.CreatedAt == nil { 1566 if _, err := cw.Write(cbg.CborNull); err != nil { 1567 return err 1568 } 1569 } else { 1570 if len(*t.CreatedAt) > 1000000 { 1571 return xerrors.Errorf("Value in field t.CreatedAt was too long") 1572 } 1573 1574 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CreatedAt))); err != nil { 1575 return err 1576 } 1577 if _, err := cw.WriteString(string(*t.CreatedAt)); err != nil { 1578 return err 1579 } 1580 } 1581 } 1582 return nil 1583} 1584 1585func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) { 1586 *t = RepoIssue{} 1587 1588 cr := cbg.NewCborReader(r) 1589 1590 maj, extra, err := cr.ReadHeader() 1591 if err != nil { 1592 return err 1593 } 1594 defer func() { 1595 if err == io.EOF { 1596 err = io.ErrUnexpectedEOF 1597 } 1598 }() 1599 1600 if maj != cbg.MajMap { 1601 return fmt.Errorf("cbor input should be of type map") 1602 } 1603 1604 if extra > cbg.MaxLength { 1605 return fmt.Errorf("RepoIssue: map struct too large (%d)", extra) 1606 } 1607 1608 n := extra 1609 1610 nameBuf := make([]byte, 9) 1611 for i := uint64(0); i < n; i++ { 1612 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1613 if err != nil { 1614 return err 1615 } 1616 1617 if !ok { 1618 // Field doesn't exist on this type, so ignore it 1619 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1620 return err 1621 } 1622 continue 1623 } 1624 1625 switch string(nameBuf[:nameLen]) { 1626 // t.Body (string) (string) 1627 case "body": 1628 1629 { 1630 b, err := cr.ReadByte() 1631 if err != nil { 1632 return err 1633 } 1634 if b != cbg.CborNull[0] { 1635 if err := cr.UnreadByte(); err != nil { 1636 return err 1637 } 1638 1639 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1640 if err != nil { 1641 return err 1642 } 1643 1644 t.Body = (*string)(&sval) 1645 } 1646 } 1647 // t.Repo (string) (string) 1648 case "repo": 1649 1650 { 1651 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1652 if err != nil { 1653 return err 1654 } 1655 1656 t.Repo = string(sval) 1657 } 1658 // t.LexiconTypeID (string) (string) 1659 case "$type": 1660 1661 { 1662 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1663 if err != nil { 1664 return err 1665 } 1666 1667 t.LexiconTypeID = string(sval) 1668 } 1669 // t.Owner (string) (string) 1670 case "owner": 1671 1672 { 1673 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1674 if err != nil { 1675 return err 1676 } 1677 1678 t.Owner = string(sval) 1679 } 1680 // t.Title (string) (string) 1681 case "title": 1682 1683 { 1684 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1685 if err != nil { 1686 return err 1687 } 1688 1689 t.Title = string(sval) 1690 } 1691 // t.IssueId (int64) (int64) 1692 case "issueId": 1693 { 1694 maj, extra, err := cr.ReadHeader() 1695 if err != nil { 1696 return err 1697 } 1698 var extraI int64 1699 switch maj { 1700 case cbg.MajUnsignedInt: 1701 extraI = int64(extra) 1702 if extraI < 0 { 1703 return fmt.Errorf("int64 positive overflow") 1704 } 1705 case cbg.MajNegativeInt: 1706 extraI = int64(extra) 1707 if extraI < 0 { 1708 return fmt.Errorf("int64 negative overflow") 1709 } 1710 extraI = -1 - extraI 1711 default: 1712 return fmt.Errorf("wrong type for int64 field: %d", maj) 1713 } 1714 1715 t.IssueId = int64(extraI) 1716 } 1717 // t.CreatedAt (string) (string) 1718 case "createdAt": 1719 1720 { 1721 b, err := cr.ReadByte() 1722 if err != nil { 1723 return err 1724 } 1725 if b != cbg.CborNull[0] { 1726 if err := cr.UnreadByte(); err != nil { 1727 return err 1728 } 1729 1730 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1731 if err != nil { 1732 return err 1733 } 1734 1735 t.CreatedAt = (*string)(&sval) 1736 } 1737 } 1738 1739 default: 1740 // Field doesn't exist on this type, so ignore it 1741 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 1742 return err 1743 } 1744 } 1745 } 1746 1747 return nil 1748} 1749func (t *Repo) MarshalCBOR(w io.Writer) error { 1750 if t == nil { 1751 _, err := w.Write(cbg.CborNull) 1752 return err 1753 } 1754 1755 cw := cbg.NewCborWriter(w) 1756 fieldCount := 6 1757 1758 if t.AddedAt == nil { 1759 fieldCount-- 1760 } 1761 1762 if t.Description == nil { 1763 fieldCount-- 1764 } 1765 1766 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 1767 return err 1768 } 1769 1770 // t.Knot (string) (string) 1771 if len("knot") > 1000000 { 1772 return xerrors.Errorf("Value in field \"knot\" was too long") 1773 } 1774 1775 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil { 1776 return err 1777 } 1778 if _, err := cw.WriteString(string("knot")); err != nil { 1779 return err 1780 } 1781 1782 if len(t.Knot) > 1000000 { 1783 return xerrors.Errorf("Value in field t.Knot was too long") 1784 } 1785 1786 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil { 1787 return err 1788 } 1789 if _, err := cw.WriteString(string(t.Knot)); err != nil { 1790 return err 1791 } 1792 1793 // t.Name (string) (string) 1794 if len("name") > 1000000 { 1795 return xerrors.Errorf("Value in field \"name\" was too long") 1796 } 1797 1798 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { 1799 return err 1800 } 1801 if _, err := cw.WriteString(string("name")); err != nil { 1802 return err 1803 } 1804 1805 if len(t.Name) > 1000000 { 1806 return xerrors.Errorf("Value in field t.Name was too long") 1807 } 1808 1809 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { 1810 return err 1811 } 1812 if _, err := cw.WriteString(string(t.Name)); err != nil { 1813 return err 1814 } 1815 1816 // t.LexiconTypeID (string) (string) 1817 if len("$type") > 1000000 { 1818 return xerrors.Errorf("Value in field \"$type\" was too long") 1819 } 1820 1821 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 1822 return err 1823 } 1824 if _, err := cw.WriteString(string("$type")); err != nil { 1825 return err 1826 } 1827 1828 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil { 1829 return err 1830 } 1831 if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil { 1832 return err 1833 } 1834 1835 // t.Owner (string) (string) 1836 if len("owner") > 1000000 { 1837 return xerrors.Errorf("Value in field \"owner\" was too long") 1838 } 1839 1840 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 1841 return err 1842 } 1843 if _, err := cw.WriteString(string("owner")); err != nil { 1844 return err 1845 } 1846 1847 if len(t.Owner) > 1000000 { 1848 return xerrors.Errorf("Value in field t.Owner was too long") 1849 } 1850 1851 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { 1852 return err 1853 } 1854 if _, err := cw.WriteString(string(t.Owner)); err != nil { 1855 return err 1856 } 1857 1858 // t.AddedAt (string) (string) 1859 if t.AddedAt != nil { 1860 1861 if len("addedAt") > 1000000 { 1862 return xerrors.Errorf("Value in field \"addedAt\" was too long") 1863 } 1864 1865 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("addedAt"))); err != nil { 1866 return err 1867 } 1868 if _, err := cw.WriteString(string("addedAt")); err != nil { 1869 return err 1870 } 1871 1872 if t.AddedAt == nil { 1873 if _, err := cw.Write(cbg.CborNull); err != nil { 1874 return err 1875 } 1876 } else { 1877 if len(*t.AddedAt) > 1000000 { 1878 return xerrors.Errorf("Value in field t.AddedAt was too long") 1879 } 1880 1881 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.AddedAt))); err != nil { 1882 return err 1883 } 1884 if _, err := cw.WriteString(string(*t.AddedAt)); err != nil { 1885 return err 1886 } 1887 } 1888 } 1889 1890 // t.Description (string) (string) 1891 if t.Description != nil { 1892 1893 if len("description") > 1000000 { 1894 return xerrors.Errorf("Value in field \"description\" was too long") 1895 } 1896 1897 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil { 1898 return err 1899 } 1900 if _, err := cw.WriteString(string("description")); err != nil { 1901 return err 1902 } 1903 1904 if t.Description == nil { 1905 if _, err := cw.Write(cbg.CborNull); err != nil { 1906 return err 1907 } 1908 } else { 1909 if len(*t.Description) > 1000000 { 1910 return xerrors.Errorf("Value in field t.Description was too long") 1911 } 1912 1913 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil { 1914 return err 1915 } 1916 if _, err := cw.WriteString(string(*t.Description)); err != nil { 1917 return err 1918 } 1919 } 1920 } 1921 return nil 1922} 1923 1924func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { 1925 *t = Repo{} 1926 1927 cr := cbg.NewCborReader(r) 1928 1929 maj, extra, err := cr.ReadHeader() 1930 if err != nil { 1931 return err 1932 } 1933 defer func() { 1934 if err == io.EOF { 1935 err = io.ErrUnexpectedEOF 1936 } 1937 }() 1938 1939 if maj != cbg.MajMap { 1940 return fmt.Errorf("cbor input should be of type map") 1941 } 1942 1943 if extra > cbg.MaxLength { 1944 return fmt.Errorf("Repo: map struct too large (%d)", extra) 1945 } 1946 1947 n := extra 1948 1949 nameBuf := make([]byte, 11) 1950 for i := uint64(0); i < n; i++ { 1951 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1952 if err != nil { 1953 return err 1954 } 1955 1956 if !ok { 1957 // Field doesn't exist on this type, so ignore it 1958 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1959 return err 1960 } 1961 continue 1962 } 1963 1964 switch string(nameBuf[:nameLen]) { 1965 // t.Knot (string) (string) 1966 case "knot": 1967 1968 { 1969 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1970 if err != nil { 1971 return err 1972 } 1973 1974 t.Knot = string(sval) 1975 } 1976 // t.Name (string) (string) 1977 case "name": 1978 1979 { 1980 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1981 if err != nil { 1982 return err 1983 } 1984 1985 t.Name = string(sval) 1986 } 1987 // t.LexiconTypeID (string) (string) 1988 case "$type": 1989 1990 { 1991 sval, err := cbg.ReadStringWithMax(cr, 1000000) 1992 if err != nil { 1993 return err 1994 } 1995 1996 t.LexiconTypeID = string(sval) 1997 } 1998 // t.Owner (string) (string) 1999 case "owner": 2000 2001 { 2002 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2003 if err != nil { 2004 return err 2005 } 2006 2007 t.Owner = string(sval) 2008 } 2009 // t.AddedAt (string) (string) 2010 case "addedAt": 2011 2012 { 2013 b, err := cr.ReadByte() 2014 if err != nil { 2015 return err 2016 } 2017 if b != cbg.CborNull[0] { 2018 if err := cr.UnreadByte(); err != nil { 2019 return err 2020 } 2021 2022 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2023 if err != nil { 2024 return err 2025 } 2026 2027 t.AddedAt = (*string)(&sval) 2028 } 2029 } 2030 // t.Description (string) (string) 2031 case "description": 2032 2033 { 2034 b, err := cr.ReadByte() 2035 if err != nil { 2036 return err 2037 } 2038 if b != cbg.CborNull[0] { 2039 if err := cr.UnreadByte(); err != nil { 2040 return err 2041 } 2042 2043 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2044 if err != nil { 2045 return err 2046 } 2047 2048 t.Description = (*string)(&sval) 2049 } 2050 } 2051 2052 default: 2053 // Field doesn't exist on this type, so ignore it 2054 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 2055 return err 2056 } 2057 } 2058 } 2059 2060 return nil 2061} 2062func (t *RepoPull) MarshalCBOR(w io.Writer) error { 2063 if t == nil { 2064 _, err := w.Write(cbg.CborNull) 2065 return err 2066 } 2067 2068 cw := cbg.NewCborWriter(w) 2069 fieldCount := 9 2070 2071 if t.Body == nil { 2072 fieldCount-- 2073 } 2074 2075 if t.CreatedAt == nil { 2076 fieldCount-- 2077 } 2078 2079 if t.SourceRepo == nil { 2080 fieldCount-- 2081 } 2082 2083 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 2084 return err 2085 } 2086 2087 // t.Body (string) (string) 2088 if t.Body != nil { 2089 2090 if len("body") > 1000000 { 2091 return xerrors.Errorf("Value in field \"body\" was too long") 2092 } 2093 2094 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { 2095 return err 2096 } 2097 if _, err := cw.WriteString(string("body")); err != nil { 2098 return err 2099 } 2100 2101 if t.Body == nil { 2102 if _, err := cw.Write(cbg.CborNull); err != nil { 2103 return err 2104 } 2105 } else { 2106 if len(*t.Body) > 1000000 { 2107 return xerrors.Errorf("Value in field t.Body was too long") 2108 } 2109 2110 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { 2111 return err 2112 } 2113 if _, err := cw.WriteString(string(*t.Body)); err != nil { 2114 return err 2115 } 2116 } 2117 } 2118 2119 // t.LexiconTypeID (string) (string) 2120 if len("$type") > 1000000 { 2121 return xerrors.Errorf("Value in field \"$type\" was too long") 2122 } 2123 2124 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 2125 return err 2126 } 2127 if _, err := cw.WriteString(string("$type")); err != nil { 2128 return err 2129 } 2130 2131 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil { 2132 return err 2133 } 2134 if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil { 2135 return err 2136 } 2137 2138 // t.Patch (string) (string) 2139 if len("patch") > 1000000 { 2140 return xerrors.Errorf("Value in field \"patch\" was too long") 2141 } 2142 2143 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil { 2144 return err 2145 } 2146 if _, err := cw.WriteString(string("patch")); err != nil { 2147 return err 2148 } 2149 2150 if len(t.Patch) > 1000000 { 2151 return xerrors.Errorf("Value in field t.Patch was too long") 2152 } 2153 2154 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil { 2155 return err 2156 } 2157 if _, err := cw.WriteString(string(t.Patch)); err != nil { 2158 return err 2159 } 2160 2161 // t.Title (string) (string) 2162 if len("title") > 1000000 { 2163 return xerrors.Errorf("Value in field \"title\" was too long") 2164 } 2165 2166 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil { 2167 return err 2168 } 2169 if _, err := cw.WriteString(string("title")); err != nil { 2170 return err 2171 } 2172 2173 if len(t.Title) > 1000000 { 2174 return xerrors.Errorf("Value in field t.Title was too long") 2175 } 2176 2177 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil { 2178 return err 2179 } 2180 if _, err := cw.WriteString(string(t.Title)); err != nil { 2181 return err 2182 } 2183 2184 // t.PullId (int64) (int64) 2185 if len("pullId") > 1000000 { 2186 return xerrors.Errorf("Value in field \"pullId\" was too long") 2187 } 2188 2189 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil { 2190 return err 2191 } 2192 if _, err := cw.WriteString(string("pullId")); err != nil { 2193 return err 2194 } 2195 2196 if t.PullId >= 0 { 2197 if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil { 2198 return err 2199 } 2200 } else { 2201 if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil { 2202 return err 2203 } 2204 } 2205 2206 // t.CreatedAt (string) (string) 2207 if t.CreatedAt != nil { 2208 2209 if len("createdAt") > 1000000 { 2210 return xerrors.Errorf("Value in field \"createdAt\" was too long") 2211 } 2212 2213 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 2214 return err 2215 } 2216 if _, err := cw.WriteString(string("createdAt")); err != nil { 2217 return err 2218 } 2219 2220 if t.CreatedAt == nil { 2221 if _, err := cw.Write(cbg.CborNull); err != nil { 2222 return err 2223 } 2224 } else { 2225 if len(*t.CreatedAt) > 1000000 { 2226 return xerrors.Errorf("Value in field t.CreatedAt was too long") 2227 } 2228 2229 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CreatedAt))); err != nil { 2230 return err 2231 } 2232 if _, err := cw.WriteString(string(*t.CreatedAt)); err != nil { 2233 return err 2234 } 2235 } 2236 } 2237 2238 // t.SourceRepo (string) (string) 2239 if t.SourceRepo != nil { 2240 2241 if len("sourceRepo") > 1000000 { 2242 return xerrors.Errorf("Value in field \"sourceRepo\" was too long") 2243 } 2244 2245 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceRepo"))); err != nil { 2246 return err 2247 } 2248 if _, err := cw.WriteString(string("sourceRepo")); err != nil { 2249 return err 2250 } 2251 2252 if t.SourceRepo == nil { 2253 if _, err := cw.Write(cbg.CborNull); err != nil { 2254 return err 2255 } 2256 } else { 2257 if len(*t.SourceRepo) > 1000000 { 2258 return xerrors.Errorf("Value in field t.SourceRepo was too long") 2259 } 2260 2261 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceRepo))); err != nil { 2262 return err 2263 } 2264 if _, err := cw.WriteString(string(*t.SourceRepo)); err != nil { 2265 return err 2266 } 2267 } 2268 } 2269 2270 // t.TargetRepo (string) (string) 2271 if len("targetRepo") > 1000000 { 2272 return xerrors.Errorf("Value in field \"targetRepo\" was too long") 2273 } 2274 2275 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil { 2276 return err 2277 } 2278 if _, err := cw.WriteString(string("targetRepo")); err != nil { 2279 return err 2280 } 2281 2282 if len(t.TargetRepo) > 1000000 { 2283 return xerrors.Errorf("Value in field t.TargetRepo was too long") 2284 } 2285 2286 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil { 2287 return err 2288 } 2289 if _, err := cw.WriteString(string(t.TargetRepo)); err != nil { 2290 return err 2291 } 2292 2293 // t.TargetBranch (string) (string) 2294 if len("targetBranch") > 1000000 { 2295 return xerrors.Errorf("Value in field \"targetBranch\" was too long") 2296 } 2297 2298 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { 2299 return err 2300 } 2301 if _, err := cw.WriteString(string("targetBranch")); err != nil { 2302 return err 2303 } 2304 2305 if len(t.TargetBranch) > 1000000 { 2306 return xerrors.Errorf("Value in field t.TargetBranch was too long") 2307 } 2308 2309 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil { 2310 return err 2311 } 2312 if _, err := cw.WriteString(string(t.TargetBranch)); err != nil { 2313 return err 2314 } 2315 return nil 2316} 2317 2318func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { 2319 *t = RepoPull{} 2320 2321 cr := cbg.NewCborReader(r) 2322 2323 maj, extra, err := cr.ReadHeader() 2324 if err != nil { 2325 return err 2326 } 2327 defer func() { 2328 if err == io.EOF { 2329 err = io.ErrUnexpectedEOF 2330 } 2331 }() 2332 2333 if maj != cbg.MajMap { 2334 return fmt.Errorf("cbor input should be of type map") 2335 } 2336 2337 if extra > cbg.MaxLength { 2338 return fmt.Errorf("RepoPull: map struct too large (%d)", extra) 2339 } 2340 2341 n := extra 2342 2343 nameBuf := make([]byte, 12) 2344 for i := uint64(0); i < n; i++ { 2345 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2346 if err != nil { 2347 return err 2348 } 2349 2350 if !ok { 2351 // Field doesn't exist on this type, so ignore it 2352 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 2353 return err 2354 } 2355 continue 2356 } 2357 2358 switch string(nameBuf[:nameLen]) { 2359 // t.Body (string) (string) 2360 case "body": 2361 2362 { 2363 b, err := cr.ReadByte() 2364 if err != nil { 2365 return err 2366 } 2367 if b != cbg.CborNull[0] { 2368 if err := cr.UnreadByte(); err != nil { 2369 return err 2370 } 2371 2372 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2373 if err != nil { 2374 return err 2375 } 2376 2377 t.Body = (*string)(&sval) 2378 } 2379 } 2380 // t.LexiconTypeID (string) (string) 2381 case "$type": 2382 2383 { 2384 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2385 if err != nil { 2386 return err 2387 } 2388 2389 t.LexiconTypeID = string(sval) 2390 } 2391 // t.Patch (string) (string) 2392 case "patch": 2393 2394 { 2395 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2396 if err != nil { 2397 return err 2398 } 2399 2400 t.Patch = string(sval) 2401 } 2402 // t.Title (string) (string) 2403 case "title": 2404 2405 { 2406 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2407 if err != nil { 2408 return err 2409 } 2410 2411 t.Title = string(sval) 2412 } 2413 // t.PullId (int64) (int64) 2414 case "pullId": 2415 { 2416 maj, extra, err := cr.ReadHeader() 2417 if err != nil { 2418 return err 2419 } 2420 var extraI int64 2421 switch maj { 2422 case cbg.MajUnsignedInt: 2423 extraI = int64(extra) 2424 if extraI < 0 { 2425 return fmt.Errorf("int64 positive overflow") 2426 } 2427 case cbg.MajNegativeInt: 2428 extraI = int64(extra) 2429 if extraI < 0 { 2430 return fmt.Errorf("int64 negative overflow") 2431 } 2432 extraI = -1 - extraI 2433 default: 2434 return fmt.Errorf("wrong type for int64 field: %d", maj) 2435 } 2436 2437 t.PullId = int64(extraI) 2438 } 2439 // t.CreatedAt (string) (string) 2440 case "createdAt": 2441 2442 { 2443 b, err := cr.ReadByte() 2444 if err != nil { 2445 return err 2446 } 2447 if b != cbg.CborNull[0] { 2448 if err := cr.UnreadByte(); err != nil { 2449 return err 2450 } 2451 2452 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2453 if err != nil { 2454 return err 2455 } 2456 2457 t.CreatedAt = (*string)(&sval) 2458 } 2459 } 2460 // t.SourceRepo (string) (string) 2461 case "sourceRepo": 2462 2463 { 2464 b, err := cr.ReadByte() 2465 if err != nil { 2466 return err 2467 } 2468 if b != cbg.CborNull[0] { 2469 if err := cr.UnreadByte(); err != nil { 2470 return err 2471 } 2472 2473 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2474 if err != nil { 2475 return err 2476 } 2477 2478 t.SourceRepo = (*string)(&sval) 2479 } 2480 } 2481 // t.TargetRepo (string) (string) 2482 case "targetRepo": 2483 2484 { 2485 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2486 if err != nil { 2487 return err 2488 } 2489 2490 t.TargetRepo = string(sval) 2491 } 2492 // t.TargetBranch (string) (string) 2493 case "targetBranch": 2494 2495 { 2496 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2497 if err != nil { 2498 return err 2499 } 2500 2501 t.TargetBranch = string(sval) 2502 } 2503 2504 default: 2505 // Field doesn't exist on this type, so ignore it 2506 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 2507 return err 2508 } 2509 } 2510 } 2511 2512 return nil 2513} 2514func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { 2515 if t == nil { 2516 _, err := w.Write(cbg.CborNull) 2517 return err 2518 } 2519 2520 cw := cbg.NewCborWriter(w) 2521 fieldCount := 3 2522 2523 if t.Status == nil { 2524 fieldCount-- 2525 } 2526 2527 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 2528 return err 2529 } 2530 2531 // t.Pull (string) (string) 2532 if len("pull") > 1000000 { 2533 return xerrors.Errorf("Value in field \"pull\" was too long") 2534 } 2535 2536 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { 2537 return err 2538 } 2539 if _, err := cw.WriteString(string("pull")); err != nil { 2540 return err 2541 } 2542 2543 if len(t.Pull) > 1000000 { 2544 return xerrors.Errorf("Value in field t.Pull was too long") 2545 } 2546 2547 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { 2548 return err 2549 } 2550 if _, err := cw.WriteString(string(t.Pull)); err != nil { 2551 return err 2552 } 2553 2554 // t.LexiconTypeID (string) (string) 2555 if len("$type") > 1000000 { 2556 return xerrors.Errorf("Value in field \"$type\" was too long") 2557 } 2558 2559 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 2560 return err 2561 } 2562 if _, err := cw.WriteString(string("$type")); err != nil { 2563 return err 2564 } 2565 2566 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil { 2567 return err 2568 } 2569 if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil { 2570 return err 2571 } 2572 2573 // t.Status (string) (string) 2574 if t.Status != nil { 2575 2576 if len("status") > 1000000 { 2577 return xerrors.Errorf("Value in field \"status\" was too long") 2578 } 2579 2580 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 2581 return err 2582 } 2583 if _, err := cw.WriteString(string("status")); err != nil { 2584 return err 2585 } 2586 2587 if t.Status == nil { 2588 if _, err := cw.Write(cbg.CborNull); err != nil { 2589 return err 2590 } 2591 } else { 2592 if len(*t.Status) > 1000000 { 2593 return xerrors.Errorf("Value in field t.Status was too long") 2594 } 2595 2596 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Status))); err != nil { 2597 return err 2598 } 2599 if _, err := cw.WriteString(string(*t.Status)); err != nil { 2600 return err 2601 } 2602 } 2603 } 2604 return nil 2605} 2606 2607func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { 2608 *t = RepoPullStatus{} 2609 2610 cr := cbg.NewCborReader(r) 2611 2612 maj, extra, err := cr.ReadHeader() 2613 if err != nil { 2614 return err 2615 } 2616 defer func() { 2617 if err == io.EOF { 2618 err = io.ErrUnexpectedEOF 2619 } 2620 }() 2621 2622 if maj != cbg.MajMap { 2623 return fmt.Errorf("cbor input should be of type map") 2624 } 2625 2626 if extra > cbg.MaxLength { 2627 return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra) 2628 } 2629 2630 n := extra 2631 2632 nameBuf := make([]byte, 6) 2633 for i := uint64(0); i < n; i++ { 2634 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2635 if err != nil { 2636 return err 2637 } 2638 2639 if !ok { 2640 // Field doesn't exist on this type, so ignore it 2641 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 2642 return err 2643 } 2644 continue 2645 } 2646 2647 switch string(nameBuf[:nameLen]) { 2648 // t.Pull (string) (string) 2649 case "pull": 2650 2651 { 2652 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2653 if err != nil { 2654 return err 2655 } 2656 2657 t.Pull = string(sval) 2658 } 2659 // t.LexiconTypeID (string) (string) 2660 case "$type": 2661 2662 { 2663 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2664 if err != nil { 2665 return err 2666 } 2667 2668 t.LexiconTypeID = string(sval) 2669 } 2670 // t.Status (string) (string) 2671 case "status": 2672 2673 { 2674 b, err := cr.ReadByte() 2675 if err != nil { 2676 return err 2677 } 2678 if b != cbg.CborNull[0] { 2679 if err := cr.UnreadByte(); err != nil { 2680 return err 2681 } 2682 2683 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2684 if err != nil { 2685 return err 2686 } 2687 2688 t.Status = (*string)(&sval) 2689 } 2690 } 2691 2692 default: 2693 // Field doesn't exist on this type, so ignore it 2694 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 2695 return err 2696 } 2697 } 2698 } 2699 2700 return nil 2701} 2702func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { 2703 if t == nil { 2704 _, err := w.Write(cbg.CborNull) 2705 return err 2706 } 2707 2708 cw := cbg.NewCborWriter(w) 2709 fieldCount := 7 2710 2711 if t.Body == nil { 2712 fieldCount-- 2713 } 2714 2715 if t.CommentId == nil { 2716 fieldCount-- 2717 } 2718 2719 if t.CreatedAt == nil { 2720 fieldCount-- 2721 } 2722 2723 if t.Owner == nil { 2724 fieldCount-- 2725 } 2726 2727 if t.Repo == nil { 2728 fieldCount-- 2729 } 2730 2731 if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 2732 return err 2733 } 2734 2735 // t.Body (string) (string) 2736 if t.Body != nil { 2737 2738 if len("body") > 1000000 { 2739 return xerrors.Errorf("Value in field \"body\" was too long") 2740 } 2741 2742 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { 2743 return err 2744 } 2745 if _, err := cw.WriteString(string("body")); err != nil { 2746 return err 2747 } 2748 2749 if t.Body == nil { 2750 if _, err := cw.Write(cbg.CborNull); err != nil { 2751 return err 2752 } 2753 } else { 2754 if len(*t.Body) > 1000000 { 2755 return xerrors.Errorf("Value in field t.Body was too long") 2756 } 2757 2758 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { 2759 return err 2760 } 2761 if _, err := cw.WriteString(string(*t.Body)); err != nil { 2762 return err 2763 } 2764 } 2765 } 2766 2767 // t.Pull (string) (string) 2768 if len("pull") > 1000000 { 2769 return xerrors.Errorf("Value in field \"pull\" was too long") 2770 } 2771 2772 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { 2773 return err 2774 } 2775 if _, err := cw.WriteString(string("pull")); err != nil { 2776 return err 2777 } 2778 2779 if len(t.Pull) > 1000000 { 2780 return xerrors.Errorf("Value in field t.Pull was too long") 2781 } 2782 2783 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { 2784 return err 2785 } 2786 if _, err := cw.WriteString(string(t.Pull)); err != nil { 2787 return err 2788 } 2789 2790 // t.Repo (string) (string) 2791 if t.Repo != nil { 2792 2793 if len("repo") > 1000000 { 2794 return xerrors.Errorf("Value in field \"repo\" was too long") 2795 } 2796 2797 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 2798 return err 2799 } 2800 if _, err := cw.WriteString(string("repo")); err != nil { 2801 return err 2802 } 2803 2804 if t.Repo == nil { 2805 if _, err := cw.Write(cbg.CborNull); err != nil { 2806 return err 2807 } 2808 } else { 2809 if len(*t.Repo) > 1000000 { 2810 return xerrors.Errorf("Value in field t.Repo was too long") 2811 } 2812 2813 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { 2814 return err 2815 } 2816 if _, err := cw.WriteString(string(*t.Repo)); err != nil { 2817 return err 2818 } 2819 } 2820 } 2821 2822 // t.LexiconTypeID (string) (string) 2823 if len("$type") > 1000000 { 2824 return xerrors.Errorf("Value in field \"$type\" was too long") 2825 } 2826 2827 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 2828 return err 2829 } 2830 if _, err := cw.WriteString(string("$type")); err != nil { 2831 return err 2832 } 2833 2834 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.comment"))); err != nil { 2835 return err 2836 } 2837 if _, err := cw.WriteString(string("sh.tangled.repo.pull.comment")); err != nil { 2838 return err 2839 } 2840 2841 // t.Owner (string) (string) 2842 if t.Owner != nil { 2843 2844 if len("owner") > 1000000 { 2845 return xerrors.Errorf("Value in field \"owner\" was too long") 2846 } 2847 2848 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 2849 return err 2850 } 2851 if _, err := cw.WriteString(string("owner")); err != nil { 2852 return err 2853 } 2854 2855 if t.Owner == nil { 2856 if _, err := cw.Write(cbg.CborNull); err != nil { 2857 return err 2858 } 2859 } else { 2860 if len(*t.Owner) > 1000000 { 2861 return xerrors.Errorf("Value in field t.Owner was too long") 2862 } 2863 2864 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Owner))); err != nil { 2865 return err 2866 } 2867 if _, err := cw.WriteString(string(*t.Owner)); err != nil { 2868 return err 2869 } 2870 } 2871 } 2872 2873 // t.CommentId (int64) (int64) 2874 if t.CommentId != nil { 2875 2876 if len("commentId") > 1000000 { 2877 return xerrors.Errorf("Value in field \"commentId\" was too long") 2878 } 2879 2880 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commentId"))); err != nil { 2881 return err 2882 } 2883 if _, err := cw.WriteString(string("commentId")); err != nil { 2884 return err 2885 } 2886 2887 if t.CommentId == nil { 2888 if _, err := cw.Write(cbg.CborNull); err != nil { 2889 return err 2890 } 2891 } else { 2892 if *t.CommentId >= 0 { 2893 if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.CommentId)); err != nil { 2894 return err 2895 } 2896 } else { 2897 if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.CommentId-1)); err != nil { 2898 return err 2899 } 2900 } 2901 } 2902 2903 } 2904 2905 // t.CreatedAt (string) (string) 2906 if t.CreatedAt != nil { 2907 2908 if len("createdAt") > 1000000 { 2909 return xerrors.Errorf("Value in field \"createdAt\" was too long") 2910 } 2911 2912 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 2913 return err 2914 } 2915 if _, err := cw.WriteString(string("createdAt")); err != nil { 2916 return err 2917 } 2918 2919 if t.CreatedAt == nil { 2920 if _, err := cw.Write(cbg.CborNull); err != nil { 2921 return err 2922 } 2923 } else { 2924 if len(*t.CreatedAt) > 1000000 { 2925 return xerrors.Errorf("Value in field t.CreatedAt was too long") 2926 } 2927 2928 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CreatedAt))); err != nil { 2929 return err 2930 } 2931 if _, err := cw.WriteString(string(*t.CreatedAt)); err != nil { 2932 return err 2933 } 2934 } 2935 } 2936 return nil 2937} 2938 2939func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { 2940 *t = RepoPullComment{} 2941 2942 cr := cbg.NewCborReader(r) 2943 2944 maj, extra, err := cr.ReadHeader() 2945 if err != nil { 2946 return err 2947 } 2948 defer func() { 2949 if err == io.EOF { 2950 err = io.ErrUnexpectedEOF 2951 } 2952 }() 2953 2954 if maj != cbg.MajMap { 2955 return fmt.Errorf("cbor input should be of type map") 2956 } 2957 2958 if extra > cbg.MaxLength { 2959 return fmt.Errorf("RepoPullComment: map struct too large (%d)", extra) 2960 } 2961 2962 n := extra 2963 2964 nameBuf := make([]byte, 9) 2965 for i := uint64(0); i < n; i++ { 2966 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2967 if err != nil { 2968 return err 2969 } 2970 2971 if !ok { 2972 // Field doesn't exist on this type, so ignore it 2973 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 2974 return err 2975 } 2976 continue 2977 } 2978 2979 switch string(nameBuf[:nameLen]) { 2980 // t.Body (string) (string) 2981 case "body": 2982 2983 { 2984 b, err := cr.ReadByte() 2985 if err != nil { 2986 return err 2987 } 2988 if b != cbg.CborNull[0] { 2989 if err := cr.UnreadByte(); err != nil { 2990 return err 2991 } 2992 2993 sval, err := cbg.ReadStringWithMax(cr, 1000000) 2994 if err != nil { 2995 return err 2996 } 2997 2998 t.Body = (*string)(&sval) 2999 } 3000 } 3001 // t.Pull (string) (string) 3002 case "pull": 3003 3004 { 3005 sval, err := cbg.ReadStringWithMax(cr, 1000000) 3006 if err != nil { 3007 return err 3008 } 3009 3010 t.Pull = string(sval) 3011 } 3012 // t.Repo (string) (string) 3013 case "repo": 3014 3015 { 3016 b, err := cr.ReadByte() 3017 if err != nil { 3018 return err 3019 } 3020 if b != cbg.CborNull[0] { 3021 if err := cr.UnreadByte(); err != nil { 3022 return err 3023 } 3024 3025 sval, err := cbg.ReadStringWithMax(cr, 1000000) 3026 if err != nil { 3027 return err 3028 } 3029 3030 t.Repo = (*string)(&sval) 3031 } 3032 } 3033 // t.LexiconTypeID (string) (string) 3034 case "$type": 3035 3036 { 3037 sval, err := cbg.ReadStringWithMax(cr, 1000000) 3038 if err != nil { 3039 return err 3040 } 3041 3042 t.LexiconTypeID = string(sval) 3043 } 3044 // t.Owner (string) (string) 3045 case "owner": 3046 3047 { 3048 b, err := cr.ReadByte() 3049 if err != nil { 3050 return err 3051 } 3052 if b != cbg.CborNull[0] { 3053 if err := cr.UnreadByte(); err != nil { 3054 return err 3055 } 3056 3057 sval, err := cbg.ReadStringWithMax(cr, 1000000) 3058 if err != nil { 3059 return err 3060 } 3061 3062 t.Owner = (*string)(&sval) 3063 } 3064 } 3065 // t.CommentId (int64) (int64) 3066 case "commentId": 3067 { 3068 3069 b, err := cr.ReadByte() 3070 if err != nil { 3071 return err 3072 } 3073 if b != cbg.CborNull[0] { 3074 if err := cr.UnreadByte(); err != nil { 3075 return err 3076 } 3077 maj, extra, err := cr.ReadHeader() 3078 if err != nil { 3079 return err 3080 } 3081 var extraI int64 3082 switch maj { 3083 case cbg.MajUnsignedInt: 3084 extraI = int64(extra) 3085 if extraI < 0 { 3086 return fmt.Errorf("int64 positive overflow") 3087 } 3088 case cbg.MajNegativeInt: 3089 extraI = int64(extra) 3090 if extraI < 0 { 3091 return fmt.Errorf("int64 negative overflow") 3092 } 3093 extraI = -1 - extraI 3094 default: 3095 return fmt.Errorf("wrong type for int64 field: %d", maj) 3096 } 3097 3098 t.CommentId = (*int64)(&extraI) 3099 } 3100 } 3101 // t.CreatedAt (string) (string) 3102 case "createdAt": 3103 3104 { 3105 b, err := cr.ReadByte() 3106 if err != nil { 3107 return err 3108 } 3109 if b != cbg.CborNull[0] { 3110 if err := cr.UnreadByte(); err != nil { 3111 return err 3112 } 3113 3114 sval, err := cbg.ReadStringWithMax(cr, 1000000) 3115 if err != nil { 3116 return err 3117 } 3118 3119 t.CreatedAt = (*string)(&sval) 3120 } 3121 } 3122 3123 default: 3124 // Field doesn't exist on this type, so ignore it 3125 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 3126 return err 3127 } 3128 } 3129 } 3130 3131 return nil 3132}