// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. package tangled // schema: sh.tangled.feed.subscription import ( "bytes" "encoding/json" "fmt" "io" "github.com/bluesky-social/indigo/lex/util" cbg "github.com/whyrusleeping/cbor-gen" ) const ( FeedSubscriptionNSID = "sh.tangled.feed.subscription" ) func init() { util.RegisterType("sh.tangled.feed.subscription", &FeedSubscription{}) } // // RECORDTYPE: FeedSubscription type FeedSubscription struct { LexiconTypeID string `json:"$type,const=sh.tangled.feed.subscription" cborgen:"$type,const=sh.tangled.feed.subscription"` // collections: Optional collection NSIDs to filter which notifications are sent. Empty or absent means all collections. Collections []string `json:"collections,omitempty" cborgen:"collections,omitempty"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` Subject *FeedSubscription_Subject `json:"subject" cborgen:"subject"` } // FeedSubscription_Repo is a "repo" in the sh.tangled.feed.subscription schema. // // RECORDTYPE: FeedSubscription_Repo type FeedSubscription_Repo struct { LexiconTypeID string `json:"$type,const=sh.tangled.feed.subscription#repo" cborgen:"$type,const=sh.tangled.feed.subscription#repo"` Did string `json:"did" cborgen:"did"` } type FeedSubscription_Subject struct { FeedSubscription_Uri *FeedSubscription_Uri FeedSubscription_Repo *FeedSubscription_Repo } func (t *FeedSubscription_Subject) MarshalJSON() ([]byte, error) { if t.FeedSubscription_Uri != nil { t.FeedSubscription_Uri.LexiconTypeID = "sh.tangled.feed.subscription#uri" return json.Marshal(t.FeedSubscription_Uri) } if t.FeedSubscription_Repo != nil { t.FeedSubscription_Repo.LexiconTypeID = "sh.tangled.feed.subscription#repo" return json.Marshal(t.FeedSubscription_Repo) } return nil, fmt.Errorf("cannot marshal empty enum") } func (t *FeedSubscription_Subject) UnmarshalJSON(b []byte) error { typ, err := util.TypeExtract(b) if err != nil { return err } switch typ { case "sh.tangled.feed.subscription#uri": t.FeedSubscription_Uri = new(FeedSubscription_Uri) return json.Unmarshal(b, t.FeedSubscription_Uri) case "sh.tangled.feed.subscription#repo": t.FeedSubscription_Repo = new(FeedSubscription_Repo) return json.Unmarshal(b, t.FeedSubscription_Repo) default: return fmt.Errorf("closed enums must have a matching value") } } func (t *FeedSubscription_Subject) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.FeedSubscription_Uri != nil { return t.FeedSubscription_Uri.MarshalCBOR(w) } if t.FeedSubscription_Repo != nil { return t.FeedSubscription_Repo.MarshalCBOR(w) } return fmt.Errorf("cannot cbor marshal empty enum") } func (t *FeedSubscription_Subject) UnmarshalCBOR(r io.Reader) error { typ, b, err := util.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "sh.tangled.feed.subscription#uri": t.FeedSubscription_Uri = new(FeedSubscription_Uri) return t.FeedSubscription_Uri.UnmarshalCBOR(bytes.NewReader(b)) case "sh.tangled.feed.subscription#repo": t.FeedSubscription_Repo = new(FeedSubscription_Repo) return t.FeedSubscription_Repo.UnmarshalCBOR(bytes.NewReader(b)) default: return fmt.Errorf("closed enums must have a matching value") } } // FeedSubscription_Uri is a "uri" in the sh.tangled.feed.subscription schema. // // RECORDTYPE: FeedSubscription_Uri type FeedSubscription_Uri struct { LexiconTypeID string `json:"$type,const=sh.tangled.feed.subscription#uri" cborgen:"$type,const=sh.tangled.feed.subscription#uri"` Uri string `json:"uri" cborgen:"uri"` }