1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.graph.list
6
7import (
8 "bytes"
9 "encoding/json"
10 "fmt"
11 "io"
12
13 comatprototypes "github.com/bluesky-social/indigo/api/atproto"
14 "github.com/bluesky-social/indigo/lex/util"
15 cbg "github.com/whyrusleeping/cbor-gen"
16)
17
18func init() {
19 util.RegisterType("app.bsky.graph.list", &GraphList{})
20} //
21// RECORDTYPE: GraphList
22type GraphList struct {
23 LexiconTypeID string `json:"$type,const=app.bsky.graph.list" cborgen:"$type,const=app.bsky.graph.list"`
24 Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
25 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
26 Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
27 DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"`
28 Labels *GraphList_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
29 // name: Display name for list; can not be empty.
30 Name string `json:"name" cborgen:"name"`
31 // purpose: Defines the purpose of the list (aka, moderation-oriented or curration-oriented)
32 Purpose *string `json:"purpose" cborgen:"purpose"`
33}
34
35type GraphList_Labels struct {
36 LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
37}
38
39func (t *GraphList_Labels) MarshalJSON() ([]byte, error) {
40 if t.LabelDefs_SelfLabels != nil {
41 t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
42 return json.Marshal(t.LabelDefs_SelfLabels)
43 }
44 return nil, fmt.Errorf("cannot marshal empty enum")
45}
46func (t *GraphList_Labels) UnmarshalJSON(b []byte) error {
47 typ, err := util.TypeExtract(b)
48 if err != nil {
49 return err
50 }
51
52 switch typ {
53 case "com.atproto.label.defs#selfLabels":
54 t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
55 return json.Unmarshal(b, t.LabelDefs_SelfLabels)
56
57 default:
58 return nil
59 }
60}
61
62func (t *GraphList_Labels) MarshalCBOR(w io.Writer) error {
63
64 if t == nil {
65 _, err := w.Write(cbg.CborNull)
66 return err
67 }
68 if t.LabelDefs_SelfLabels != nil {
69 return t.LabelDefs_SelfLabels.MarshalCBOR(w)
70 }
71 return fmt.Errorf("cannot cbor marshal empty enum")
72}
73func (t *GraphList_Labels) UnmarshalCBOR(r io.Reader) error {
74 typ, b, err := util.CborTypeExtractReader(r)
75 if err != nil {
76 return err
77 }
78
79 switch typ {
80 case "com.atproto.label.defs#selfLabels":
81 t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
82 return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
83
84 default:
85 return nil
86 }
87}