// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. // Lexicon schema: org.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("org.tangled.feed.comment", &FeedComment{}) } type FeedComment struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=org.tangled.feed.comment"` Body *FeedComment_Body `json:"body" cborgen:"body"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` Embed *FeedComment_Embed `json:"embed,omitempty" cborgen:"embed,omitempty"` ReplyTo *comatproto.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` Subject *FeedComment_Subject `json:"subject" cborgen:"subject"` } type FeedComment_Body struct { MarkupMarkdown *MarkupMarkdown } func (t *FeedComment_Body) MarshalJSON() ([]byte, error) { if t.MarkupMarkdown != nil { t.MarkupMarkdown.LexiconTypeID = "org.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 "org.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 "org.tangled.markup.markdown": t.MarkupMarkdown = new(MarkupMarkdown) return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } } type FeedComment_Embed struct { EmbedCommit *EmbedCommit } func (t *FeedComment_Embed) MarshalJSON() ([]byte, error) { if t.EmbedCommit != nil { t.EmbedCommit.LexiconTypeID = "org.tangled.embed.commit" return json.Marshal(t.EmbedCommit) } return nil, fmt.Errorf("can not marshal empty union as JSON") } func (t *FeedComment_Embed) UnmarshalJSON(b []byte) error { typ, err := lexutil.TypeExtract(b) if err != nil { return err } switch typ { case "org.tangled.embed.commit": t.EmbedCommit = new(EmbedCommit) return json.Unmarshal(b, t.EmbedCommit) default: return nil } } func (t *FeedComment_Embed) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.EmbedCommit != nil { return t.EmbedCommit.MarshalCBOR(w) } return fmt.Errorf("can not marshal empty union as CBOR") } func (t *FeedComment_Embed) UnmarshalCBOR(r io.Reader) error { typ, b, err := lexutil.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "org.tangled.embed.commit": t.EmbedCommit = new(EmbedCommit) return t.EmbedCommit.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } } type FeedComment_Subject struct { RepoStrongRef *comatproto.RepoStrongRef } func (t *FeedComment_Subject) MarshalJSON() ([]byte, error) { if t.RepoStrongRef != nil { t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef" return json.Marshal(t.RepoStrongRef) } return nil, fmt.Errorf("can not marshal empty union as JSON") } func (t *FeedComment_Subject) UnmarshalJSON(b []byte) error { typ, err := lexutil.TypeExtract(b) if err != nil { return err } switch typ { case "com.atproto.repo.strongRef": t.RepoStrongRef = new(comatproto.RepoStrongRef) return json.Unmarshal(b, t.RepoStrongRef) default: return nil } } func (t *FeedComment_Subject) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.RepoStrongRef != nil { return t.RepoStrongRef.MarshalCBOR(w) } return fmt.Errorf("can not marshal empty union as CBOR") } func (t *FeedComment_Subject) UnmarshalCBOR(r io.Reader) error { typ, b, err := lexutil.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "com.atproto.repo.strongRef": t.RepoStrongRef = new(comatproto.RepoStrongRef) return t.RepoStrongRef.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } }