// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. // Lexicon schema: sh.tangled.feed.comment package tangledlex import ( "bytes" "encoding/json" "fmt" "io" comatproto "github.com/bluesky-social/indigo/api/atproto" lexutil "github.com/bluesky-social/indigo/lex/util" cbg "github.com/whyrusleeping/cbor-gen" ) func init() { lexutil.RegisterType("sh.tangled.feed.comment", &FeedComment{}) } type FeedComment struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.feed.comment"` Body *FeedComment_Body `json:"body" cborgen:"body"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` // pullRoundIdx: optional pull submission round index. required when subject is sh.tangled.repo.pull PullRoundIdx *int64 `json:"pullRoundIdx,omitempty" cborgen:"pullRoundIdx,omitempty"` ReplyTo *comatproto.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` Subject *comatproto.RepoStrongRef `json:"subject" cborgen:"subject"` } type FeedComment_Body struct { MarkupMarkdown *MarkupMarkdown } func (t *FeedComment_Body) MarshalJSON() ([]byte, error) { if t.MarkupMarkdown != nil { t.MarkupMarkdown.LexiconTypeID = "sh.tangled.markup.markdown" return json.Marshal(t.MarkupMarkdown) } return nil, fmt.Errorf("can not marshal empty union as JSON") } func (t *FeedComment_Body) UnmarshalJSON(b []byte) error { typ, err := lexutil.TypeExtract(b) if err != nil { return err } switch typ { case "sh.tangled.markup.markdown": t.MarkupMarkdown = new(MarkupMarkdown) return json.Unmarshal(b, t.MarkupMarkdown) default: return nil } } func (t *FeedComment_Body) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.MarkupMarkdown != nil { return t.MarkupMarkdown.MarshalCBOR(w) } return fmt.Errorf("can not marshal empty union as CBOR") } func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error { typ, b, err := lexutil.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "sh.tangled.markup.markdown": t.MarkupMarkdown = new(MarkupMarkdown) return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } }