// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
package org_tangled
// schema: org.tangled.feed.comment
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 (
FeedCommentNSID = "org.tangled.feed.comment"
)
func init() {
util.RegisterType("org.tangled.feed.comment", &FeedComment{})
} //
// RECORDTYPE: FeedComment
type FeedComment struct {
LexiconTypeID string `json:"$type,const=org.tangled.feed.comment" 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 *comatprototypes.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("cannot marshal empty enum")
}
func (t *FeedComment_Body) UnmarshalJSON(b []byte) error {
typ, err := util.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("cannot cbor marshal empty enum")
}
func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error {
typ, b, err := util.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("cannot marshal empty enum")
}
func (t *FeedComment_Embed) UnmarshalJSON(b []byte) error {
typ, err := util.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("cannot cbor marshal empty enum")
}
func (t *FeedComment_Embed) UnmarshalCBOR(r io.Reader) error {
typ, b, err := util.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 *comatprototypes.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("cannot marshal empty enum")
}
func (t *FeedComment_Subject) UnmarshalJSON(b []byte) error {
typ, err := util.TypeExtract(b)
if err != nil {
return err
}
switch typ {
case "com.atproto.repo.strongRef":
t.RepoStrongRef = new(comatprototypes.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("cannot cbor marshal empty enum")
}
func (t *FeedComment_Subject) UnmarshalCBOR(r io.Reader) error {
typ, b, err := util.CborTypeExtractReader(r)
if err != nil {
return err
}
switch typ {
case "com.atproto.repo.strongRef":
t.RepoStrongRef = new(comatprototypes.RepoStrongRef)
return t.RepoStrongRef.UnmarshalCBOR(bytes.NewReader(b))
default:
return nil
}
}