// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. package org_tangled // schema: org.tangled.feed.star import ( "bytes" "encoding/json" "fmt" "io" comatprototypes "github.com/bluesky-social/indigo/api/atproto" "github.com/bluesky-social/indigo/lex/util" cbg "github.com/whyrusleeping/cbor-gen" ) const ( FeedStarNSID = "org.tangled.feed.star" ) func init() { util.RegisterType("org.tangled.feed.star", &FeedStar{}) } // // RECORDTYPE: FeedStar type FeedStar struct { LexiconTypeID string `json:"$type,const=org.tangled.feed.star" cborgen:"$type,const=org.tangled.feed.star"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` Subject *FeedStar_Subject `json:"subject" cborgen:"subject"` } // FeedStar_Record is a "record" in the org.tangled.feed.star schema. // // RECORDTYPE: FeedStar_Record type FeedStar_Record struct { LexiconTypeID string `json:"$type,const=org.tangled.feed.star#record" cborgen:"$type,const=org.tangled.feed.star#record"` Record *comatprototypes.RepoStrongRef `json:"record" cborgen:"record"` } // FeedStar_Repo is a "repo" in the org.tangled.feed.star schema. // // RECORDTYPE: FeedStar_Repo type FeedStar_Repo struct { LexiconTypeID string `json:"$type,const=org.tangled.feed.star#repo" cborgen:"$type,const=org.tangled.feed.star#repo"` Identity string `json:"identity" cborgen:"identity"` } type FeedStar_Subject struct { FeedStar_Repo *FeedStar_Repo FeedStar_Record *FeedStar_Record } func (t *FeedStar_Subject) MarshalJSON() ([]byte, error) { if t.FeedStar_Repo != nil { t.FeedStar_Repo.LexiconTypeID = "org.tangled.feed.star#repo" return json.Marshal(t.FeedStar_Repo) } if t.FeedStar_Record != nil { t.FeedStar_Record.LexiconTypeID = "org.tangled.feed.star#record" return json.Marshal(t.FeedStar_Record) } return nil, fmt.Errorf("cannot marshal empty enum") } func (t *FeedStar_Subject) UnmarshalJSON(b []byte) error { typ, err := util.TypeExtract(b) if err != nil { return err } switch typ { case "org.tangled.feed.star#repo": t.FeedStar_Repo = new(FeedStar_Repo) return json.Unmarshal(b, t.FeedStar_Repo) case "org.tangled.feed.star#record": t.FeedStar_Record = new(FeedStar_Record) return json.Unmarshal(b, t.FeedStar_Record) default: return fmt.Errorf("closed enums must have a matching value") } } func (t *FeedStar_Subject) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.FeedStar_Repo != nil { return t.FeedStar_Repo.MarshalCBOR(w) } if t.FeedStar_Record != nil { return t.FeedStar_Record.MarshalCBOR(w) } return fmt.Errorf("cannot cbor marshal empty enum") } func (t *FeedStar_Subject) UnmarshalCBOR(r io.Reader) error { typ, b, err := util.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "org.tangled.feed.star#repo": t.FeedStar_Repo = new(FeedStar_Repo) return t.FeedStar_Repo.UnmarshalCBOR(bytes.NewReader(b)) case "org.tangled.feed.star#record": t.FeedStar_Record = new(FeedStar_Record) return t.FeedStar_Record.UnmarshalCBOR(bytes.NewReader(b)) default: return fmt.Errorf("closed enums must have a matching value") } }