···88 "math"
99 "sort"
10101111+ util "github.com/bluesky-social/indigo/lex/util"
1112 cid "github.com/ipfs/go-cid"
1213 cbg "github.com/whyrusleeping/cbor-gen"
1314 xerrors "golang.org/x/xerrors"
···1819var _ = math.E
1920var _ = sort.Sort
20212121-func (t *CrewRecord) MarshalCBOR(w io.Writer) error {
2222+func (t *Manifest) MarshalCBOR(w io.Writer) error {
2223 if t == nil {
2324 _, err := w.Write(cbg.CborNull)
2425 return err
2526 }
26272728 cw := cbg.NewCborWriter(w)
2929+ fieldCount := 14
28302929- if _, err := cw.Write([]byte{165}); err != nil {
3030- return err
3131+ if t.Annotations == nil {
3232+ fieldCount--
3333+ }
3434+3535+ if t.Config == nil {
3636+ fieldCount--
3737+ }
3838+3939+ if t.HoldDid == nil {
4040+ fieldCount--
3141 }
32423333- // t.Role (string) (string)
3434- if len("role") > 8192 {
3535- return xerrors.Errorf("Value in field \"role\" was too long")
4343+ if t.HoldEndpoint == nil {
4444+ fieldCount--
3645 }
37463838- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("role"))); err != nil {
3939- return err
4747+ if t.Layers == nil {
4848+ fieldCount--
4049 }
4141- if _, err := cw.WriteString(string("role")); err != nil {
4242- return err
5050+5151+ if t.ManifestBlob == nil {
5252+ fieldCount--
4353 }
44544545- if len(t.Role) > 8192 {
4646- return xerrors.Errorf("Value in field t.Role was too long")
5555+ if t.Manifests == nil {
5656+ fieldCount--
4757 }
48584949- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Role))); err != nil {
5050- return err
5959+ if t.Subject == nil {
6060+ fieldCount--
5161 }
5252- if _, err := cw.WriteString(string(t.Role)); err != nil {
6262+6363+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
5364 return err
5465 }
55665656- // t.Type (string) (string)
6767+ // t.LexiconTypeID (string) (string)
5768 if len("$type") > 8192 {
5869 return xerrors.Errorf("Value in field \"$type\" was too long")
5970 }
···6576 return err
6677 }
67786868- if len(t.Type) > 8192 {
6969- return xerrors.Errorf("Value in field t.Type was too long")
7979+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.manifest"))); err != nil {
8080+ return err
8181+ }
8282+ if _, err := cw.WriteString(string("io.atcr.manifest")); err != nil {
8383+ return err
8484+ }
8585+8686+ // t.Config (atproto.Manifest_BlobReference) (struct)
8787+ if t.Config != nil {
8888+8989+ if len("config") > 8192 {
9090+ return xerrors.Errorf("Value in field \"config\" was too long")
9191+ }
9292+9393+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("config"))); err != nil {
9494+ return err
9595+ }
9696+ if _, err := cw.WriteString(string("config")); err != nil {
9797+ return err
9898+ }
9999+100100+ if err := t.Config.MarshalCBOR(cw); err != nil {
101101+ return err
102102+ }
70103 }
711047272- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Type))); err != nil {
105105+ // t.Digest (string) (string)
106106+ if len("digest") > 8192 {
107107+ return xerrors.Errorf("Value in field \"digest\" was too long")
108108+ }
109109+110110+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("digest"))); err != nil {
73111 return err
74112 }
7575- if _, err := cw.WriteString(string(t.Type)); err != nil {
113113+ if _, err := cw.WriteString(string("digest")); err != nil {
76114 return err
77115 }
781167979- // t.Member (string) (string)
8080- if len("member") > 8192 {
8181- return xerrors.Errorf("Value in field \"member\" was too long")
117117+ if len(t.Digest) > 8192 {
118118+ return xerrors.Errorf("Value in field t.Digest was too long")
82119 }
831208484- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("member"))); err != nil {
121121+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Digest))); err != nil {
85122 return err
86123 }
8787- if _, err := cw.WriteString(string("member")); err != nil {
124124+ if _, err := cw.WriteString(string(t.Digest)); err != nil {
88125 return err
89126 }
901279191- if len(t.Member) > 8192 {
9292- return xerrors.Errorf("Value in field t.Member was too long")
128128+ // t.Layers ([]atproto.Manifest_BlobReference) (slice)
129129+ if t.Layers != nil {
130130+131131+ if len("layers") > 8192 {
132132+ return xerrors.Errorf("Value in field \"layers\" was too long")
133133+ }
134134+135135+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("layers"))); err != nil {
136136+ return err
137137+ }
138138+ if _, err := cw.WriteString(string("layers")); err != nil {
139139+ return err
140140+ }
141141+142142+ if len(t.Layers) > 8192 {
143143+ return xerrors.Errorf("Slice value in field t.Layers was too long")
144144+ }
145145+146146+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Layers))); err != nil {
147147+ return err
148148+ }
149149+ for _, v := range t.Layers {
150150+ if err := v.MarshalCBOR(cw); err != nil {
151151+ return err
152152+ }
153153+154154+ }
93155 }
941569595- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Member))); err != nil {
157157+ // t.HoldDid (string) (string)
158158+ if t.HoldDid != nil {
159159+160160+ if len("holdDid") > 8192 {
161161+ return xerrors.Errorf("Value in field \"holdDid\" was too long")
162162+ }
163163+164164+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("holdDid"))); err != nil {
165165+ return err
166166+ }
167167+ if _, err := cw.WriteString(string("holdDid")); err != nil {
168168+ return err
169169+ }
170170+171171+ if t.HoldDid == nil {
172172+ if _, err := cw.Write(cbg.CborNull); err != nil {
173173+ return err
174174+ }
175175+ } else {
176176+ if len(*t.HoldDid) > 8192 {
177177+ return xerrors.Errorf("Value in field t.HoldDid was too long")
178178+ }
179179+180180+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.HoldDid))); err != nil {
181181+ return err
182182+ }
183183+ if _, err := cw.WriteString(string(*t.HoldDid)); err != nil {
184184+ return err
185185+ }
186186+ }
187187+ }
188188+189189+ // t.Subject (atproto.Manifest_BlobReference) (struct)
190190+ if t.Subject != nil {
191191+192192+ if len("subject") > 8192 {
193193+ return xerrors.Errorf("Value in field \"subject\" was too long")
194194+ }
195195+196196+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
197197+ return err
198198+ }
199199+ if _, err := cw.WriteString(string("subject")); err != nil {
200200+ return err
201201+ }
202202+203203+ if err := t.Subject.MarshalCBOR(cw); err != nil {
204204+ return err
205205+ }
206206+ }
207207+208208+ // t.CreatedAt (string) (string)
209209+ if len("createdAt") > 8192 {
210210+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
211211+ }
212212+213213+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
96214 return err
97215 }
9898- if _, err := cw.WriteString(string(t.Member)); err != nil {
216216+ if _, err := cw.WriteString(string("createdAt")); err != nil {
99217 return err
100218 }
101219102102- // t.AddedAt (string) (string)
103103- if len("addedAt") > 8192 {
104104- return xerrors.Errorf("Value in field \"addedAt\" was too long")
220220+ if len(t.CreatedAt) > 8192 {
221221+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
105222 }
106223107107- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("addedAt"))); err != nil {
224224+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
108225 return err
109226 }
110110- if _, err := cw.WriteString(string("addedAt")); err != nil {
227227+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
111228 return err
112229 }
113230114114- if len(t.AddedAt) > 8192 {
115115- return xerrors.Errorf("Value in field t.AddedAt was too long")
231231+ // t.Manifests ([]atproto.Manifest_ManifestReference) (slice)
232232+ if t.Manifests != nil {
233233+234234+ if len("manifests") > 8192 {
235235+ return xerrors.Errorf("Value in field \"manifests\" was too long")
236236+ }
237237+238238+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("manifests"))); err != nil {
239239+ return err
240240+ }
241241+ if _, err := cw.WriteString(string("manifests")); err != nil {
242242+ return err
243243+ }
244244+245245+ if len(t.Manifests) > 8192 {
246246+ return xerrors.Errorf("Slice value in field t.Manifests was too long")
247247+ }
248248+249249+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Manifests))); err != nil {
250250+ return err
251251+ }
252252+ for _, v := range t.Manifests {
253253+ if err := v.MarshalCBOR(cw); err != nil {
254254+ return err
255255+ }
256256+257257+ }
116258 }
117259118118- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.AddedAt))); err != nil {
260260+ // t.MediaType (string) (string)
261261+ if len("mediaType") > 8192 {
262262+ return xerrors.Errorf("Value in field \"mediaType\" was too long")
263263+ }
264264+265265+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mediaType"))); err != nil {
119266 return err
120267 }
121121- if _, err := cw.WriteString(string(t.AddedAt)); err != nil {
268268+ if _, err := cw.WriteString(string("mediaType")); err != nil {
122269 return err
123270 }
124271125125- // t.Permissions ([]string) (slice)
126126- if len("permissions") > 8192 {
127127- return xerrors.Errorf("Value in field \"permissions\" was too long")
272272+ if len(t.MediaType) > 8192 {
273273+ return xerrors.Errorf("Value in field t.MediaType was too long")
128274 }
129275130130- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("permissions"))); err != nil {
276276+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.MediaType))); err != nil {
277277+ return err
278278+ }
279279+ if _, err := cw.WriteString(string(t.MediaType)); err != nil {
280280+ return err
281281+ }
282282+283283+ // t.Repository (string) (string)
284284+ if len("repository") > 8192 {
285285+ return xerrors.Errorf("Value in field \"repository\" was too long")
286286+ }
287287+288288+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repository"))); err != nil {
131289 return err
132290 }
133133- if _, err := cw.WriteString(string("permissions")); err != nil {
291291+ if _, err := cw.WriteString(string("repository")); err != nil {
134292 return err
135293 }
136294137137- if len(t.Permissions) > 8192 {
138138- return xerrors.Errorf("Slice value in field t.Permissions was too long")
295295+ if len(t.Repository) > 8192 {
296296+ return xerrors.Errorf("Value in field t.Repository was too long")
139297 }
140298141141- if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Permissions))); err != nil {
299299+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repository))); err != nil {
142300 return err
143301 }
144144- for _, v := range t.Permissions {
145145- if len(v) > 8192 {
146146- return xerrors.Errorf("Value in field v was too long")
302302+ if _, err := cw.WriteString(string(t.Repository)); err != nil {
303303+ return err
304304+ }
305305+306306+ // t.Annotations (atproto.Manifest_Annotations) (struct)
307307+ if t.Annotations != nil {
308308+309309+ if len("annotations") > 8192 {
310310+ return xerrors.Errorf("Value in field \"annotations\" was too long")
311311+ }
312312+313313+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("annotations"))); err != nil {
314314+ return err
315315+ }
316316+ if _, err := cw.WriteString(string("annotations")); err != nil {
317317+ return err
318318+ }
319319+320320+ if err := t.Annotations.MarshalCBOR(cw); err != nil {
321321+ return err
322322+ }
323323+ }
324324+325325+ // t.HoldEndpoint (string) (string)
326326+ if t.HoldEndpoint != nil {
327327+328328+ if len("holdEndpoint") > 8192 {
329329+ return xerrors.Errorf("Value in field \"holdEndpoint\" was too long")
330330+ }
331331+332332+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("holdEndpoint"))); err != nil {
333333+ return err
334334+ }
335335+ if _, err := cw.WriteString(string("holdEndpoint")); err != nil {
336336+ return err
337337+ }
338338+339339+ if t.HoldEndpoint == nil {
340340+ if _, err := cw.Write(cbg.CborNull); err != nil {
341341+ return err
342342+ }
343343+ } else {
344344+ if len(*t.HoldEndpoint) > 8192 {
345345+ return xerrors.Errorf("Value in field t.HoldEndpoint was too long")
346346+ }
347347+348348+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.HoldEndpoint))); err != nil {
349349+ return err
350350+ }
351351+ if _, err := cw.WriteString(string(*t.HoldEndpoint)); err != nil {
352352+ return err
353353+ }
147354 }
355355+ }
148356149149- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
357357+ // t.ManifestBlob (util.LexBlob) (struct)
358358+ if t.ManifestBlob != nil {
359359+360360+ if len("manifestBlob") > 8192 {
361361+ return xerrors.Errorf("Value in field \"manifestBlob\" was too long")
362362+ }
363363+364364+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("manifestBlob"))); err != nil {
150365 return err
151366 }
152152- if _, err := cw.WriteString(string(v)); err != nil {
367367+ if _, err := cw.WriteString(string("manifestBlob")); err != nil {
153368 return err
154369 }
155370371371+ if err := t.ManifestBlob.MarshalCBOR(cw); err != nil {
372372+ return err
373373+ }
156374 }
375375+376376+ // t.SchemaVersion (int64) (int64)
377377+ if len("schemaVersion") > 8192 {
378378+ return xerrors.Errorf("Value in field \"schemaVersion\" was too long")
379379+ }
380380+381381+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("schemaVersion"))); err != nil {
382382+ return err
383383+ }
384384+ if _, err := cw.WriteString(string("schemaVersion")); err != nil {
385385+ return err
386386+ }
387387+388388+ if t.SchemaVersion >= 0 {
389389+ if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SchemaVersion)); err != nil {
390390+ return err
391391+ }
392392+ } else {
393393+ if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SchemaVersion-1)); err != nil {
394394+ return err
395395+ }
396396+ }
397397+157398 return nil
158399}
159400160160-func (t *CrewRecord) UnmarshalCBOR(r io.Reader) (err error) {
161161- *t = CrewRecord{}
401401+func (t *Manifest) UnmarshalCBOR(r io.Reader) (err error) {
402402+ *t = Manifest{}
162403163404 cr := cbg.NewCborReader(r)
164405···177418 }
178419179420 if extra > cbg.MaxLength {
180180- return fmt.Errorf("CrewRecord: map struct too large (%d)", extra)
421421+ return fmt.Errorf("Manifest: map struct too large (%d)", extra)
422422+ }
423423+424424+ n := extra
425425+426426+ nameBuf := make([]byte, 13)
427427+ for i := uint64(0); i < n; i++ {
428428+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
429429+ if err != nil {
430430+ return err
431431+ }
432432+433433+ if !ok {
434434+ // Field doesn't exist on this type, so ignore it
435435+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
436436+ return err
437437+ }
438438+ continue
439439+ }
440440+441441+ switch string(nameBuf[:nameLen]) {
442442+ // t.LexiconTypeID (string) (string)
443443+ case "$type":
444444+445445+ {
446446+ sval, err := cbg.ReadStringWithMax(cr, 8192)
447447+ if err != nil {
448448+ return err
449449+ }
450450+451451+ t.LexiconTypeID = string(sval)
452452+ }
453453+ // t.Config (atproto.Manifest_BlobReference) (struct)
454454+ case "config":
455455+456456+ {
457457+458458+ b, err := cr.ReadByte()
459459+ if err != nil {
460460+ return err
461461+ }
462462+ if b != cbg.CborNull[0] {
463463+ if err := cr.UnreadByte(); err != nil {
464464+ return err
465465+ }
466466+ t.Config = new(Manifest_BlobReference)
467467+ if err := t.Config.UnmarshalCBOR(cr); err != nil {
468468+ return xerrors.Errorf("unmarshaling t.Config pointer: %w", err)
469469+ }
470470+ }
471471+472472+ }
473473+ // t.Digest (string) (string)
474474+ case "digest":
475475+476476+ {
477477+ sval, err := cbg.ReadStringWithMax(cr, 8192)
478478+ if err != nil {
479479+ return err
480480+ }
481481+482482+ t.Digest = string(sval)
483483+ }
484484+ // t.Layers ([]atproto.Manifest_BlobReference) (slice)
485485+ case "layers":
486486+487487+ maj, extra, err = cr.ReadHeader()
488488+ if err != nil {
489489+ return err
490490+ }
491491+492492+ if extra > 8192 {
493493+ return fmt.Errorf("t.Layers: array too large (%d)", extra)
494494+ }
495495+496496+ if maj != cbg.MajArray {
497497+ return fmt.Errorf("expected cbor array")
498498+ }
499499+500500+ if extra > 0 {
501501+ t.Layers = make([]Manifest_BlobReference, extra)
502502+ }
503503+504504+ for i := 0; i < int(extra); i++ {
505505+ {
506506+ var maj byte
507507+ var extra uint64
508508+ var err error
509509+ _ = maj
510510+ _ = extra
511511+ _ = err
512512+513513+ {
514514+515515+ if err := t.Layers[i].UnmarshalCBOR(cr); err != nil {
516516+ return xerrors.Errorf("unmarshaling t.Layers[i]: %w", err)
517517+ }
518518+519519+ }
520520+521521+ }
522522+ }
523523+ // t.HoldDid (string) (string)
524524+ case "holdDid":
525525+526526+ {
527527+ b, err := cr.ReadByte()
528528+ if err != nil {
529529+ return err
530530+ }
531531+ if b != cbg.CborNull[0] {
532532+ if err := cr.UnreadByte(); err != nil {
533533+ return err
534534+ }
535535+536536+ sval, err := cbg.ReadStringWithMax(cr, 8192)
537537+ if err != nil {
538538+ return err
539539+ }
540540+541541+ t.HoldDid = (*string)(&sval)
542542+ }
543543+ }
544544+ // t.Subject (atproto.Manifest_BlobReference) (struct)
545545+ case "subject":
546546+547547+ {
548548+549549+ b, err := cr.ReadByte()
550550+ if err != nil {
551551+ return err
552552+ }
553553+ if b != cbg.CborNull[0] {
554554+ if err := cr.UnreadByte(); err != nil {
555555+ return err
556556+ }
557557+ t.Subject = new(Manifest_BlobReference)
558558+ if err := t.Subject.UnmarshalCBOR(cr); err != nil {
559559+ return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err)
560560+ }
561561+ }
562562+563563+ }
564564+ // t.CreatedAt (string) (string)
565565+ case "createdAt":
566566+567567+ {
568568+ sval, err := cbg.ReadStringWithMax(cr, 8192)
569569+ if err != nil {
570570+ return err
571571+ }
572572+573573+ t.CreatedAt = string(sval)
574574+ }
575575+ // t.Manifests ([]atproto.Manifest_ManifestReference) (slice)
576576+ case "manifests":
577577+578578+ maj, extra, err = cr.ReadHeader()
579579+ if err != nil {
580580+ return err
581581+ }
582582+583583+ if extra > 8192 {
584584+ return fmt.Errorf("t.Manifests: array too large (%d)", extra)
585585+ }
586586+587587+ if maj != cbg.MajArray {
588588+ return fmt.Errorf("expected cbor array")
589589+ }
590590+591591+ if extra > 0 {
592592+ t.Manifests = make([]Manifest_ManifestReference, extra)
593593+ }
594594+595595+ for i := 0; i < int(extra); i++ {
596596+ {
597597+ var maj byte
598598+ var extra uint64
599599+ var err error
600600+ _ = maj
601601+ _ = extra
602602+ _ = err
603603+604604+ {
605605+606606+ if err := t.Manifests[i].UnmarshalCBOR(cr); err != nil {
607607+ return xerrors.Errorf("unmarshaling t.Manifests[i]: %w", err)
608608+ }
609609+610610+ }
611611+612612+ }
613613+ }
614614+ // t.MediaType (string) (string)
615615+ case "mediaType":
616616+617617+ {
618618+ sval, err := cbg.ReadStringWithMax(cr, 8192)
619619+ if err != nil {
620620+ return err
621621+ }
622622+623623+ t.MediaType = string(sval)
624624+ }
625625+ // t.Repository (string) (string)
626626+ case "repository":
627627+628628+ {
629629+ sval, err := cbg.ReadStringWithMax(cr, 8192)
630630+ if err != nil {
631631+ return err
632632+ }
633633+634634+ t.Repository = string(sval)
635635+ }
636636+ // t.Annotations (atproto.Manifest_Annotations) (struct)
637637+ case "annotations":
638638+639639+ {
640640+641641+ b, err := cr.ReadByte()
642642+ if err != nil {
643643+ return err
644644+ }
645645+ if b != cbg.CborNull[0] {
646646+ if err := cr.UnreadByte(); err != nil {
647647+ return err
648648+ }
649649+ t.Annotations = new(Manifest_Annotations)
650650+ if err := t.Annotations.UnmarshalCBOR(cr); err != nil {
651651+ return xerrors.Errorf("unmarshaling t.Annotations pointer: %w", err)
652652+ }
653653+ }
654654+655655+ }
656656+ // t.HoldEndpoint (string) (string)
657657+ case "holdEndpoint":
658658+659659+ {
660660+ b, err := cr.ReadByte()
661661+ if err != nil {
662662+ return err
663663+ }
664664+ if b != cbg.CborNull[0] {
665665+ if err := cr.UnreadByte(); err != nil {
666666+ return err
667667+ }
668668+669669+ sval, err := cbg.ReadStringWithMax(cr, 8192)
670670+ if err != nil {
671671+ return err
672672+ }
673673+674674+ t.HoldEndpoint = (*string)(&sval)
675675+ }
676676+ }
677677+ // t.ManifestBlob (util.LexBlob) (struct)
678678+ case "manifestBlob":
679679+680680+ {
681681+682682+ b, err := cr.ReadByte()
683683+ if err != nil {
684684+ return err
685685+ }
686686+ if b != cbg.CborNull[0] {
687687+ if err := cr.UnreadByte(); err != nil {
688688+ return err
689689+ }
690690+ t.ManifestBlob = new(util.LexBlob)
691691+ if err := t.ManifestBlob.UnmarshalCBOR(cr); err != nil {
692692+ return xerrors.Errorf("unmarshaling t.ManifestBlob pointer: %w", err)
693693+ }
694694+ }
695695+696696+ }
697697+ // t.SchemaVersion (int64) (int64)
698698+ case "schemaVersion":
699699+ {
700700+ maj, extra, err := cr.ReadHeader()
701701+ if err != nil {
702702+ return err
703703+ }
704704+ var extraI int64
705705+ switch maj {
706706+ case cbg.MajUnsignedInt:
707707+ extraI = int64(extra)
708708+ if extraI < 0 {
709709+ return fmt.Errorf("int64 positive overflow")
710710+ }
711711+ case cbg.MajNegativeInt:
712712+ extraI = int64(extra)
713713+ if extraI < 0 {
714714+ return fmt.Errorf("int64 negative overflow")
715715+ }
716716+ extraI = -1 - extraI
717717+ default:
718718+ return fmt.Errorf("wrong type for int64 field: %d", maj)
719719+ }
720720+721721+ t.SchemaVersion = int64(extraI)
722722+ }
723723+724724+ default:
725725+ // Field doesn't exist on this type, so ignore it
726726+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
727727+ return err
728728+ }
729729+ }
730730+ }
731731+732732+ return nil
733733+}
734734+func (t *Manifest_BlobReference) MarshalCBOR(w io.Writer) error {
735735+ if t == nil {
736736+ _, err := w.Write(cbg.CborNull)
737737+ return err
738738+ }
739739+740740+ cw := cbg.NewCborWriter(w)
741741+ fieldCount := 6
742742+743743+ if t.LexiconTypeID == "" {
744744+ fieldCount--
745745+ }
746746+747747+ if t.Annotations == nil {
748748+ fieldCount--
749749+ }
750750+751751+ if t.Urls == nil {
752752+ fieldCount--
753753+ }
754754+755755+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
756756+ return err
757757+ }
758758+759759+ // t.Size (int64) (int64)
760760+ if len("size") > 8192 {
761761+ return xerrors.Errorf("Value in field \"size\" was too long")
762762+ }
763763+764764+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("size"))); err != nil {
765765+ return err
766766+ }
767767+ if _, err := cw.WriteString(string("size")); err != nil {
768768+ return err
769769+ }
770770+771771+ if t.Size >= 0 {
772772+ if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
773773+ return err
774774+ }
775775+ } else {
776776+ if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Size-1)); err != nil {
777777+ return err
778778+ }
779779+ }
780780+781781+ // t.Urls ([]string) (slice)
782782+ if t.Urls != nil {
783783+784784+ if len("urls") > 8192 {
785785+ return xerrors.Errorf("Value in field \"urls\" was too long")
786786+ }
787787+788788+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("urls"))); err != nil {
789789+ return err
790790+ }
791791+ if _, err := cw.WriteString(string("urls")); err != nil {
792792+ return err
793793+ }
794794+795795+ if len(t.Urls) > 8192 {
796796+ return xerrors.Errorf("Slice value in field t.Urls was too long")
797797+ }
798798+799799+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Urls))); err != nil {
800800+ return err
801801+ }
802802+ for _, v := range t.Urls {
803803+ if len(v) > 8192 {
804804+ return xerrors.Errorf("Value in field v was too long")
805805+ }
806806+807807+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
808808+ return err
809809+ }
810810+ if _, err := cw.WriteString(string(v)); err != nil {
811811+ return err
812812+ }
813813+814814+ }
815815+ }
816816+817817+ // t.LexiconTypeID (string) (string)
818818+ if t.LexiconTypeID != "" {
819819+820820+ if len("$type") > 8192 {
821821+ return xerrors.Errorf("Value in field \"$type\" was too long")
822822+ }
823823+824824+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
825825+ return err
826826+ }
827827+ if _, err := cw.WriteString(string("$type")); err != nil {
828828+ return err
829829+ }
830830+831831+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.manifest#blobReference"))); err != nil {
832832+ return err
833833+ }
834834+ if _, err := cw.WriteString(string("io.atcr.manifest#blobReference")); err != nil {
835835+ return err
836836+ }
837837+ }
838838+839839+ // t.Digest (string) (string)
840840+ if len("digest") > 8192 {
841841+ return xerrors.Errorf("Value in field \"digest\" was too long")
842842+ }
843843+844844+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("digest"))); err != nil {
845845+ return err
846846+ }
847847+ if _, err := cw.WriteString(string("digest")); err != nil {
848848+ return err
849849+ }
850850+851851+ if len(t.Digest) > 8192 {
852852+ return xerrors.Errorf("Value in field t.Digest was too long")
853853+ }
854854+855855+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Digest))); err != nil {
856856+ return err
857857+ }
858858+ if _, err := cw.WriteString(string(t.Digest)); err != nil {
859859+ return err
860860+ }
861861+862862+ // t.MediaType (string) (string)
863863+ if len("mediaType") > 8192 {
864864+ return xerrors.Errorf("Value in field \"mediaType\" was too long")
865865+ }
866866+867867+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mediaType"))); err != nil {
868868+ return err
869869+ }
870870+ if _, err := cw.WriteString(string("mediaType")); err != nil {
871871+ return err
872872+ }
873873+874874+ if len(t.MediaType) > 8192 {
875875+ return xerrors.Errorf("Value in field t.MediaType was too long")
876876+ }
877877+878878+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.MediaType))); err != nil {
879879+ return err
880880+ }
881881+ if _, err := cw.WriteString(string(t.MediaType)); err != nil {
882882+ return err
883883+ }
884884+885885+ // t.Annotations (atproto.Manifest_BlobReference_Annotations) (struct)
886886+ if t.Annotations != nil {
887887+888888+ if len("annotations") > 8192 {
889889+ return xerrors.Errorf("Value in field \"annotations\" was too long")
890890+ }
891891+892892+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("annotations"))); err != nil {
893893+ return err
894894+ }
895895+ if _, err := cw.WriteString(string("annotations")); err != nil {
896896+ return err
897897+ }
898898+899899+ if err := t.Annotations.MarshalCBOR(cw); err != nil {
900900+ return err
901901+ }
902902+ }
903903+ return nil
904904+}
905905+906906+func (t *Manifest_BlobReference) UnmarshalCBOR(r io.Reader) (err error) {
907907+ *t = Manifest_BlobReference{}
908908+909909+ cr := cbg.NewCborReader(r)
910910+911911+ maj, extra, err := cr.ReadHeader()
912912+ if err != nil {
913913+ return err
914914+ }
915915+ defer func() {
916916+ if err == io.EOF {
917917+ err = io.ErrUnexpectedEOF
918918+ }
919919+ }()
920920+921921+ if maj != cbg.MajMap {
922922+ return fmt.Errorf("cbor input should be of type map")
923923+ }
924924+925925+ if extra > cbg.MaxLength {
926926+ return fmt.Errorf("Manifest_BlobReference: map struct too large (%d)", extra)
181927 }
182928183929 n := extra
···198944 }
199945200946 switch string(nameBuf[:nameLen]) {
201201- // t.Role (string) (string)
202202- case "role":
947947+ // t.Size (int64) (int64)
948948+ case "size":
949949+ {
950950+ maj, extra, err := cr.ReadHeader()
951951+ if err != nil {
952952+ return err
953953+ }
954954+ var extraI int64
955955+ switch maj {
956956+ case cbg.MajUnsignedInt:
957957+ extraI = int64(extra)
958958+ if extraI < 0 {
959959+ return fmt.Errorf("int64 positive overflow")
960960+ }
961961+ case cbg.MajNegativeInt:
962962+ extraI = int64(extra)
963963+ if extraI < 0 {
964964+ return fmt.Errorf("int64 negative overflow")
965965+ }
966966+ extraI = -1 - extraI
967967+ default:
968968+ return fmt.Errorf("wrong type for int64 field: %d", maj)
969969+ }
970970+971971+ t.Size = int64(extraI)
972972+ }
973973+ // t.Urls ([]string) (slice)
974974+ case "urls":
975975+976976+ maj, extra, err = cr.ReadHeader()
977977+ if err != nil {
978978+ return err
979979+ }
980980+981981+ if extra > 8192 {
982982+ return fmt.Errorf("t.Urls: array too large (%d)", extra)
983983+ }
984984+985985+ if maj != cbg.MajArray {
986986+ return fmt.Errorf("expected cbor array")
987987+ }
988988+989989+ if extra > 0 {
990990+ t.Urls = make([]string, extra)
991991+ }
992992+993993+ for i := 0; i < int(extra); i++ {
994994+ {
995995+ var maj byte
996996+ var extra uint64
997997+ var err error
998998+ _ = maj
999999+ _ = extra
10001000+ _ = err
10011001+10021002+ {
10031003+ sval, err := cbg.ReadStringWithMax(cr, 8192)
10041004+ if err != nil {
10051005+ return err
10061006+ }
10071007+10081008+ t.Urls[i] = string(sval)
10091009+ }
10101010+10111011+ }
10121012+ }
10131013+ // t.LexiconTypeID (string) (string)
10141014+ case "$type":
20310152041016 {
2051017 sval, err := cbg.ReadStringWithMax(cr, 8192)
···2071019 return err
2081020 }
2091021210210- t.Role = string(sval)
10221022+ t.LexiconTypeID = string(sval)
10231023+ }
10241024+ // t.Digest (string) (string)
10251025+ case "digest":
10261026+10271027+ {
10281028+ sval, err := cbg.ReadStringWithMax(cr, 8192)
10291029+ if err != nil {
10301030+ return err
10311031+ }
10321032+10331033+ t.Digest = string(sval)
10341034+ }
10351035+ // t.MediaType (string) (string)
10361036+ case "mediaType":
10371037+10381038+ {
10391039+ sval, err := cbg.ReadStringWithMax(cr, 8192)
10401040+ if err != nil {
10411041+ return err
10421042+ }
10431043+10441044+ t.MediaType = string(sval)
10451045+ }
10461046+ // t.Annotations (atproto.Manifest_BlobReference_Annotations) (struct)
10471047+ case "annotations":
10481048+10491049+ {
10501050+10511051+ b, err := cr.ReadByte()
10521052+ if err != nil {
10531053+ return err
10541054+ }
10551055+ if b != cbg.CborNull[0] {
10561056+ if err := cr.UnreadByte(); err != nil {
10571057+ return err
10581058+ }
10591059+ t.Annotations = new(Manifest_BlobReference_Annotations)
10601060+ if err := t.Annotations.UnmarshalCBOR(cr); err != nil {
10611061+ return xerrors.Errorf("unmarshaling t.Annotations pointer: %w", err)
10621062+ }
10631063+ }
10641064+10651065+ }
10661066+10671067+ default:
10681068+ // Field doesn't exist on this type, so ignore it
10691069+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
10701070+ return err
10711071+ }
10721072+ }
10731073+ }
10741074+10751075+ return nil
10761076+}
10771077+func (t *Manifest_ManifestReference) MarshalCBOR(w io.Writer) error {
10781078+ if t == nil {
10791079+ _, err := w.Write(cbg.CborNull)
10801080+ return err
10811081+ }
10821082+10831083+ cw := cbg.NewCborWriter(w)
10841084+ fieldCount := 6
10851085+10861086+ if t.LexiconTypeID == "" {
10871087+ fieldCount--
10881088+ }
10891089+10901090+ if t.Annotations == nil {
10911091+ fieldCount--
10921092+ }
10931093+10941094+ if t.Platform == nil {
10951095+ fieldCount--
10961096+ }
10971097+10981098+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
10991099+ return err
11001100+ }
11011101+11021102+ // t.Size (int64) (int64)
11031103+ if len("size") > 8192 {
11041104+ return xerrors.Errorf("Value in field \"size\" was too long")
11051105+ }
11061106+11071107+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("size"))); err != nil {
11081108+ return err
11091109+ }
11101110+ if _, err := cw.WriteString(string("size")); err != nil {
11111111+ return err
11121112+ }
11131113+11141114+ if t.Size >= 0 {
11151115+ if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
11161116+ return err
11171117+ }
11181118+ } else {
11191119+ if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Size-1)); err != nil {
11201120+ return err
11211121+ }
11221122+ }
11231123+11241124+ // t.LexiconTypeID (string) (string)
11251125+ if t.LexiconTypeID != "" {
11261126+11271127+ if len("$type") > 8192 {
11281128+ return xerrors.Errorf("Value in field \"$type\" was too long")
11291129+ }
11301130+11311131+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
11321132+ return err
11331133+ }
11341134+ if _, err := cw.WriteString(string("$type")); err != nil {
11351135+ return err
11361136+ }
11371137+11381138+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.manifest#manifestReference"))); err != nil {
11391139+ return err
11401140+ }
11411141+ if _, err := cw.WriteString(string("io.atcr.manifest#manifestReference")); err != nil {
11421142+ return err
11431143+ }
11441144+ }
11451145+11461146+ // t.Digest (string) (string)
11471147+ if len("digest") > 8192 {
11481148+ return xerrors.Errorf("Value in field \"digest\" was too long")
11491149+ }
11501150+11511151+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("digest"))); err != nil {
11521152+ return err
11531153+ }
11541154+ if _, err := cw.WriteString(string("digest")); err != nil {
11551155+ return err
11561156+ }
11571157+11581158+ if len(t.Digest) > 8192 {
11591159+ return xerrors.Errorf("Value in field t.Digest was too long")
11601160+ }
11611161+11621162+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Digest))); err != nil {
11631163+ return err
11641164+ }
11651165+ if _, err := cw.WriteString(string(t.Digest)); err != nil {
11661166+ return err
11671167+ }
11681168+11691169+ // t.Platform (atproto.Manifest_Platform) (struct)
11701170+ if t.Platform != nil {
11711171+11721172+ if len("platform") > 8192 {
11731173+ return xerrors.Errorf("Value in field \"platform\" was too long")
11741174+ }
11751175+11761176+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("platform"))); err != nil {
11771177+ return err
11781178+ }
11791179+ if _, err := cw.WriteString(string("platform")); err != nil {
11801180+ return err
11811181+ }
11821182+11831183+ if err := t.Platform.MarshalCBOR(cw); err != nil {
11841184+ return err
11851185+ }
11861186+ }
11871187+11881188+ // t.MediaType (string) (string)
11891189+ if len("mediaType") > 8192 {
11901190+ return xerrors.Errorf("Value in field \"mediaType\" was too long")
11911191+ }
11921192+11931193+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mediaType"))); err != nil {
11941194+ return err
11951195+ }
11961196+ if _, err := cw.WriteString(string("mediaType")); err != nil {
11971197+ return err
11981198+ }
11991199+12001200+ if len(t.MediaType) > 8192 {
12011201+ return xerrors.Errorf("Value in field t.MediaType was too long")
12021202+ }
12031203+12041204+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.MediaType))); err != nil {
12051205+ return err
12061206+ }
12071207+ if _, err := cw.WriteString(string(t.MediaType)); err != nil {
12081208+ return err
12091209+ }
12101210+12111211+ // t.Annotations (atproto.Manifest_ManifestReference_Annotations) (struct)
12121212+ if t.Annotations != nil {
12131213+12141214+ if len("annotations") > 8192 {
12151215+ return xerrors.Errorf("Value in field \"annotations\" was too long")
12161216+ }
12171217+12181218+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("annotations"))); err != nil {
12191219+ return err
12201220+ }
12211221+ if _, err := cw.WriteString(string("annotations")); err != nil {
12221222+ return err
12231223+ }
12241224+12251225+ if err := t.Annotations.MarshalCBOR(cw); err != nil {
12261226+ return err
12271227+ }
12281228+ }
12291229+ return nil
12301230+}
12311231+12321232+func (t *Manifest_ManifestReference) UnmarshalCBOR(r io.Reader) (err error) {
12331233+ *t = Manifest_ManifestReference{}
12341234+12351235+ cr := cbg.NewCborReader(r)
12361236+12371237+ maj, extra, err := cr.ReadHeader()
12381238+ if err != nil {
12391239+ return err
12401240+ }
12411241+ defer func() {
12421242+ if err == io.EOF {
12431243+ err = io.ErrUnexpectedEOF
12441244+ }
12451245+ }()
12461246+12471247+ if maj != cbg.MajMap {
12481248+ return fmt.Errorf("cbor input should be of type map")
12491249+ }
12501250+12511251+ if extra > cbg.MaxLength {
12521252+ return fmt.Errorf("Manifest_ManifestReference: map struct too large (%d)", extra)
12531253+ }
12541254+12551255+ n := extra
12561256+12571257+ nameBuf := make([]byte, 11)
12581258+ for i := uint64(0); i < n; i++ {
12591259+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
12601260+ if err != nil {
12611261+ return err
12621262+ }
12631263+12641264+ if !ok {
12651265+ // Field doesn't exist on this type, so ignore it
12661266+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
12671267+ return err
12681268+ }
12691269+ continue
12701270+ }
12711271+12721272+ switch string(nameBuf[:nameLen]) {
12731273+ // t.Size (int64) (int64)
12741274+ case "size":
12751275+ {
12761276+ maj, extra, err := cr.ReadHeader()
12771277+ if err != nil {
12781278+ return err
12791279+ }
12801280+ var extraI int64
12811281+ switch maj {
12821282+ case cbg.MajUnsignedInt:
12831283+ extraI = int64(extra)
12841284+ if extraI < 0 {
12851285+ return fmt.Errorf("int64 positive overflow")
12861286+ }
12871287+ case cbg.MajNegativeInt:
12881288+ extraI = int64(extra)
12891289+ if extraI < 0 {
12901290+ return fmt.Errorf("int64 negative overflow")
12911291+ }
12921292+ extraI = -1 - extraI
12931293+ default:
12941294+ return fmt.Errorf("wrong type for int64 field: %d", maj)
12951295+ }
12961296+12971297+ t.Size = int64(extraI)
2111298 }
212212- // t.Type (string) (string)
12991299+ // t.LexiconTypeID (string) (string)
2131300 case "$type":
21413012151302 {
···2181305 return err
2191306 }
2201307221221- t.Type = string(sval)
13081308+ t.LexiconTypeID = string(sval)
13091309+ }
13101310+ // t.Digest (string) (string)
13111311+ case "digest":
13121312+13131313+ {
13141314+ sval, err := cbg.ReadStringWithMax(cr, 8192)
13151315+ if err != nil {
13161316+ return err
13171317+ }
13181318+13191319+ t.Digest = string(sval)
13201320+ }
13211321+ // t.Platform (atproto.Manifest_Platform) (struct)
13221322+ case "platform":
13231323+13241324+ {
13251325+13261326+ b, err := cr.ReadByte()
13271327+ if err != nil {
13281328+ return err
13291329+ }
13301330+ if b != cbg.CborNull[0] {
13311331+ if err := cr.UnreadByte(); err != nil {
13321332+ return err
13331333+ }
13341334+ t.Platform = new(Manifest_Platform)
13351335+ if err := t.Platform.UnmarshalCBOR(cr); err != nil {
13361336+ return xerrors.Errorf("unmarshaling t.Platform pointer: %w", err)
13371337+ }
13381338+ }
13391339+13401340+ }
13411341+ // t.MediaType (string) (string)
13421342+ case "mediaType":
13431343+13441344+ {
13451345+ sval, err := cbg.ReadStringWithMax(cr, 8192)
13461346+ if err != nil {
13471347+ return err
13481348+ }
13491349+13501350+ t.MediaType = string(sval)
13511351+ }
13521352+ // t.Annotations (atproto.Manifest_ManifestReference_Annotations) (struct)
13531353+ case "annotations":
13541354+13551355+ {
13561356+13571357+ b, err := cr.ReadByte()
13581358+ if err != nil {
13591359+ return err
13601360+ }
13611361+ if b != cbg.CborNull[0] {
13621362+ if err := cr.UnreadByte(); err != nil {
13631363+ return err
13641364+ }
13651365+ t.Annotations = new(Manifest_ManifestReference_Annotations)
13661366+ if err := t.Annotations.UnmarshalCBOR(cr); err != nil {
13671367+ return xerrors.Errorf("unmarshaling t.Annotations pointer: %w", err)
13681368+ }
13691369+ }
13701370+13711371+ }
13721372+13731373+ default:
13741374+ // Field doesn't exist on this type, so ignore it
13751375+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
13761376+ return err
13771377+ }
13781378+ }
13791379+ }
13801380+13811381+ return nil
13821382+}
13831383+func (t *Manifest_Platform) MarshalCBOR(w io.Writer) error {
13841384+ if t == nil {
13851385+ _, err := w.Write(cbg.CborNull)
13861386+ return err
13871387+ }
13881388+13891389+ cw := cbg.NewCborWriter(w)
13901390+ fieldCount := 6
13911391+13921392+ if t.LexiconTypeID == "" {
13931393+ fieldCount--
13941394+ }
13951395+13961396+ if t.OsFeatures == nil {
13971397+ fieldCount--
13981398+ }
13991399+14001400+ if t.OsVersion == nil {
14011401+ fieldCount--
14021402+ }
14031403+14041404+ if t.Variant == nil {
14051405+ fieldCount--
14061406+ }
14071407+14081408+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
14091409+ return err
14101410+ }
14111411+14121412+ // t.Os (string) (string)
14131413+ if len("os") > 8192 {
14141414+ return xerrors.Errorf("Value in field \"os\" was too long")
14151415+ }
14161416+14171417+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("os"))); err != nil {
14181418+ return err
14191419+ }
14201420+ if _, err := cw.WriteString(string("os")); err != nil {
14211421+ return err
14221422+ }
14231423+14241424+ if len(t.Os) > 8192 {
14251425+ return xerrors.Errorf("Value in field t.Os was too long")
14261426+ }
14271427+14281428+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Os))); err != nil {
14291429+ return err
14301430+ }
14311431+ if _, err := cw.WriteString(string(t.Os)); err != nil {
14321432+ return err
14331433+ }
14341434+14351435+ // t.LexiconTypeID (string) (string)
14361436+ if t.LexiconTypeID != "" {
14371437+14381438+ if len("$type") > 8192 {
14391439+ return xerrors.Errorf("Value in field \"$type\" was too long")
14401440+ }
14411441+14421442+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
14431443+ return err
14441444+ }
14451445+ if _, err := cw.WriteString(string("$type")); err != nil {
14461446+ return err
14471447+ }
14481448+14491449+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.manifest#platform"))); err != nil {
14501450+ return err
14511451+ }
14521452+ if _, err := cw.WriteString(string("io.atcr.manifest#platform")); err != nil {
14531453+ return err
14541454+ }
14551455+ }
14561456+14571457+ // t.Variant (string) (string)
14581458+ if t.Variant != nil {
14591459+14601460+ if len("variant") > 8192 {
14611461+ return xerrors.Errorf("Value in field \"variant\" was too long")
14621462+ }
14631463+14641464+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("variant"))); err != nil {
14651465+ return err
14661466+ }
14671467+ if _, err := cw.WriteString(string("variant")); err != nil {
14681468+ return err
14691469+ }
14701470+14711471+ if t.Variant == nil {
14721472+ if _, err := cw.Write(cbg.CborNull); err != nil {
14731473+ return err
2221474 }
223223- // t.Member (string) (string)
224224- case "member":
14751475+ } else {
14761476+ if len(*t.Variant) > 8192 {
14771477+ return xerrors.Errorf("Value in field t.Variant was too long")
14781478+ }
14791479+14801480+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Variant))); err != nil {
14811481+ return err
14821482+ }
14831483+ if _, err := cw.WriteString(string(*t.Variant)); err != nil {
14841484+ return err
14851485+ }
14861486+ }
14871487+ }
14881488+14891489+ // t.OsVersion (string) (string)
14901490+ if t.OsVersion != nil {
14911491+14921492+ if len("osVersion") > 8192 {
14931493+ return xerrors.Errorf("Value in field \"osVersion\" was too long")
14941494+ }
14951495+14961496+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("osVersion"))); err != nil {
14971497+ return err
14981498+ }
14991499+ if _, err := cw.WriteString(string("osVersion")); err != nil {
15001500+ return err
15011501+ }
15021502+15031503+ if t.OsVersion == nil {
15041504+ if _, err := cw.Write(cbg.CborNull); err != nil {
15051505+ return err
15061506+ }
15071507+ } else {
15081508+ if len(*t.OsVersion) > 8192 {
15091509+ return xerrors.Errorf("Value in field t.OsVersion was too long")
15101510+ }
15111511+15121512+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OsVersion))); err != nil {
15131513+ return err
15141514+ }
15151515+ if _, err := cw.WriteString(string(*t.OsVersion)); err != nil {
15161516+ return err
15171517+ }
15181518+ }
15191519+ }
15201520+15211521+ // t.OsFeatures ([]string) (slice)
15221522+ if t.OsFeatures != nil {
15231523+15241524+ if len("osFeatures") > 8192 {
15251525+ return xerrors.Errorf("Value in field \"osFeatures\" was too long")
15261526+ }
15271527+15281528+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("osFeatures"))); err != nil {
15291529+ return err
15301530+ }
15311531+ if _, err := cw.WriteString(string("osFeatures")); err != nil {
15321532+ return err
15331533+ }
15341534+15351535+ if len(t.OsFeatures) > 8192 {
15361536+ return xerrors.Errorf("Slice value in field t.OsFeatures was too long")
15371537+ }
15381538+15391539+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.OsFeatures))); err != nil {
15401540+ return err
15411541+ }
15421542+ for _, v := range t.OsFeatures {
15431543+ if len(v) > 8192 {
15441544+ return xerrors.Errorf("Value in field v was too long")
15451545+ }
15461546+15471547+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
15481548+ return err
15491549+ }
15501550+ if _, err := cw.WriteString(string(v)); err != nil {
15511551+ return err
15521552+ }
15531553+15541554+ }
15551555+ }
15561556+15571557+ // t.Architecture (string) (string)
15581558+ if len("architecture") > 8192 {
15591559+ return xerrors.Errorf("Value in field \"architecture\" was too long")
15601560+ }
15611561+15621562+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("architecture"))); err != nil {
15631563+ return err
15641564+ }
15651565+ if _, err := cw.WriteString(string("architecture")); err != nil {
15661566+ return err
15671567+ }
15681568+15691569+ if len(t.Architecture) > 8192 {
15701570+ return xerrors.Errorf("Value in field t.Architecture was too long")
15711571+ }
15721572+15731573+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Architecture))); err != nil {
15741574+ return err
15751575+ }
15761576+ if _, err := cw.WriteString(string(t.Architecture)); err != nil {
15771577+ return err
15781578+ }
15791579+ return nil
15801580+}
15811581+15821582+func (t *Manifest_Platform) UnmarshalCBOR(r io.Reader) (err error) {
15831583+ *t = Manifest_Platform{}
15841584+15851585+ cr := cbg.NewCborReader(r)
15861586+15871587+ maj, extra, err := cr.ReadHeader()
15881588+ if err != nil {
15891589+ return err
15901590+ }
15911591+ defer func() {
15921592+ if err == io.EOF {
15931593+ err = io.ErrUnexpectedEOF
15941594+ }
15951595+ }()
15961596+15971597+ if maj != cbg.MajMap {
15981598+ return fmt.Errorf("cbor input should be of type map")
15991599+ }
16001600+16011601+ if extra > cbg.MaxLength {
16021602+ return fmt.Errorf("Manifest_Platform: map struct too large (%d)", extra)
16031603+ }
16041604+16051605+ n := extra
16061606+16071607+ nameBuf := make([]byte, 12)
16081608+ for i := uint64(0); i < n; i++ {
16091609+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
16101610+ if err != nil {
16111611+ return err
16121612+ }
16131613+16141614+ if !ok {
16151615+ // Field doesn't exist on this type, so ignore it
16161616+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
16171617+ return err
16181618+ }
16191619+ continue
16201620+ }
16211621+16221622+ switch string(nameBuf[:nameLen]) {
16231623+ // t.Os (string) (string)
16241624+ case "os":
22516252261626 {
2271627 sval, err := cbg.ReadStringWithMax(cr, 8192)
···2291629 return err
2301630 }
2311631232232- t.Member = string(sval)
16321632+ t.Os = string(sval)
2331633 }
234234- // t.AddedAt (string) (string)
235235- case "addedAt":
16341634+ // t.LexiconTypeID (string) (string)
16351635+ case "$type":
23616362371637 {
2381638 sval, err := cbg.ReadStringWithMax(cr, 8192)
···2401640 return err
2411641 }
2421642243243- t.AddedAt = string(sval)
16431643+ t.LexiconTypeID = string(sval)
2441644 }
245245- // t.Permissions ([]string) (slice)
246246- case "permissions":
16451645+ // t.Variant (string) (string)
16461646+ case "variant":
16471647+16481648+ {
16491649+ b, err := cr.ReadByte()
16501650+ if err != nil {
16511651+ return err
16521652+ }
16531653+ if b != cbg.CborNull[0] {
16541654+ if err := cr.UnreadByte(); err != nil {
16551655+ return err
16561656+ }
16571657+16581658+ sval, err := cbg.ReadStringWithMax(cr, 8192)
16591659+ if err != nil {
16601660+ return err
16611661+ }
16621662+16631663+ t.Variant = (*string)(&sval)
16641664+ }
16651665+ }
16661666+ // t.OsVersion (string) (string)
16671667+ case "osVersion":
16681668+16691669+ {
16701670+ b, err := cr.ReadByte()
16711671+ if err != nil {
16721672+ return err
16731673+ }
16741674+ if b != cbg.CborNull[0] {
16751675+ if err := cr.UnreadByte(); err != nil {
16761676+ return err
16771677+ }
16781678+16791679+ sval, err := cbg.ReadStringWithMax(cr, 8192)
16801680+ if err != nil {
16811681+ return err
16821682+ }
16831683+16841684+ t.OsVersion = (*string)(&sval)
16851685+ }
16861686+ }
16871687+ // t.OsFeatures ([]string) (slice)
16881688+ case "osFeatures":
24716892481690 maj, extra, err = cr.ReadHeader()
2491691 if err != nil {
···2511693 }
25216942531695 if extra > 8192 {
254254- return fmt.Errorf("t.Permissions: array too large (%d)", extra)
16961696+ return fmt.Errorf("t.OsFeatures: array too large (%d)", extra)
2551697 }
25616982571699 if maj != cbg.MajArray {
···2591701 }
26017022611703 if extra > 0 {
262262- t.Permissions = make([]string, extra)
17041704+ t.OsFeatures = make([]string, extra)
2631705 }
26417062651707 for i := 0; i < int(extra); i++ {
···2771719 return err
2781720 }
2791721280280- t.Permissions[i] = string(sval)
17221722+ t.OsFeatures[i] = string(sval)
17231723+ }
17241724+17251725+ }
17261726+ }
17271727+ // t.Architecture (string) (string)
17281728+ case "architecture":
17291729+17301730+ {
17311731+ sval, err := cbg.ReadStringWithMax(cr, 8192)
17321732+ if err != nil {
17331733+ return err
17341734+ }
17351735+17361736+ t.Architecture = string(sval)
17371737+ }
17381738+17391739+ default:
17401740+ // Field doesn't exist on this type, so ignore it
17411741+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
17421742+ return err
17431743+ }
17441744+ }
17451745+ }
17461746+17471747+ return nil
17481748+}
17491749+func (t *Manifest_Annotations) MarshalCBOR(w io.Writer) error {
17501750+ if t == nil {
17511751+ _, err := w.Write(cbg.CborNull)
17521752+ return err
17531753+ }
17541754+17551755+ cw := cbg.NewCborWriter(w)
17561756+17571757+ if _, err := cw.Write([]byte{160}); err != nil {
17581758+ return err
17591759+ }
17601760+ return nil
17611761+}
17621762+17631763+func (t *Manifest_Annotations) UnmarshalCBOR(r io.Reader) (err error) {
17641764+ *t = Manifest_Annotations{}
17651765+17661766+ cr := cbg.NewCborReader(r)
17671767+17681768+ maj, extra, err := cr.ReadHeader()
17691769+ if err != nil {
17701770+ return err
17711771+ }
17721772+ defer func() {
17731773+ if err == io.EOF {
17741774+ err = io.ErrUnexpectedEOF
17751775+ }
17761776+ }()
17771777+17781778+ if maj != cbg.MajMap {
17791779+ return fmt.Errorf("cbor input should be of type map")
17801780+ }
17811781+17821782+ if extra > cbg.MaxLength {
17831783+ return fmt.Errorf("Manifest_Annotations: map struct too large (%d)", extra)
17841784+ }
17851785+17861786+ n := extra
17871787+17881788+ nameBuf := make([]byte, 0)
17891789+ for i := uint64(0); i < n; i++ {
17901790+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
17911791+ if err != nil {
17921792+ return err
17931793+ }
17941794+17951795+ if !ok {
17961796+ // Field doesn't exist on this type, so ignore it
17971797+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
17981798+ return err
17991799+ }
18001800+ continue
18011801+ }
18021802+18031803+ switch string(nameBuf[:nameLen]) {
18041804+18051805+ default:
18061806+ // Field doesn't exist on this type, so ignore it
18071807+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
18081808+ return err
18091809+ }
18101810+ }
18111811+ }
18121812+18131813+ return nil
18141814+}
18151815+func (t *Manifest_BlobReference_Annotations) MarshalCBOR(w io.Writer) error {
18161816+ if t == nil {
18171817+ _, err := w.Write(cbg.CborNull)
18181818+ return err
18191819+ }
18201820+18211821+ cw := cbg.NewCborWriter(w)
18221822+18231823+ if _, err := cw.Write([]byte{160}); err != nil {
18241824+ return err
18251825+ }
18261826+ return nil
18271827+}
18281828+18291829+func (t *Manifest_BlobReference_Annotations) UnmarshalCBOR(r io.Reader) (err error) {
18301830+ *t = Manifest_BlobReference_Annotations{}
18311831+18321832+ cr := cbg.NewCborReader(r)
18331833+18341834+ maj, extra, err := cr.ReadHeader()
18351835+ if err != nil {
18361836+ return err
18371837+ }
18381838+ defer func() {
18391839+ if err == io.EOF {
18401840+ err = io.ErrUnexpectedEOF
18411841+ }
18421842+ }()
18431843+18441844+ if maj != cbg.MajMap {
18451845+ return fmt.Errorf("cbor input should be of type map")
18461846+ }
18471847+18481848+ if extra > cbg.MaxLength {
18491849+ return fmt.Errorf("Manifest_BlobReference_Annotations: map struct too large (%d)", extra)
18501850+ }
18511851+18521852+ n := extra
18531853+18541854+ nameBuf := make([]byte, 0)
18551855+ for i := uint64(0); i < n; i++ {
18561856+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
18571857+ if err != nil {
18581858+ return err
18591859+ }
18601860+18611861+ if !ok {
18621862+ // Field doesn't exist on this type, so ignore it
18631863+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
18641864+ return err
18651865+ }
18661866+ continue
18671867+ }
18681868+18691869+ switch string(nameBuf[:nameLen]) {
18701870+18711871+ default:
18721872+ // Field doesn't exist on this type, so ignore it
18731873+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
18741874+ return err
18751875+ }
18761876+ }
18771877+ }
18781878+18791879+ return nil
18801880+}
18811881+func (t *Manifest_ManifestReference_Annotations) MarshalCBOR(w io.Writer) error {
18821882+ if t == nil {
18831883+ _, err := w.Write(cbg.CborNull)
18841884+ return err
18851885+ }
18861886+18871887+ cw := cbg.NewCborWriter(w)
18881888+18891889+ if _, err := cw.Write([]byte{160}); err != nil {
18901890+ return err
18911891+ }
18921892+ return nil
18931893+}
18941894+18951895+func (t *Manifest_ManifestReference_Annotations) UnmarshalCBOR(r io.Reader) (err error) {
18961896+ *t = Manifest_ManifestReference_Annotations{}
18971897+18981898+ cr := cbg.NewCborReader(r)
18991899+19001900+ maj, extra, err := cr.ReadHeader()
19011901+ if err != nil {
19021902+ return err
19031903+ }
19041904+ defer func() {
19051905+ if err == io.EOF {
19061906+ err = io.ErrUnexpectedEOF
19071907+ }
19081908+ }()
19091909+19101910+ if maj != cbg.MajMap {
19111911+ return fmt.Errorf("cbor input should be of type map")
19121912+ }
19131913+19141914+ if extra > cbg.MaxLength {
19151915+ return fmt.Errorf("Manifest_ManifestReference_Annotations: map struct too large (%d)", extra)
19161916+ }
19171917+19181918+ n := extra
19191919+19201920+ nameBuf := make([]byte, 0)
19211921+ for i := uint64(0); i < n; i++ {
19221922+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
19231923+ if err != nil {
19241924+ return err
19251925+ }
19261926+19271927+ if !ok {
19281928+ // Field doesn't exist on this type, so ignore it
19291929+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
19301930+ return err
19311931+ }
19321932+ continue
19331933+ }
19341934+19351935+ switch string(nameBuf[:nameLen]) {
19361936+19371937+ default:
19381938+ // Field doesn't exist on this type, so ignore it
19391939+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
19401940+ return err
19411941+ }
19421942+ }
19431943+ }
19441944+19451945+ return nil
19461946+}
19471947+func (t *Tag) MarshalCBOR(w io.Writer) error {
19481948+ if t == nil {
19491949+ _, err := w.Write(cbg.CborNull)
19501950+ return err
19511951+ }
19521952+19531953+ cw := cbg.NewCborWriter(w)
19541954+ fieldCount := 6
19551955+19561956+ if t.Manifest == nil {
19571957+ fieldCount--
19581958+ }
19591959+19601960+ if t.ManifestDigest == nil {
19611961+ fieldCount--
19621962+ }
19631963+19641964+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
19651965+ return err
19661966+ }
19671967+19681968+ // t.Tag (string) (string)
19691969+ if len("tag") > 8192 {
19701970+ return xerrors.Errorf("Value in field \"tag\" was too long")
19711971+ }
19721972+19731973+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("tag"))); err != nil {
19741974+ return err
19751975+ }
19761976+ if _, err := cw.WriteString(string("tag")); err != nil {
19771977+ return err
19781978+ }
19791979+19801980+ if len(t.Tag) > 8192 {
19811981+ return xerrors.Errorf("Value in field t.Tag was too long")
19821982+ }
19831983+19841984+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Tag))); err != nil {
19851985+ return err
19861986+ }
19871987+ if _, err := cw.WriteString(string(t.Tag)); err != nil {
19881988+ return err
19891989+ }
19901990+19911991+ // t.LexiconTypeID (string) (string)
19921992+ if len("$type") > 8192 {
19931993+ return xerrors.Errorf("Value in field \"$type\" was too long")
19941994+ }
19951995+19961996+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
19971997+ return err
19981998+ }
19991999+ if _, err := cw.WriteString(string("$type")); err != nil {
20002000+ return err
20012001+ }
20022002+20032003+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.tag"))); err != nil {
20042004+ return err
20052005+ }
20062006+ if _, err := cw.WriteString(string("io.atcr.tag")); err != nil {
20072007+ return err
20082008+ }
20092009+20102010+ // t.Manifest (string) (string)
20112011+ if t.Manifest != nil {
20122012+20132013+ if len("manifest") > 8192 {
20142014+ return xerrors.Errorf("Value in field \"manifest\" was too long")
20152015+ }
20162016+20172017+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("manifest"))); err != nil {
20182018+ return err
20192019+ }
20202020+ if _, err := cw.WriteString(string("manifest")); err != nil {
20212021+ return err
20222022+ }
20232023+20242024+ if t.Manifest == nil {
20252025+ if _, err := cw.Write(cbg.CborNull); err != nil {
20262026+ return err
20272027+ }
20282028+ } else {
20292029+ if len(*t.Manifest) > 8192 {
20302030+ return xerrors.Errorf("Value in field t.Manifest was too long")
20312031+ }
20322032+20332033+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Manifest))); err != nil {
20342034+ return err
20352035+ }
20362036+ if _, err := cw.WriteString(string(*t.Manifest)); err != nil {
20372037+ return err
20382038+ }
20392039+ }
20402040+ }
20412041+20422042+ // t.CreatedAt (string) (string)
20432043+ if len("createdAt") > 8192 {
20442044+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
20452045+ }
20462046+20472047+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
20482048+ return err
20492049+ }
20502050+ if _, err := cw.WriteString(string("createdAt")); err != nil {
20512051+ return err
20522052+ }
20532053+20542054+ if len(t.CreatedAt) > 8192 {
20552055+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
20562056+ }
20572057+20582058+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
20592059+ return err
20602060+ }
20612061+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
20622062+ return err
20632063+ }
20642064+20652065+ // t.Repository (string) (string)
20662066+ if len("repository") > 8192 {
20672067+ return xerrors.Errorf("Value in field \"repository\" was too long")
20682068+ }
20692069+20702070+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repository"))); err != nil {
20712071+ return err
20722072+ }
20732073+ if _, err := cw.WriteString(string("repository")); err != nil {
20742074+ return err
20752075+ }
20762076+20772077+ if len(t.Repository) > 8192 {
20782078+ return xerrors.Errorf("Value in field t.Repository was too long")
20792079+ }
20802080+20812081+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repository))); err != nil {
20822082+ return err
20832083+ }
20842084+ if _, err := cw.WriteString(string(t.Repository)); err != nil {
20852085+ return err
20862086+ }
20872087+20882088+ // t.ManifestDigest (string) (string)
20892089+ if t.ManifestDigest != nil {
20902090+20912091+ if len("manifestDigest") > 8192 {
20922092+ return xerrors.Errorf("Value in field \"manifestDigest\" was too long")
20932093+ }
20942094+20952095+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("manifestDigest"))); err != nil {
20962096+ return err
20972097+ }
20982098+ if _, err := cw.WriteString(string("manifestDigest")); err != nil {
20992099+ return err
21002100+ }
21012101+21022102+ if t.ManifestDigest == nil {
21032103+ if _, err := cw.Write(cbg.CborNull); err != nil {
21042104+ return err
21052105+ }
21062106+ } else {
21072107+ if len(*t.ManifestDigest) > 8192 {
21082108+ return xerrors.Errorf("Value in field t.ManifestDigest was too long")
21092109+ }
21102110+21112111+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ManifestDigest))); err != nil {
21122112+ return err
21132113+ }
21142114+ if _, err := cw.WriteString(string(*t.ManifestDigest)); err != nil {
21152115+ return err
21162116+ }
21172117+ }
21182118+ }
21192119+ return nil
21202120+}
21212121+21222122+func (t *Tag) UnmarshalCBOR(r io.Reader) (err error) {
21232123+ *t = Tag{}
21242124+21252125+ cr := cbg.NewCborReader(r)
21262126+21272127+ maj, extra, err := cr.ReadHeader()
21282128+ if err != nil {
21292129+ return err
21302130+ }
21312131+ defer func() {
21322132+ if err == io.EOF {
21332133+ err = io.ErrUnexpectedEOF
21342134+ }
21352135+ }()
21362136+21372137+ if maj != cbg.MajMap {
21382138+ return fmt.Errorf("cbor input should be of type map")
21392139+ }
21402140+21412141+ if extra > cbg.MaxLength {
21422142+ return fmt.Errorf("Tag: map struct too large (%d)", extra)
21432143+ }
21442144+21452145+ n := extra
21462146+21472147+ nameBuf := make([]byte, 14)
21482148+ for i := uint64(0); i < n; i++ {
21492149+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
21502150+ if err != nil {
21512151+ return err
21522152+ }
21532153+21542154+ if !ok {
21552155+ // Field doesn't exist on this type, so ignore it
21562156+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
21572157+ return err
21582158+ }
21592159+ continue
21602160+ }
21612161+21622162+ switch string(nameBuf[:nameLen]) {
21632163+ // t.Tag (string) (string)
21642164+ case "tag":
21652165+21662166+ {
21672167+ sval, err := cbg.ReadStringWithMax(cr, 8192)
21682168+ if err != nil {
21692169+ return err
21702170+ }
21712171+21722172+ t.Tag = string(sval)
21732173+ }
21742174+ // t.LexiconTypeID (string) (string)
21752175+ case "$type":
21762176+21772177+ {
21782178+ sval, err := cbg.ReadStringWithMax(cr, 8192)
21792179+ if err != nil {
21802180+ return err
21812181+ }
21822182+21832183+ t.LexiconTypeID = string(sval)
21842184+ }
21852185+ // t.Manifest (string) (string)
21862186+ case "manifest":
21872187+21882188+ {
21892189+ b, err := cr.ReadByte()
21902190+ if err != nil {
21912191+ return err
21922192+ }
21932193+ if b != cbg.CborNull[0] {
21942194+ if err := cr.UnreadByte(); err != nil {
21952195+ return err
2812196 }
282219721982198+ sval, err := cbg.ReadStringWithMax(cr, 8192)
21992199+ if err != nil {
22002200+ return err
22012201+ }
22022202+22032203+ t.Manifest = (*string)(&sval)
22042204+ }
22052205+ }
22062206+ // t.CreatedAt (string) (string)
22072207+ case "createdAt":
22082208+22092209+ {
22102210+ sval, err := cbg.ReadStringWithMax(cr, 8192)
22112211+ if err != nil {
22122212+ return err
22132213+ }
22142214+22152215+ t.CreatedAt = string(sval)
22162216+ }
22172217+ // t.Repository (string) (string)
22182218+ case "repository":
22192219+22202220+ {
22212221+ sval, err := cbg.ReadStringWithMax(cr, 8192)
22222222+ if err != nil {
22232223+ return err
22242224+ }
22252225+22262226+ t.Repository = string(sval)
22272227+ }
22282228+ // t.ManifestDigest (string) (string)
22292229+ case "manifestDigest":
22302230+22312231+ {
22322232+ b, err := cr.ReadByte()
22332233+ if err != nil {
22342234+ return err
22352235+ }
22362236+ if b != cbg.CborNull[0] {
22372237+ if err := cr.UnreadByte(); err != nil {
22382238+ return err
22392239+ }
22402240+22412241+ sval, err := cbg.ReadStringWithMax(cr, 8192)
22422242+ if err != nil {
22432243+ return err
22442244+ }
22452245+22462246+ t.ManifestDigest = (*string)(&sval)
2832247 }
2842248 }
2852249···29322572942258 return nil
2952259}
296296-func (t *CaptainRecord) MarshalCBOR(w io.Writer) error {
22602260+func (t *SailorProfile) MarshalCBOR(w io.Writer) error {
2972261 if t == nil {
2982262 _, err := w.Write(cbg.CborNull)
2992263 return err
3002264 }
30122653022266 cw := cbg.NewCborWriter(w)
303303- fieldCount := 8
22672267+ fieldCount := 4
3042268305305- if t.Region == "" {
22692269+ if t.DefaultHold == nil {
3062270 fieldCount--
3072271 }
3082272309309- if t.Provider == "" {
22732273+ if t.UpdatedAt == nil {
3102274 fieldCount--
3112275 }
3122276···3142278 return err
3152279 }
3162280317317- // t.Type (string) (string)
22812281+ // t.LexiconTypeID (string) (string)
3182282 if len("$type") > 8192 {
3192283 return xerrors.Errorf("Value in field \"$type\" was too long")
3202284 }
···3262290 return err
3272291 }
3282292329329- if len(t.Type) > 8192 {
330330- return xerrors.Errorf("Value in field t.Type was too long")
22932293+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.sailor.profile"))); err != nil {
22942294+ return err
22952295+ }
22962296+ if _, err := cw.WriteString(string("io.atcr.sailor.profile")); err != nil {
22972297+ return err
22982298+ }
22992299+23002300+ // t.CreatedAt (string) (string)
23012301+ if len("createdAt") > 8192 {
23022302+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
3312303 }
3322304333333- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Type))); err != nil {
23052305+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
3342306 return err
3352307 }
336336- if _, err := cw.WriteString(string(t.Type)); err != nil {
23082308+ if _, err := cw.WriteString(string("createdAt")); err != nil {
23092309+ return err
23102310+ }
23112311+23122312+ if len(t.CreatedAt) > 8192 {
23132313+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
23142314+ }
23152315+23162316+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
23172317+ return err
23182318+ }
23192319+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
23202320+ return err
23212321+ }
23222322+23232323+ // t.UpdatedAt (string) (string)
23242324+ if t.UpdatedAt != nil {
23252325+23262326+ if len("updatedAt") > 8192 {
23272327+ return xerrors.Errorf("Value in field \"updatedAt\" was too long")
23282328+ }
23292329+23302330+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("updatedAt"))); err != nil {
23312331+ return err
23322332+ }
23332333+ if _, err := cw.WriteString(string("updatedAt")); err != nil {
23342334+ return err
23352335+ }
23362336+23372337+ if t.UpdatedAt == nil {
23382338+ if _, err := cw.Write(cbg.CborNull); err != nil {
23392339+ return err
23402340+ }
23412341+ } else {
23422342+ if len(*t.UpdatedAt) > 8192 {
23432343+ return xerrors.Errorf("Value in field t.UpdatedAt was too long")
23442344+ }
23452345+23462346+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.UpdatedAt))); err != nil {
23472347+ return err
23482348+ }
23492349+ if _, err := cw.WriteString(string(*t.UpdatedAt)); err != nil {
23502350+ return err
23512351+ }
23522352+ }
23532353+ }
23542354+23552355+ // t.DefaultHold (string) (string)
23562356+ if t.DefaultHold != nil {
23572357+23582358+ if len("defaultHold") > 8192 {
23592359+ return xerrors.Errorf("Value in field \"defaultHold\" was too long")
23602360+ }
23612361+23622362+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("defaultHold"))); err != nil {
23632363+ return err
23642364+ }
23652365+ if _, err := cw.WriteString(string("defaultHold")); err != nil {
23662366+ return err
23672367+ }
23682368+23692369+ if t.DefaultHold == nil {
23702370+ if _, err := cw.Write(cbg.CborNull); err != nil {
23712371+ return err
23722372+ }
23732373+ } else {
23742374+ if len(*t.DefaultHold) > 8192 {
23752375+ return xerrors.Errorf("Value in field t.DefaultHold was too long")
23762376+ }
23772377+23782378+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.DefaultHold))); err != nil {
23792379+ return err
23802380+ }
23812381+ if _, err := cw.WriteString(string(*t.DefaultHold)); err != nil {
23822382+ return err
23832383+ }
23842384+ }
23852385+ }
23862386+ return nil
23872387+}
23882388+23892389+func (t *SailorProfile) UnmarshalCBOR(r io.Reader) (err error) {
23902390+ *t = SailorProfile{}
23912391+23922392+ cr := cbg.NewCborReader(r)
23932393+23942394+ maj, extra, err := cr.ReadHeader()
23952395+ if err != nil {
23962396+ return err
23972397+ }
23982398+ defer func() {
23992399+ if err == io.EOF {
24002400+ err = io.ErrUnexpectedEOF
24012401+ }
24022402+ }()
24032403+24042404+ if maj != cbg.MajMap {
24052405+ return fmt.Errorf("cbor input should be of type map")
24062406+ }
24072407+24082408+ if extra > cbg.MaxLength {
24092409+ return fmt.Errorf("SailorProfile: map struct too large (%d)", extra)
24102410+ }
24112411+24122412+ n := extra
24132413+24142414+ nameBuf := make([]byte, 11)
24152415+ for i := uint64(0); i < n; i++ {
24162416+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
24172417+ if err != nil {
24182418+ return err
24192419+ }
24202420+24212421+ if !ok {
24222422+ // Field doesn't exist on this type, so ignore it
24232423+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
24242424+ return err
24252425+ }
24262426+ continue
24272427+ }
24282428+24292429+ switch string(nameBuf[:nameLen]) {
24302430+ // t.LexiconTypeID (string) (string)
24312431+ case "$type":
24322432+24332433+ {
24342434+ sval, err := cbg.ReadStringWithMax(cr, 8192)
24352435+ if err != nil {
24362436+ return err
24372437+ }
24382438+24392439+ t.LexiconTypeID = string(sval)
24402440+ }
24412441+ // t.CreatedAt (string) (string)
24422442+ case "createdAt":
24432443+24442444+ {
24452445+ sval, err := cbg.ReadStringWithMax(cr, 8192)
24462446+ if err != nil {
24472447+ return err
24482448+ }
24492449+24502450+ t.CreatedAt = string(sval)
24512451+ }
24522452+ // t.UpdatedAt (string) (string)
24532453+ case "updatedAt":
24542454+24552455+ {
24562456+ b, err := cr.ReadByte()
24572457+ if err != nil {
24582458+ return err
24592459+ }
24602460+ if b != cbg.CborNull[0] {
24612461+ if err := cr.UnreadByte(); err != nil {
24622462+ return err
24632463+ }
24642464+24652465+ sval, err := cbg.ReadStringWithMax(cr, 8192)
24662466+ if err != nil {
24672467+ return err
24682468+ }
24692469+24702470+ t.UpdatedAt = (*string)(&sval)
24712471+ }
24722472+ }
24732473+ // t.DefaultHold (string) (string)
24742474+ case "defaultHold":
24752475+24762476+ {
24772477+ b, err := cr.ReadByte()
24782478+ if err != nil {
24792479+ return err
24802480+ }
24812481+ if b != cbg.CborNull[0] {
24822482+ if err := cr.UnreadByte(); err != nil {
24832483+ return err
24842484+ }
24852485+24862486+ sval, err := cbg.ReadStringWithMax(cr, 8192)
24872487+ if err != nil {
24882488+ return err
24892489+ }
24902490+24912491+ t.DefaultHold = (*string)(&sval)
24922492+ }
24932493+ }
24942494+24952495+ default:
24962496+ // Field doesn't exist on this type, so ignore it
24972497+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
24982498+ return err
24992499+ }
25002500+ }
25012501+ }
25022502+25032503+ return nil
25042504+}
25052505+func (t *SailorStar) MarshalCBOR(w io.Writer) error {
25062506+ if t == nil {
25072507+ _, err := w.Write(cbg.CborNull)
25082508+ return err
25092509+ }
25102510+25112511+ cw := cbg.NewCborWriter(w)
25122512+25132513+ if _, err := cw.Write([]byte{163}); err != nil {
25142514+ return err
25152515+ }
25162516+25172517+ // t.LexiconTypeID (string) (string)
25182518+ if len("$type") > 8192 {
25192519+ return xerrors.Errorf("Value in field \"$type\" was too long")
25202520+ }
25212521+25222522+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
25232523+ return err
25242524+ }
25252525+ if _, err := cw.WriteString(string("$type")); err != nil {
25262526+ return err
25272527+ }
25282528+25292529+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.sailor.star"))); err != nil {
25302530+ return err
25312531+ }
25322532+ if _, err := cw.WriteString(string("io.atcr.sailor.star")); err != nil {
25332533+ return err
25342534+ }
25352535+25362536+ // t.Subject (atproto.SailorStar_Subject) (struct)
25372537+ if len("subject") > 8192 {
25382538+ return xerrors.Errorf("Value in field \"subject\" was too long")
25392539+ }
25402540+25412541+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
25422542+ return err
25432543+ }
25442544+ if _, err := cw.WriteString(string("subject")); err != nil {
25452545+ return err
25462546+ }
25472547+25482548+ if err := t.Subject.MarshalCBOR(cw); err != nil {
25492549+ return err
25502550+ }
25512551+25522552+ // t.CreatedAt (string) (string)
25532553+ if len("createdAt") > 8192 {
25542554+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
25552555+ }
25562556+25572557+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
25582558+ return err
25592559+ }
25602560+ if _, err := cw.WriteString(string("createdAt")); err != nil {
25612561+ return err
25622562+ }
25632563+25642564+ if len(t.CreatedAt) > 8192 {
25652565+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
25662566+ }
25672567+25682568+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
25692569+ return err
25702570+ }
25712571+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
25722572+ return err
25732573+ }
25742574+ return nil
25752575+}
25762576+25772577+func (t *SailorStar) UnmarshalCBOR(r io.Reader) (err error) {
25782578+ *t = SailorStar{}
25792579+25802580+ cr := cbg.NewCborReader(r)
25812581+25822582+ maj, extra, err := cr.ReadHeader()
25832583+ if err != nil {
25842584+ return err
25852585+ }
25862586+ defer func() {
25872587+ if err == io.EOF {
25882588+ err = io.ErrUnexpectedEOF
25892589+ }
25902590+ }()
25912591+25922592+ if maj != cbg.MajMap {
25932593+ return fmt.Errorf("cbor input should be of type map")
25942594+ }
25952595+25962596+ if extra > cbg.MaxLength {
25972597+ return fmt.Errorf("SailorStar: map struct too large (%d)", extra)
25982598+ }
25992599+26002600+ n := extra
26012601+26022602+ nameBuf := make([]byte, 9)
26032603+ for i := uint64(0); i < n; i++ {
26042604+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
26052605+ if err != nil {
26062606+ return err
26072607+ }
26082608+26092609+ if !ok {
26102610+ // Field doesn't exist on this type, so ignore it
26112611+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
26122612+ return err
26132613+ }
26142614+ continue
26152615+ }
26162616+26172617+ switch string(nameBuf[:nameLen]) {
26182618+ // t.LexiconTypeID (string) (string)
26192619+ case "$type":
26202620+26212621+ {
26222622+ sval, err := cbg.ReadStringWithMax(cr, 8192)
26232623+ if err != nil {
26242624+ return err
26252625+ }
26262626+26272627+ t.LexiconTypeID = string(sval)
26282628+ }
26292629+ // t.Subject (atproto.SailorStar_Subject) (struct)
26302630+ case "subject":
26312631+26322632+ {
26332633+26342634+ if err := t.Subject.UnmarshalCBOR(cr); err != nil {
26352635+ return xerrors.Errorf("unmarshaling t.Subject: %w", err)
26362636+ }
26372637+26382638+ }
26392639+ // t.CreatedAt (string) (string)
26402640+ case "createdAt":
26412641+26422642+ {
26432643+ sval, err := cbg.ReadStringWithMax(cr, 8192)
26442644+ if err != nil {
26452645+ return err
26462646+ }
26472647+26482648+ t.CreatedAt = string(sval)
26492649+ }
26502650+26512651+ default:
26522652+ // Field doesn't exist on this type, so ignore it
26532653+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
26542654+ return err
26552655+ }
26562656+ }
26572657+ }
26582658+26592659+ return nil
26602660+}
26612661+func (t *SailorStar_Subject) MarshalCBOR(w io.Writer) error {
26622662+ if t == nil {
26632663+ _, err := w.Write(cbg.CborNull)
26642664+ return err
26652665+ }
26662666+26672667+ cw := cbg.NewCborWriter(w)
26682668+ fieldCount := 3
26692669+26702670+ if t.LexiconTypeID == "" {
26712671+ fieldCount--
26722672+ }
26732673+26742674+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
26752675+ return err
26762676+ }
26772677+26782678+ // t.Did (string) (string)
26792679+ if len("did") > 8192 {
26802680+ return xerrors.Errorf("Value in field \"did\" was too long")
26812681+ }
26822682+26832683+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("did"))); err != nil {
26842684+ return err
26852685+ }
26862686+ if _, err := cw.WriteString(string("did")); err != nil {
26872687+ return err
26882688+ }
26892689+26902690+ if len(t.Did) > 8192 {
26912691+ return xerrors.Errorf("Value in field t.Did was too long")
26922692+ }
26932693+26942694+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Did))); err != nil {
26952695+ return err
26962696+ }
26972697+ if _, err := cw.WriteString(string(t.Did)); err != nil {
26982698+ return err
26992699+ }
27002700+27012701+ // t.LexiconTypeID (string) (string)
27022702+ if t.LexiconTypeID != "" {
27032703+27042704+ if len("$type") > 8192 {
27052705+ return xerrors.Errorf("Value in field \"$type\" was too long")
27062706+ }
27072707+27082708+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
27092709+ return err
27102710+ }
27112711+ if _, err := cw.WriteString(string("$type")); err != nil {
27122712+ return err
27132713+ }
27142714+27152715+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.sailor.star#subject"))); err != nil {
27162716+ return err
27172717+ }
27182718+ if _, err := cw.WriteString(string("io.atcr.sailor.star#subject")); err != nil {
27192719+ return err
27202720+ }
27212721+ }
27222722+27232723+ // t.Repository (string) (string)
27242724+ if len("repository") > 8192 {
27252725+ return xerrors.Errorf("Value in field \"repository\" was too long")
27262726+ }
27272727+27282728+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repository"))); err != nil {
27292729+ return err
27302730+ }
27312731+ if _, err := cw.WriteString(string("repository")); err != nil {
27322732+ return err
27332733+ }
27342734+27352735+ if len(t.Repository) > 8192 {
27362736+ return xerrors.Errorf("Value in field t.Repository was too long")
27372737+ }
27382738+27392739+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repository))); err != nil {
27402740+ return err
27412741+ }
27422742+ if _, err := cw.WriteString(string(t.Repository)); err != nil {
27432743+ return err
27442744+ }
27452745+ return nil
27462746+}
27472747+27482748+func (t *SailorStar_Subject) UnmarshalCBOR(r io.Reader) (err error) {
27492749+ *t = SailorStar_Subject{}
27502750+27512751+ cr := cbg.NewCborReader(r)
27522752+27532753+ maj, extra, err := cr.ReadHeader()
27542754+ if err != nil {
27552755+ return err
27562756+ }
27572757+ defer func() {
27582758+ if err == io.EOF {
27592759+ err = io.ErrUnexpectedEOF
27602760+ }
27612761+ }()
27622762+27632763+ if maj != cbg.MajMap {
27642764+ return fmt.Errorf("cbor input should be of type map")
27652765+ }
27662766+27672767+ if extra > cbg.MaxLength {
27682768+ return fmt.Errorf("SailorStar_Subject: map struct too large (%d)", extra)
27692769+ }
27702770+27712771+ n := extra
27722772+27732773+ nameBuf := make([]byte, 10)
27742774+ for i := uint64(0); i < n; i++ {
27752775+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
27762776+ if err != nil {
27772777+ return err
27782778+ }
27792779+27802780+ if !ok {
27812781+ // Field doesn't exist on this type, so ignore it
27822782+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
27832783+ return err
27842784+ }
27852785+ continue
27862786+ }
27872787+27882788+ switch string(nameBuf[:nameLen]) {
27892789+ // t.Did (string) (string)
27902790+ case "did":
27912791+27922792+ {
27932793+ sval, err := cbg.ReadStringWithMax(cr, 8192)
27942794+ if err != nil {
27952795+ return err
27962796+ }
27972797+27982798+ t.Did = string(sval)
27992799+ }
28002800+ // t.LexiconTypeID (string) (string)
28012801+ case "$type":
28022802+28032803+ {
28042804+ sval, err := cbg.ReadStringWithMax(cr, 8192)
28052805+ if err != nil {
28062806+ return err
28072807+ }
28082808+28092809+ t.LexiconTypeID = string(sval)
28102810+ }
28112811+ // t.Repository (string) (string)
28122812+ case "repository":
28132813+28142814+ {
28152815+ sval, err := cbg.ReadStringWithMax(cr, 8192)
28162816+ if err != nil {
28172817+ return err
28182818+ }
28192819+28202820+ t.Repository = string(sval)
28212821+ }
28222822+28232823+ default:
28242824+ // Field doesn't exist on this type, so ignore it
28252825+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
28262826+ return err
28272827+ }
28282828+ }
28292829+ }
28302830+28312831+ return nil
28322832+}
28332833+func (t *HoldCaptain) MarshalCBOR(w io.Writer) error {
28342834+ if t == nil {
28352835+ _, err := w.Write(cbg.CborNull)
28362836+ return err
28372837+ }
28382838+28392839+ cw := cbg.NewCborWriter(w)
28402840+ fieldCount := 8
28412841+28422842+ if t.Provider == nil {
28432843+ fieldCount--
28442844+ }
28452845+28462846+ if t.Region == nil {
28472847+ fieldCount--
28482848+ }
28492849+28502850+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
28512851+ return err
28522852+ }
28532853+28542854+ // t.LexiconTypeID (string) (string)
28552855+ if len("$type") > 8192 {
28562856+ return xerrors.Errorf("Value in field \"$type\" was too long")
28572857+ }
28582858+28592859+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
28602860+ return err
28612861+ }
28622862+ if _, err := cw.WriteString(string("$type")); err != nil {
28632863+ return err
28642864+ }
28652865+28662866+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.hold.captain"))); err != nil {
28672867+ return err
28682868+ }
28692869+ if _, err := cw.WriteString(string("io.atcr.hold.captain")); err != nil {
3372870 return err
3382871 }
3392872···3772910 }
37829113792912 // t.Region (string) (string)
380380- if t.Region != "" {
29132913+ if t.Region != nil {
38129143822915 if len("region") > 8192 {
3832916 return xerrors.Errorf("Value in field \"region\" was too long")
···3902923 return err
3912924 }
3922925393393- if len(t.Region) > 8192 {
394394- return xerrors.Errorf("Value in field t.Region was too long")
395395- }
29262926+ if t.Region == nil {
29272927+ if _, err := cw.Write(cbg.CborNull); err != nil {
29282928+ return err
29292929+ }
29302930+ } else {
29312931+ if len(*t.Region) > 8192 {
29322932+ return xerrors.Errorf("Value in field t.Region was too long")
29332933+ }
3962934397397- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Region))); err != nil {
398398- return err
399399- }
400400- if _, err := cw.WriteString(string(t.Region)); err != nil {
401401- return err
29352935+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Region))); err != nil {
29362936+ return err
29372937+ }
29382938+ if _, err := cw.WriteString(string(*t.Region)); err != nil {
29392939+ return err
29402940+ }
4022941 }
4032942 }
40429434052944 // t.Provider (string) (string)
406406- if t.Provider != "" {
29452945+ if t.Provider != nil {
40729464082947 if len("provider") > 8192 {
4092948 return xerrors.Errorf("Value in field \"provider\" was too long")
···4162955 return err
4172956 }
4182957419419- if len(t.Provider) > 8192 {
420420- return xerrors.Errorf("Value in field t.Provider was too long")
421421- }
29582958+ if t.Provider == nil {
29592959+ if _, err := cw.Write(cbg.CborNull); err != nil {
29602960+ return err
29612961+ }
29622962+ } else {
29632963+ if len(*t.Provider) > 8192 {
29642964+ return xerrors.Errorf("Value in field t.Provider was too long")
29652965+ }
4222966423423- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Provider))); err != nil {
424424- return err
425425- }
426426- if _, err := cw.WriteString(string(t.Provider)); err != nil {
427427- return err
29672967+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Provider))); err != nil {
29682968+ return err
29692969+ }
29702970+ if _, err := cw.WriteString(string(*t.Provider)); err != nil {
29712971+ return err
29722972+ }
4282973 }
4292974 }
4302975···4853030 return nil
4863031}
4873032488488-func (t *CaptainRecord) UnmarshalCBOR(r io.Reader) (err error) {
489489- *t = CaptainRecord{}
30333033+func (t *HoldCaptain) UnmarshalCBOR(r io.Reader) (err error) {
30343034+ *t = HoldCaptain{}
49030354913036 cr := cbg.NewCborReader(r)
4923037···5053050 }
50630515073052 if extra > cbg.MaxLength {
508508- return fmt.Errorf("CaptainRecord: map struct too large (%d)", extra)
30533053+ return fmt.Errorf("HoldCaptain: map struct too large (%d)", extra)
5093054 }
51030555113056 n := extra
···5263071 }
52730725283073 switch string(nameBuf[:nameLen]) {
529529- // t.Type (string) (string)
30743074+ // t.LexiconTypeID (string) (string)
5303075 case "$type":
53130765323077 {
···5353080 return err
5363081 }
5373082538538- t.Type = string(sval)
30833083+ t.LexiconTypeID = string(sval)
5393084 }
5403085 // t.Owner (string) (string)
5413086 case "owner":
···5703115 case "region":
57131165723117 {
573573- sval, err := cbg.ReadStringWithMax(cr, 8192)
31183118+ b, err := cr.ReadByte()
5743119 if err != nil {
5753120 return err
5763121 }
31223122+ if b != cbg.CborNull[0] {
31233123+ if err := cr.UnreadByte(); err != nil {
31243124+ return err
31253125+ }
5773126578578- t.Region = string(sval)
31273127+ sval, err := cbg.ReadStringWithMax(cr, 8192)
31283128+ if err != nil {
31293129+ return err
31303130+ }
31313131+31323132+ t.Region = (*string)(&sval)
31333133+ }
5793134 }
5803135 // t.Provider (string) (string)
5813136 case "provider":
58231375833138 {
584584- sval, err := cbg.ReadStringWithMax(cr, 8192)
31393139+ b, err := cr.ReadByte()
5853140 if err != nil {
5863141 return err
5873142 }
31433143+ if b != cbg.CborNull[0] {
31443144+ if err := cr.UnreadByte(); err != nil {
31453145+ return err
31463146+ }
5883147589589- t.Provider = string(sval)
31483148+ sval, err := cbg.ReadStringWithMax(cr, 8192)
31493149+ if err != nil {
31503150+ return err
31513151+ }
31523152+31533153+ t.Provider = (*string)(&sval)
31543154+ }
5903155 }
5913156 // t.DeployedAt (string) (string)
5923157 case "deployedAt":
···64632116473212 return nil
6483213}
649649-func (t *LayerRecord) MarshalCBOR(w io.Writer) error {
32143214+func (t *HoldCrew) MarshalCBOR(w io.Writer) error {
32153215+ if t == nil {
32163216+ _, err := w.Write(cbg.CborNull)
32173217+ return err
32183218+ }
32193219+32203220+ cw := cbg.NewCborWriter(w)
32213221+32223222+ if _, err := cw.Write([]byte{165}); err != nil {
32233223+ return err
32243224+ }
32253225+32263226+ // t.Role (string) (string)
32273227+ if len("role") > 8192 {
32283228+ return xerrors.Errorf("Value in field \"role\" was too long")
32293229+ }
32303230+32313231+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("role"))); err != nil {
32323232+ return err
32333233+ }
32343234+ if _, err := cw.WriteString(string("role")); err != nil {
32353235+ return err
32363236+ }
32373237+32383238+ if len(t.Role) > 8192 {
32393239+ return xerrors.Errorf("Value in field t.Role was too long")
32403240+ }
32413241+32423242+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Role))); err != nil {
32433243+ return err
32443244+ }
32453245+ if _, err := cw.WriteString(string(t.Role)); err != nil {
32463246+ return err
32473247+ }
32483248+32493249+ // t.LexiconTypeID (string) (string)
32503250+ if len("$type") > 8192 {
32513251+ return xerrors.Errorf("Value in field \"$type\" was too long")
32523252+ }
32533253+32543254+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
32553255+ return err
32563256+ }
32573257+ if _, err := cw.WriteString(string("$type")); err != nil {
32583258+ return err
32593259+ }
32603260+32613261+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.hold.crew"))); err != nil {
32623262+ return err
32633263+ }
32643264+ if _, err := cw.WriteString(string("io.atcr.hold.crew")); err != nil {
32653265+ return err
32663266+ }
32673267+32683268+ // t.Member (string) (string)
32693269+ if len("member") > 8192 {
32703270+ return xerrors.Errorf("Value in field \"member\" was too long")
32713271+ }
32723272+32733273+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("member"))); err != nil {
32743274+ return err
32753275+ }
32763276+ if _, err := cw.WriteString(string("member")); err != nil {
32773277+ return err
32783278+ }
32793279+32803280+ if len(t.Member) > 8192 {
32813281+ return xerrors.Errorf("Value in field t.Member was too long")
32823282+ }
32833283+32843284+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Member))); err != nil {
32853285+ return err
32863286+ }
32873287+ if _, err := cw.WriteString(string(t.Member)); err != nil {
32883288+ return err
32893289+ }
32903290+32913291+ // t.AddedAt (string) (string)
32923292+ if len("addedAt") > 8192 {
32933293+ return xerrors.Errorf("Value in field \"addedAt\" was too long")
32943294+ }
32953295+32963296+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("addedAt"))); err != nil {
32973297+ return err
32983298+ }
32993299+ if _, err := cw.WriteString(string("addedAt")); err != nil {
33003300+ return err
33013301+ }
33023302+33033303+ if len(t.AddedAt) > 8192 {
33043304+ return xerrors.Errorf("Value in field t.AddedAt was too long")
33053305+ }
33063306+33073307+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.AddedAt))); err != nil {
33083308+ return err
33093309+ }
33103310+ if _, err := cw.WriteString(string(t.AddedAt)); err != nil {
33113311+ return err
33123312+ }
33133313+33143314+ // t.Permissions ([]string) (slice)
33153315+ if len("permissions") > 8192 {
33163316+ return xerrors.Errorf("Value in field \"permissions\" was too long")
33173317+ }
33183318+33193319+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("permissions"))); err != nil {
33203320+ return err
33213321+ }
33223322+ if _, err := cw.WriteString(string("permissions")); err != nil {
33233323+ return err
33243324+ }
33253325+33263326+ if len(t.Permissions) > 8192 {
33273327+ return xerrors.Errorf("Slice value in field t.Permissions was too long")
33283328+ }
33293329+33303330+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Permissions))); err != nil {
33313331+ return err
33323332+ }
33333333+ for _, v := range t.Permissions {
33343334+ if len(v) > 8192 {
33353335+ return xerrors.Errorf("Value in field v was too long")
33363336+ }
33373337+33383338+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
33393339+ return err
33403340+ }
33413341+ if _, err := cw.WriteString(string(v)); err != nil {
33423342+ return err
33433343+ }
33443344+33453345+ }
33463346+ return nil
33473347+}
33483348+33493349+func (t *HoldCrew) UnmarshalCBOR(r io.Reader) (err error) {
33503350+ *t = HoldCrew{}
33513351+33523352+ cr := cbg.NewCborReader(r)
33533353+33543354+ maj, extra, err := cr.ReadHeader()
33553355+ if err != nil {
33563356+ return err
33573357+ }
33583358+ defer func() {
33593359+ if err == io.EOF {
33603360+ err = io.ErrUnexpectedEOF
33613361+ }
33623362+ }()
33633363+33643364+ if maj != cbg.MajMap {
33653365+ return fmt.Errorf("cbor input should be of type map")
33663366+ }
33673367+33683368+ if extra > cbg.MaxLength {
33693369+ return fmt.Errorf("HoldCrew: map struct too large (%d)", extra)
33703370+ }
33713371+33723372+ n := extra
33733373+33743374+ nameBuf := make([]byte, 11)
33753375+ for i := uint64(0); i < n; i++ {
33763376+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 8192)
33773377+ if err != nil {
33783378+ return err
33793379+ }
33803380+33813381+ if !ok {
33823382+ // Field doesn't exist on this type, so ignore it
33833383+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
33843384+ return err
33853385+ }
33863386+ continue
33873387+ }
33883388+33893389+ switch string(nameBuf[:nameLen]) {
33903390+ // t.Role (string) (string)
33913391+ case "role":
33923392+33933393+ {
33943394+ sval, err := cbg.ReadStringWithMax(cr, 8192)
33953395+ if err != nil {
33963396+ return err
33973397+ }
33983398+33993399+ t.Role = string(sval)
34003400+ }
34013401+ // t.LexiconTypeID (string) (string)
34023402+ case "$type":
34033403+34043404+ {
34053405+ sval, err := cbg.ReadStringWithMax(cr, 8192)
34063406+ if err != nil {
34073407+ return err
34083408+ }
34093409+34103410+ t.LexiconTypeID = string(sval)
34113411+ }
34123412+ // t.Member (string) (string)
34133413+ case "member":
34143414+34153415+ {
34163416+ sval, err := cbg.ReadStringWithMax(cr, 8192)
34173417+ if err != nil {
34183418+ return err
34193419+ }
34203420+34213421+ t.Member = string(sval)
34223422+ }
34233423+ // t.AddedAt (string) (string)
34243424+ case "addedAt":
34253425+34263426+ {
34273427+ sval, err := cbg.ReadStringWithMax(cr, 8192)
34283428+ if err != nil {
34293429+ return err
34303430+ }
34313431+34323432+ t.AddedAt = string(sval)
34333433+ }
34343434+ // t.Permissions ([]string) (slice)
34353435+ case "permissions":
34363436+34373437+ maj, extra, err = cr.ReadHeader()
34383438+ if err != nil {
34393439+ return err
34403440+ }
34413441+34423442+ if extra > 8192 {
34433443+ return fmt.Errorf("t.Permissions: array too large (%d)", extra)
34443444+ }
34453445+34463446+ if maj != cbg.MajArray {
34473447+ return fmt.Errorf("expected cbor array")
34483448+ }
34493449+34503450+ if extra > 0 {
34513451+ t.Permissions = make([]string, extra)
34523452+ }
34533453+34543454+ for i := 0; i < int(extra); i++ {
34553455+ {
34563456+ var maj byte
34573457+ var extra uint64
34583458+ var err error
34593459+ _ = maj
34603460+ _ = extra
34613461+ _ = err
34623462+34633463+ {
34643464+ sval, err := cbg.ReadStringWithMax(cr, 8192)
34653465+ if err != nil {
34663466+ return err
34673467+ }
34683468+34693469+ t.Permissions[i] = string(sval)
34703470+ }
34713471+34723472+ }
34733473+ }
34743474+34753475+ default:
34763476+ // Field doesn't exist on this type, so ignore it
34773477+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
34783478+ return err
34793479+ }
34803480+ }
34813481+ }
34823482+34833483+ return nil
34843484+}
34853485+func (t *HoldLayer) MarshalCBOR(w io.Writer) error {
6503486 if t == nil {
6513487 _, err := w.Write(cbg.CborNull)
6523488 return err
···6803516 }
6813517 }
6823518683683- // t.Type (string) (string)
35193519+ // t.LexiconTypeID (string) (string)
6843520 if len("$type") > 8192 {
6853521 return xerrors.Errorf("Value in field \"$type\" was too long")
6863522 }
···6923528 return err
6933529 }
6943530695695- if len(t.Type) > 8192 {
696696- return xerrors.Errorf("Value in field t.Type was too long")
697697- }
698698-699699- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Type))); err != nil {
35313531+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("io.atcr.hold.layer"))); err != nil {
7003532 return err
7013533 }
702702- if _, err := cw.WriteString(string(t.Type)); err != nil {
35343534+ if _, err := cw.WriteString(string("io.atcr.hold.layer")); err != nil {
7033535 return err
7043536 }
7053537···7263558 return err
7273559 }
7283560729729- // t.UserDID (string) (string)
35613561+ // t.UserDid (string) (string)
7303562 if len("userDid") > 8192 {
7313563 return xerrors.Errorf("Value in field \"userDid\" was too long")
7323564 }
···7383570 return err
7393571 }
7403572741741- if len(t.UserDID) > 8192 {
742742- return xerrors.Errorf("Value in field t.UserDID was too long")
35733573+ if len(t.UserDid) > 8192 {
35743574+ return xerrors.Errorf("Value in field t.UserDid was too long")
7433575 }
7443576745745- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.UserDID))); err != nil {
35773577+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.UserDid))); err != nil {
7463578 return err
7473579 }
748748- if _, err := cw.WriteString(string(t.UserDID)); err != nil {
35803580+ if _, err := cw.WriteString(string(t.UserDid)); err != nil {
7493581 return err
7503582 }
7513583···8433675 return nil
8443676}
8453677846846-func (t *LayerRecord) UnmarshalCBOR(r io.Reader) (err error) {
847847- *t = LayerRecord{}
36783678+func (t *HoldLayer) UnmarshalCBOR(r io.Reader) (err error) {
36793679+ *t = HoldLayer{}
84836808493681 cr := cbg.NewCborReader(r)
8503682···8633695 }
86436968653697 if extra > cbg.MaxLength {
866866- return fmt.Errorf("LayerRecord: map struct too large (%d)", extra)
36983698+ return fmt.Errorf("HoldLayer: map struct too large (%d)", extra)
8673699 }
86837008693701 n := extra
···91037429113743 t.Size = int64(extraI)
9123744 }
913913- // t.Type (string) (string)
37453745+ // t.LexiconTypeID (string) (string)
9143746 case "$type":
91537479163748 {
···9193751 return err
9203752 }
9213753922922- t.Type = string(sval)
37543754+ t.LexiconTypeID = string(sval)
9233755 }
9243756 // t.Digest (string) (string)
9253757 case "digest":
···93237649333765 t.Digest = string(sval)
9343766 }
935935- // t.UserDID (string) (string)
37673767+ // t.UserDid (string) (string)
9363768 case "userDid":
93737699383770 {
···9413773 return err
9423774 }
9433775944944- t.UserDID = string(sval)
37763776+ t.UserDid = string(sval)
9453777 }
9463778 // t.CreatedAt (string) (string)
9473779 case "createdAt":
+255-11
pkg/atproto/generate.go
···3344package main
5566-// CBOR Code Generator
66+// Lexicon and CBOR Code Generator
77//
88-// This generates optimized CBOR marshaling code for ATProto records.
88+// This generates:
99+// 1. Go types from lexicon JSON files (via lex/lexgen library)
1010+// 2. CBOR marshaling code for ATProto records (via cbor-gen)
1111+// 3. Type registration for lexutil (register.go)
912//
1013// Usage:
1114// go generate ./pkg/atproto/...
1215//
1313-// This creates pkg/atproto/cbor_gen.go which should be committed to git.
1414-// Only re-run when you modify types in pkg/atproto/types.go
1515-//
1616-// The //go:generate directive is in lexicon.go
1616+// Key insight: We use RegisterLexiconTypeID: false to avoid generating init()
1717+// blocks that require CBORMarshaler. This breaks the circular dependency between
1818+// lexgen and cbor-gen. See: https://github.com/bluesky-social/indigo/issues/931
1919+2020+import (
2121+ "bytes"
2222+ "encoding/json"
2323+ "fmt"
2424+ "os"
2525+ "os/exec"
2626+ "path/filepath"
2727+ "strings"
2828+2929+ "github.com/bluesky-social/indigo/atproto/lexicon"
3030+ "github.com/bluesky-social/indigo/lex/lexgen"
3131+ "golang.org/x/tools/imports"
3232+)
3333+3434+func main() {
3535+ // Find repo root
3636+ repoRoot, err := findRepoRoot()
3737+ if err != nil {
3838+ fmt.Printf("failed to find repo root: %v\n", err)
3939+ os.Exit(1)
4040+ }
4141+4242+ pkgDir := filepath.Join(repoRoot, "pkg/atproto")
4343+ lexDir := filepath.Join(repoRoot, "lexicons")
4444+4545+ // Step 0: Clean up old register.go to avoid conflicts
4646+ // (It will be regenerated at the end)
4747+ os.Remove(filepath.Join(pkgDir, "register.go"))
4848+4949+ // Step 1: Load all lexicon schemas into catalog (for cross-references)
5050+ fmt.Println("Loading lexicons...")
5151+ cat := lexicon.NewBaseCatalog()
5252+ if err := cat.LoadDirectory(lexDir); err != nil {
5353+ fmt.Printf("failed to load lexicons: %v\n", err)
5454+ os.Exit(1)
5555+ }
5656+5757+ // Step 2: Generate Go code for each lexicon file
5858+ fmt.Println("Running lexgen...")
5959+ config := &lexgen.GenConfig{
6060+ RegisterLexiconTypeID: false, // KEY: no init() blocks generated
6161+ UnknownType: "map-string-any",
6262+ WarningText: "Code generated by generate.go; DO NOT EDIT.",
6363+ }
6464+6565+ // Track generated types for register.go
6666+ var registeredTypes []typeInfo
6767+6868+ // Walk lexicon directory and generate code for each file
6969+ err = filepath.Walk(lexDir, func(path string, info os.FileInfo, err error) error {
7070+ if err != nil {
7171+ return err
7272+ }
7373+ if info.IsDir() || !strings.HasSuffix(path, ".json") {
7474+ return nil
7575+ }
7676+7777+ // Load and parse the schema file
7878+ data, err := os.ReadFile(path)
7979+ if err != nil {
8080+ return fmt.Errorf("failed to read %s: %w", path, err)
8181+ }
8282+8383+ var sf lexicon.SchemaFile
8484+ if err := json.Unmarshal(data, &sf); err != nil {
8585+ return fmt.Errorf("failed to parse %s: %w", path, err)
8686+ }
8787+8888+ if err := sf.FinishParse(); err != nil {
8989+ return fmt.Errorf("failed to finish parse %s: %w", path, err)
9090+ }
9191+9292+ // Flatten the schema
9393+ flat, err := lexgen.FlattenSchemaFile(&sf)
9494+ if err != nil {
9595+ return fmt.Errorf("failed to flatten schema %s: %w", path, err)
9696+ }
9797+9898+ // Generate code
9999+ var buf bytes.Buffer
100100+ gen := &lexgen.CodeGenerator{
101101+ Config: config,
102102+ Lex: flat,
103103+ Cat: &cat,
104104+ Out: &buf,
105105+ }
106106+107107+ if err := gen.WriteLexicon(); err != nil {
108108+ return fmt.Errorf("failed to generate code for %s: %w", path, err)
109109+ }
110110+111111+ // Fix package name: lexgen generates "ioatcr" but we want "atproto"
112112+ code := bytes.Replace(buf.Bytes(), []byte("package ioatcr"), []byte("package atproto"), 1)
113113+114114+ // Format with goimports
115115+ fileName := gen.FileName()
116116+ formatted, err := imports.Process(fileName, code, nil)
117117+ if err != nil {
118118+ // Write unformatted for debugging
119119+ outPath := filepath.Join(pkgDir, fileName)
120120+ os.WriteFile(outPath+".broken", code, 0644)
121121+ return fmt.Errorf("failed to format %s: %w (wrote to %s.broken)", fileName, err, outPath)
122122+ }
123123+124124+ // Write output file
125125+ outPath := filepath.Join(pkgDir, fileName)
126126+ if err := os.WriteFile(outPath, formatted, 0644); err != nil {
127127+ return fmt.Errorf("failed to write %s: %w", outPath, err)
128128+ }
129129+130130+ fmt.Printf(" Generated %s\n", fileName)
131131+132132+ // Track type for registration - compute type name from NSID
133133+ typeName := nsidToTypeName(sf.ID)
134134+ registeredTypes = append(registeredTypes, typeInfo{
135135+ NSID: sf.ID,
136136+ TypeName: typeName,
137137+ })
138138+139139+ return nil
140140+ })
141141+ if err != nil {
142142+ fmt.Printf("lexgen failed: %v\n", err)
143143+ os.Exit(1)
144144+ }
145145+146146+ // Step 3: Run cbor-gen via exec.Command
147147+ // This must be a separate process so it can compile the freshly generated types
148148+ fmt.Println("Running cbor-gen...")
149149+ if err := runCborGen(repoRoot, pkgDir); err != nil {
150150+ fmt.Printf("cbor-gen failed: %v\n", err)
151151+ os.Exit(1)
152152+ }
153153+154154+ // Step 4: Generate register.go
155155+ fmt.Println("Generating register.go...")
156156+ if err := generateRegisterFile(pkgDir, registeredTypes); err != nil {
157157+ fmt.Printf("failed to generate register.go: %v\n", err)
158158+ os.Exit(1)
159159+ }
160160+161161+ fmt.Println("Code generation complete!")
162162+}
163163+164164+type typeInfo struct {
165165+ NSID string
166166+ TypeName string
167167+}
168168+169169+// nsidToTypeName converts an NSID to a Go type name
170170+// io.atcr.manifest → Manifest
171171+// io.atcr.hold.captain → HoldCaptain
172172+// io.atcr.sailor.profile → SailorProfile
173173+func nsidToTypeName(nsid string) string {
174174+ parts := strings.Split(nsid, ".")
175175+ if len(parts) < 3 {
176176+ return ""
177177+ }
178178+ // Skip the first two parts (authority, e.g., "io.atcr")
179179+ // and capitalize each remaining part
180180+ var result string
181181+ for _, part := range parts[2:] {
182182+ if len(part) > 0 {
183183+ result += strings.ToUpper(part[:1]) + part[1:]
184184+ }
185185+ }
186186+ return result
187187+}
188188+189189+func runCborGen(repoRoot, pkgDir string) error {
190190+ // Create a temporary Go file that runs cbor-gen
191191+ cborGenCode := `//go:build ignore
192192+193193+package main
1719418195import (
19196 "fmt"
···25202)
2620327204func main() {
2828- // Generate map-style encoders for CrewRecord, CaptainRecord, LayerRecord, and TangledProfileRecord
29205 if err := cbg.WriteMapEncodersToFile("cbor_gen.go", "atproto",
3030- atproto.CrewRecord{},
3131- atproto.CaptainRecord{},
3232- atproto.LayerRecord{},
206206+ // Manifest types
207207+ atproto.Manifest{},
208208+ atproto.Manifest_BlobReference{},
209209+ atproto.Manifest_ManifestReference{},
210210+ atproto.Manifest_Platform{},
211211+ atproto.Manifest_Annotations{},
212212+ atproto.Manifest_BlobReference_Annotations{},
213213+ atproto.Manifest_ManifestReference_Annotations{},
214214+ // Tag
215215+ atproto.Tag{},
216216+ // Sailor types
217217+ atproto.SailorProfile{},
218218+ atproto.SailorStar{},
219219+ atproto.SailorStar_Subject{},
220220+ // Hold types
221221+ atproto.HoldCaptain{},
222222+ atproto.HoldCrew{},
223223+ atproto.HoldLayer{},
224224+ // External types
33225 atproto.TangledProfileRecord{},
34226 ); err != nil {
3535- fmt.Printf("Failed to generate CBOR encoders: %v\n", err)
227227+ fmt.Printf("cbor-gen failed: %v\n", err)
36228 os.Exit(1)
37229 }
38230}
231231+`
232232+233233+ // Write temp file
234234+ tmpFile := filepath.Join(pkgDir, "cborgen_tmp.go")
235235+ if err := os.WriteFile(tmpFile, []byte(cborGenCode), 0644); err != nil {
236236+ return fmt.Errorf("failed to write temp cbor-gen file: %w", err)
237237+ }
238238+ defer os.Remove(tmpFile)
239239+240240+ // Run it
241241+ cmd := exec.Command("go", "run", tmpFile)
242242+ cmd.Dir = pkgDir
243243+ cmd.Stdout = os.Stdout
244244+ cmd.Stderr = os.Stderr
245245+ return cmd.Run()
246246+}
247247+248248+func generateRegisterFile(pkgDir string, types []typeInfo) error {
249249+ var buf bytes.Buffer
250250+251251+ buf.WriteString("// Code generated by generate.go; DO NOT EDIT.\n\n")
252252+ buf.WriteString("package atproto\n\n")
253253+ buf.WriteString("import lexutil \"github.com/bluesky-social/indigo/lex/util\"\n\n")
254254+ buf.WriteString("func init() {\n")
255255+256256+ for _, t := range types {
257257+ fmt.Fprintf(&buf, "\tlexutil.RegisterType(%q, &%s{})\n", t.NSID, t.TypeName)
258258+ }
259259+260260+ buf.WriteString("}\n")
261261+262262+ outPath := filepath.Join(pkgDir, "register.go")
263263+ return os.WriteFile(outPath, buf.Bytes(), 0644)
264264+}
265265+266266+func findRepoRoot() (string, error) {
267267+ dir, err := os.Getwd()
268268+ if err != nil {
269269+ return "", err
270270+ }
271271+272272+ for {
273273+ if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
274274+ return dir, nil
275275+ }
276276+ parent := filepath.Dir(dir)
277277+ if parent == dir {
278278+ return "", fmt.Errorf("go.mod not found")
279279+ }
280280+ dir = parent
281281+ }
282282+}
+24
pkg/atproto/holdcaptain.go
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.hold.captain
44+55+package atproto
66+77+// Represents the hold's ownership and metadata. Stored as a singleton record at rkey 'self' in the hold's embedded PDS.
88+type HoldCaptain struct {
99+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.hold.captain"`
1010+ // allowAllCrew: Allow any authenticated user to register as crew
1111+ AllowAllCrew bool `json:"allowAllCrew" cborgen:"allowAllCrew"`
1212+ // deployedAt: RFC3339 timestamp of when the hold was deployed
1313+ DeployedAt string `json:"deployedAt" cborgen:"deployedAt"`
1414+ // enableBlueskyPosts: Enable Bluesky posts when manifests are pushed
1515+ EnableBlueskyPosts bool `json:"enableBlueskyPosts" cborgen:"enableBlueskyPosts"`
1616+ // owner: DID of the hold owner
1717+ Owner string `json:"owner" cborgen:"owner"`
1818+ // provider: Deployment provider (e.g., fly.io, aws, etc.)
1919+ Provider *string `json:"provider,omitempty" cborgen:"provider,omitempty"`
2020+ // public: Whether this hold allows public blob reads (pulls) without authentication
2121+ Public bool `json:"public" cborgen:"public"`
2222+ // region: S3 region where blobs are stored
2323+ Region *string `json:"region,omitempty" cborgen:"region,omitempty"`
2424+}
+18
pkg/atproto/holdcrew.go
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.hold.crew
44+55+package atproto
66+77+// Crew member in a hold's embedded PDS. Grants access permissions to push blobs to the hold. Stored in the hold's embedded PDS (one record per member).
88+type HoldCrew struct {
99+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.hold.crew"`
1010+ // addedAt: RFC3339 timestamp of when the member was added
1111+ AddedAt string `json:"addedAt" cborgen:"addedAt"`
1212+ // member: DID of the crew member
1313+ Member string `json:"member" cborgen:"member"`
1414+ // permissions: Specific permissions granted to this member
1515+ Permissions []string `json:"permissions" cborgen:"permissions"`
1616+ // role: Member's role in the hold
1717+ Role string `json:"role" cborgen:"role"`
1818+}
+24
pkg/atproto/holdlayer.go
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.hold.layer
44+55+package atproto
66+77+// Represents metadata about a container layer stored in the hold. Stored in the hold's embedded PDS for tracking and analytics.
88+type HoldLayer struct {
99+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.hold.layer"`
1010+ // createdAt: RFC3339 timestamp of when the layer was uploaded
1111+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
1212+ // digest: Layer digest (e.g., sha256:abc123...)
1313+ Digest string `json:"digest" cborgen:"digest"`
1414+ // mediaType: Media type (e.g., application/vnd.oci.image.layer.v1.tar+gzip)
1515+ MediaType string `json:"mediaType" cborgen:"mediaType"`
1616+ // repository: Repository this layer belongs to
1717+ Repository string `json:"repository" cborgen:"repository"`
1818+ // size: Size in bytes
1919+ Size int64 `json:"size" cborgen:"size"`
2020+ // userDid: DID of user who uploaded this layer
2121+ UserDid string `json:"userDid" cborgen:"userDid"`
2222+ // userHandle: Handle of user (for display purposes)
2323+ UserHandle string `json:"userHandle" cborgen:"userHandle"`
2424+}
+103
pkg/atproto/manifest.go
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.manifest
44+55+package atproto
66+77+import (
88+ lexutil "github.com/bluesky-social/indigo/lex/util"
99+)
1010+1111+// A container image manifest following OCI specification, stored in ATProto
1212+type Manifest struct {
1313+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.manifest"`
1414+ // annotations: Optional metadata annotations
1515+ Annotations *Manifest_Annotations `json:"annotations,omitempty" cborgen:"annotations,omitempty"`
1616+ // config: Reference to image configuration blob
1717+ Config *Manifest_BlobReference `json:"config,omitempty" cborgen:"config,omitempty"`
1818+ // createdAt: Record creation timestamp
1919+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
2020+ // digest: Content digest (e.g., 'sha256:abc123...')
2121+ Digest string `json:"digest" cborgen:"digest"`
2222+ // holdDid: DID of the hold service where blobs are stored (e.g., 'did:web:hold01.atcr.io'). Primary reference for hold resolution.
2323+ HoldDid *string `json:"holdDid,omitempty" cborgen:"holdDid,omitempty"`
2424+ // holdEndpoint: Hold service endpoint URL where blobs are stored. DEPRECATED: Use holdDid instead. Kept for backward compatibility.
2525+ HoldEndpoint *string `json:"holdEndpoint,omitempty" cborgen:"holdEndpoint,omitempty"`
2626+ // layers: Filesystem layers (for image manifests)
2727+ Layers []Manifest_BlobReference `json:"layers,omitempty" cborgen:"layers,omitempty"`
2828+ // manifestBlob: The full OCI manifest stored as a blob in ATProto.
2929+ ManifestBlob *lexutil.LexBlob `json:"manifestBlob,omitempty" cborgen:"manifestBlob,omitempty"`
3030+ // manifests: Referenced manifests (for manifest lists/indexes)
3131+ Manifests []Manifest_ManifestReference `json:"manifests,omitempty" cborgen:"manifests,omitempty"`
3232+ // mediaType: OCI media type
3333+ MediaType string `json:"mediaType" cborgen:"mediaType"`
3434+ // repository: Repository name (e.g., 'myapp'). Scoped to user's DID.
3535+ Repository string `json:"repository" cborgen:"repository"`
3636+ // schemaVersion: OCI schema version (typically 2)
3737+ SchemaVersion int64 `json:"schemaVersion" cborgen:"schemaVersion"`
3838+ // subject: Optional reference to another manifest (for attestations, signatures)
3939+ Subject *Manifest_BlobReference `json:"subject,omitempty" cborgen:"subject,omitempty"`
4040+}
4141+4242+// Optional metadata annotations
4343+type Manifest_Annotations struct {
4444+}
4545+4646+// Manifest_BlobReference is a "blobReference" in the io.atcr.manifest schema.
4747+//
4848+// Reference to a blob stored in S3 or external storage
4949+type Manifest_BlobReference struct {
5050+ LexiconTypeID string `json:"$type,omitempty" cborgen:"$type,const=io.atcr.manifest#blobReference,omitempty"`
5151+ // annotations: Optional metadata
5252+ Annotations *Manifest_BlobReference_Annotations `json:"annotations,omitempty" cborgen:"annotations,omitempty"`
5353+ // digest: Content digest (e.g., 'sha256:...')
5454+ Digest string `json:"digest" cborgen:"digest"`
5555+ // mediaType: MIME type of the blob
5656+ MediaType string `json:"mediaType" cborgen:"mediaType"`
5757+ // size: Size in bytes
5858+ Size int64 `json:"size" cborgen:"size"`
5959+ // urls: Optional direct URLs to blob (for BYOS)
6060+ Urls []string `json:"urls,omitempty" cborgen:"urls,omitempty"`
6161+}
6262+6363+// Optional metadata
6464+type Manifest_BlobReference_Annotations struct {
6565+}
6666+6767+// Manifest_ManifestReference is a "manifestReference" in the io.atcr.manifest schema.
6868+//
6969+// Reference to a manifest in a manifest list/index
7070+type Manifest_ManifestReference struct {
7171+ LexiconTypeID string `json:"$type,omitempty" cborgen:"$type,const=io.atcr.manifest#manifestReference,omitempty"`
7272+ // annotations: Optional metadata
7373+ Annotations *Manifest_ManifestReference_Annotations `json:"annotations,omitempty" cborgen:"annotations,omitempty"`
7474+ // digest: Content digest (e.g., 'sha256:...')
7575+ Digest string `json:"digest" cborgen:"digest"`
7676+ // mediaType: Media type of the referenced manifest
7777+ MediaType string `json:"mediaType" cborgen:"mediaType"`
7878+ // platform: Platform information for this manifest
7979+ Platform *Manifest_Platform `json:"platform,omitempty" cborgen:"platform,omitempty"`
8080+ // size: Size in bytes
8181+ Size int64 `json:"size" cborgen:"size"`
8282+}
8383+8484+// Optional metadata
8585+type Manifest_ManifestReference_Annotations struct {
8686+}
8787+8888+// Manifest_Platform is a "platform" in the io.atcr.manifest schema.
8989+//
9090+// Platform information describing OS and architecture
9191+type Manifest_Platform struct {
9292+ LexiconTypeID string `json:"$type,omitempty" cborgen:"$type,const=io.atcr.manifest#platform,omitempty"`
9393+ // architecture: CPU architecture (e.g., 'amd64', 'arm64', 'arm')
9494+ Architecture string `json:"architecture" cborgen:"architecture"`
9595+ // os: Operating system (e.g., 'linux', 'windows', 'darwin')
9696+ Os string `json:"os" cborgen:"os"`
9797+ // osFeatures: Optional OS features
9898+ OsFeatures []string `json:"osFeatures,omitempty" cborgen:"osFeatures,omitempty"`
9999+ // osVersion: Optional OS version
100100+ OsVersion *string `json:"osVersion,omitempty" cborgen:"osVersion,omitempty"`
101101+ // variant: Optional CPU variant (e.g., 'v7' for ARM)
102102+ Variant *string `json:"variant,omitempty" cborgen:"variant,omitempty"`
103103+}
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.sailor.profile
44+55+package atproto
66+77+// User profile for ATCR registry. Stores preferences like default hold for blob storage.
88+type SailorProfile struct {
99+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.sailor.profile"`
1010+ // createdAt: Profile creation timestamp
1111+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
1212+ // defaultHold: Default hold endpoint for blob storage. If null, user has opted out of defaults.
1313+ DefaultHold *string `json:"defaultHold,omitempty" cborgen:"defaultHold,omitempty"`
1414+ // updatedAt: Profile last updated timestamp
1515+ UpdatedAt *string `json:"updatedAt,omitempty" cborgen:"updatedAt,omitempty"`
1616+}
+25
pkg/atproto/sailorstar.go
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.sailor.star
44+55+package atproto
66+77+// A star (like) on a container image repository. Stored in the starrer's PDS, similar to Bluesky likes.
88+type SailorStar struct {
99+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.sailor.star"`
1010+ // createdAt: Star creation timestamp
1111+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
1212+ // subject: The repository being starred
1313+ Subject SailorStar_Subject `json:"subject" cborgen:"subject"`
1414+}
1515+1616+// SailorStar_Subject is a "subject" in the io.atcr.sailor.star schema.
1717+//
1818+// Reference to a repository owned by a user
1919+type SailorStar_Subject struct {
2020+ LexiconTypeID string `json:"$type,omitempty" cborgen:"$type,const=io.atcr.sailor.star#subject,omitempty"`
2121+ // did: DID of the repository owner
2222+ Did string `json:"did" cborgen:"did"`
2323+ // repository: Repository name (e.g., 'myapp')
2424+ Repository string `json:"repository" cborgen:"repository"`
2525+}
+20
pkg/atproto/tag.go
···11+// Code generated by generate.go; DO NOT EDIT.
22+33+// Lexicon schema: io.atcr.tag
44+55+package atproto
66+77+// A named tag pointing to a specific manifest digest
88+type Tag struct {
99+ LexiconTypeID string `json:"$type" cborgen:"$type,const=io.atcr.tag"`
1010+ // createdAt: Tag creation timestamp
1111+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
1212+ // manifest: AT-URI of the manifest this tag points to (e.g., 'at://did:plc:xyz/io.atcr.manifest/abc123'). Preferred over manifestDigest for new records.
1313+ Manifest *string `json:"manifest,omitempty" cborgen:"manifest,omitempty"`
1414+ // manifestDigest: DEPRECATED: Digest of the manifest (e.g., 'sha256:...'). Kept for backward compatibility with old records. New records should use 'manifest' field instead.
1515+ ManifestDigest *string `json:"manifestDigest,omitempty" cborgen:"manifestDigest,omitempty"`
1616+ // repository: Repository name (e.g., 'myapp'). Scoped to user's DID.
1717+ Repository string `json:"repository" cborgen:"repository"`
1818+ // tag: Tag name (e.g., 'latest', 'v1.0.0', '12-slim')
1919+ Tag string `json:"tag" cborgen:"tag"`
2020+}