// Code generated by glex; DO NOT EDIT. // Lexicon schema: app.bsky.feed.defs package appbsky import ( "encoding/json" "fmt" "io" glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" comatproto "stream.place/streamplace/pkg/comatproto" ) // FeedDefs_BlockedAuthor is a "blockedAuthor" in the app.bsky.feed.defs schema. type FeedDefs_BlockedAuthor struct { LexiconTypeID string `json:"$type,omitempty"` Did string `json:"did"` Viewer *ActorDefs_ViewerState `json:"viewer,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_BlockedAuthor) RecordTypeID() string { return "app.bsky.feed.defs#blockedAuthor" } func (t *FeedDefs_BlockedAuthor) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#blockedAuthor" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_BlockedAuthor) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_BlockedPost is a "blockedPost" in the app.bsky.feed.defs schema. type FeedDefs_BlockedPost struct { LexiconTypeID string `json:"$type,omitempty"` Author FeedDefs_BlockedAuthor `json:"author"` Blocked bool `json:"blocked"` Uri string `json:"uri"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_BlockedPost) RecordTypeID() string { return "app.bsky.feed.defs#blockedPost" } func (t *FeedDefs_BlockedPost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_BlockedPost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_FeedViewPost is a "feedViewPost" in the app.bsky.feed.defs schema. type FeedDefs_FeedViewPost struct { LexiconTypeID string `json:"$type,omitempty"` // feedContext: Context provided by feed generator that may be passed back alongside interactions. FeedContext *string `json:"feedContext,omitempty"` Post FeedDefs_PostView `json:"post"` Reason *FeedDefs_FeedViewPost_Reason `json:"reason,omitempty"` Reply *FeedDefs_ReplyRef `json:"reply,omitempty"` // reqId: Unique identifier per request that may be passed back alongside interactions. ReqId *string `json:"reqId,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_FeedViewPost) RecordTypeID() string { return "app.bsky.feed.defs#feedViewPost" } func (t *FeedDefs_FeedViewPost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#feedViewPost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_FeedViewPost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } type FeedDefs_FeedViewPost_Reason struct { FeedDefs_ReasonPin *FeedDefs_ReasonPin FeedDefs_ReasonRepost *FeedDefs_ReasonRepost // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_FeedViewPost_Reason and *FeedDefs_FeedViewPost_Reason marshal correctly. func (t FeedDefs_FeedViewPost_Reason) MarshalJSON() ([]byte, error) { if t.FeedDefs_ReasonPin != nil { cp := *t.FeedDefs_ReasonPin cp.LexiconTypeID = "app.bsky.feed.defs#reasonPin" return json.Marshal(&cp) } if t.FeedDefs_ReasonRepost != nil { cp := *t.FeedDefs_ReasonRepost cp.LexiconTypeID = "app.bsky.feed.defs#reasonRepost" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_FeedViewPost_Reason", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_FeedViewPost_Reason as JSON") } func (t *FeedDefs_FeedViewPost_Reason) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#reasonPin": t.FeedDefs_ReasonPin = new(FeedDefs_ReasonPin) return json.Unmarshal(b, t.FeedDefs_ReasonPin) case "app.bsky.feed.defs#reasonRepost": t.FeedDefs_ReasonRepost = new(FeedDefs_ReasonRepost) return json.Unmarshal(b, t.FeedDefs_ReasonRepost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_FeedViewPost_Reason) MarshalCBOR() ([]byte, error) { if t.FeedDefs_ReasonPin != nil { cp := *t.FeedDefs_ReasonPin cp.LexiconTypeID = "app.bsky.feed.defs#reasonPin" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_ReasonRepost != nil { cp := *t.FeedDefs_ReasonRepost cp.LexiconTypeID = "app.bsky.feed.defs#reasonRepost" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_FeedViewPost_Reason", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_FeedViewPost_Reason as CBOR") } func (t *FeedDefs_FeedViewPost_Reason) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#reasonPin": t.FeedDefs_ReasonPin = new(FeedDefs_ReasonPin) return glex.UnmarshalCBORBytes(b, t.FeedDefs_ReasonPin) case "app.bsky.feed.defs#reasonRepost": t.FeedDefs_ReasonRepost = new(FeedDefs_ReasonRepost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_ReasonRepost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // FeedDefs_GeneratorView is a "generatorView" in the app.bsky.feed.defs schema. type FeedDefs_GeneratorView struct { LexiconTypeID string `json:"$type,omitempty"` AcceptsInteractions *bool `json:"acceptsInteractions,omitempty"` Avatar *string `json:"avatar,omitempty"` Cid string `json:"cid"` ContentMode *string `json:"contentMode,omitempty"` Creator ActorDefs_ProfileView `json:"creator"` Description *string `json:"description,omitempty"` DescriptionFacets []RichtextFacet `json:"descriptionFacets,omitempty"` Did string `json:"did"` DisplayName string `json:"displayName"` IndexedAt string `json:"indexedAt"` Labels []comatproto.LabelDefs_Label `json:"labels,omitempty"` LikeCount *int64 `json:"likeCount,omitempty"` Uri string `json:"uri"` Viewer *FeedDefs_GeneratorViewerState `json:"viewer,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_GeneratorView) RecordTypeID() string { return "app.bsky.feed.defs#generatorView" } func (t *FeedDefs_GeneratorView) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#generatorView" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_GeneratorView) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_GeneratorViewerState is a "generatorViewerState" in the app.bsky.feed.defs schema. type FeedDefs_GeneratorViewerState struct { LexiconTypeID string `json:"$type,omitempty"` Like *string `json:"like,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_GeneratorViewerState) RecordTypeID() string { return "app.bsky.feed.defs#generatorViewerState" } func (t *FeedDefs_GeneratorViewerState) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#generatorViewerState" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_GeneratorViewerState) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_Interaction is a "interaction" in the app.bsky.feed.defs schema. type FeedDefs_Interaction struct { LexiconTypeID string `json:"$type,omitempty"` Event *string `json:"event,omitempty"` // feedContext: Context on a feed item that was originally supplied by the feed generator on getFeedSkeleton. FeedContext *string `json:"feedContext,omitempty"` Item *string `json:"item,omitempty"` // reqId: Unique identifier per request that may be passed back alongside interactions. ReqId *string `json:"reqId,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_Interaction) RecordTypeID() string { return "app.bsky.feed.defs#interaction" } func (t *FeedDefs_Interaction) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#interaction" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_Interaction) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_NotFoundPost is a "notFoundPost" in the app.bsky.feed.defs schema. type FeedDefs_NotFoundPost struct { LexiconTypeID string `json:"$type,omitempty"` NotFound bool `json:"notFound"` Uri string `json:"uri"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_NotFoundPost) RecordTypeID() string { return "app.bsky.feed.defs#notFoundPost" } func (t *FeedDefs_NotFoundPost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_NotFoundPost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_PostView is a "postView" in the app.bsky.feed.defs schema. type FeedDefs_PostView struct { LexiconTypeID string `json:"$type,omitempty"` Author ActorDefs_ProfileViewBasic `json:"author"` BookmarkCount *int64 `json:"bookmarkCount,omitempty"` Cid string `json:"cid"` // debug: Debug information for internal development Debug *glex.LexiconTypeDecoder `json:"debug,omitempty"` Embed *FeedDefs_PostView_Embed `json:"embed,omitempty"` IndexedAt string `json:"indexedAt"` Labels []comatproto.LabelDefs_Label `json:"labels,omitempty"` LikeCount *int64 `json:"likeCount,omitempty"` QuoteCount *int64 `json:"quoteCount,omitempty"` Record *glex.LexiconTypeDecoder `json:"record"` ReplyCount *int64 `json:"replyCount,omitempty"` RepostCount *int64 `json:"repostCount,omitempty"` Threadgate *FeedDefs_ThreadgateView `json:"threadgate,omitempty"` Uri string `json:"uri"` Viewer *FeedDefs_ViewerState `json:"viewer,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_PostView) RecordTypeID() string { return "app.bsky.feed.defs#postView" } func (t *FeedDefs_PostView) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#postView" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_PostView) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } type FeedDefs_PostView_Embed struct { EmbedExternal_View *EmbedExternal_View EmbedGallery_View *EmbedGallery_View EmbedImages_View *EmbedImages_View EmbedRecordWithMedia_View *EmbedRecordWithMedia_View EmbedRecord_View *EmbedRecord_View EmbedVideo_View *EmbedVideo_View // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_PostView_Embed and *FeedDefs_PostView_Embed marshal correctly. func (t FeedDefs_PostView_Embed) MarshalJSON() ([]byte, error) { if t.EmbedExternal_View != nil { cp := *t.EmbedExternal_View cp.LexiconTypeID = "app.bsky.embed.external#view" return json.Marshal(&cp) } if t.EmbedGallery_View != nil { cp := *t.EmbedGallery_View cp.LexiconTypeID = "app.bsky.embed.gallery#view" return json.Marshal(&cp) } if t.EmbedImages_View != nil { cp := *t.EmbedImages_View cp.LexiconTypeID = "app.bsky.embed.images#view" return json.Marshal(&cp) } if t.EmbedRecordWithMedia_View != nil { cp := *t.EmbedRecordWithMedia_View cp.LexiconTypeID = "app.bsky.embed.recordWithMedia#view" return json.Marshal(&cp) } if t.EmbedRecord_View != nil { cp := *t.EmbedRecord_View cp.LexiconTypeID = "app.bsky.embed.record#view" return json.Marshal(&cp) } if t.EmbedVideo_View != nil { cp := *t.EmbedVideo_View cp.LexiconTypeID = "app.bsky.embed.video#view" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_PostView_Embed", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_PostView_Embed as JSON") } func (t *FeedDefs_PostView_Embed) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.embed.external#view": t.EmbedExternal_View = new(EmbedExternal_View) return json.Unmarshal(b, t.EmbedExternal_View) case "app.bsky.embed.gallery#view": t.EmbedGallery_View = new(EmbedGallery_View) return json.Unmarshal(b, t.EmbedGallery_View) case "app.bsky.embed.images#view": t.EmbedImages_View = new(EmbedImages_View) return json.Unmarshal(b, t.EmbedImages_View) case "app.bsky.embed.recordWithMedia#view": t.EmbedRecordWithMedia_View = new(EmbedRecordWithMedia_View) return json.Unmarshal(b, t.EmbedRecordWithMedia_View) case "app.bsky.embed.record#view": t.EmbedRecord_View = new(EmbedRecord_View) return json.Unmarshal(b, t.EmbedRecord_View) case "app.bsky.embed.video#view": t.EmbedVideo_View = new(EmbedVideo_View) return json.Unmarshal(b, t.EmbedVideo_View) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_PostView_Embed) MarshalCBOR() ([]byte, error) { if t.EmbedExternal_View != nil { cp := *t.EmbedExternal_View cp.LexiconTypeID = "app.bsky.embed.external#view" return glex.MarshalCBORBytes(&cp) } if t.EmbedGallery_View != nil { cp := *t.EmbedGallery_View cp.LexiconTypeID = "app.bsky.embed.gallery#view" return glex.MarshalCBORBytes(&cp) } if t.EmbedImages_View != nil { cp := *t.EmbedImages_View cp.LexiconTypeID = "app.bsky.embed.images#view" return glex.MarshalCBORBytes(&cp) } if t.EmbedRecordWithMedia_View != nil { cp := *t.EmbedRecordWithMedia_View cp.LexiconTypeID = "app.bsky.embed.recordWithMedia#view" return glex.MarshalCBORBytes(&cp) } if t.EmbedRecord_View != nil { cp := *t.EmbedRecord_View cp.LexiconTypeID = "app.bsky.embed.record#view" return glex.MarshalCBORBytes(&cp) } if t.EmbedVideo_View != nil { cp := *t.EmbedVideo_View cp.LexiconTypeID = "app.bsky.embed.video#view" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_PostView_Embed", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_PostView_Embed as CBOR") } func (t *FeedDefs_PostView_Embed) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.embed.external#view": t.EmbedExternal_View = new(EmbedExternal_View) return glex.UnmarshalCBORBytes(b, t.EmbedExternal_View) case "app.bsky.embed.gallery#view": t.EmbedGallery_View = new(EmbedGallery_View) return glex.UnmarshalCBORBytes(b, t.EmbedGallery_View) case "app.bsky.embed.images#view": t.EmbedImages_View = new(EmbedImages_View) return glex.UnmarshalCBORBytes(b, t.EmbedImages_View) case "app.bsky.embed.recordWithMedia#view": t.EmbedRecordWithMedia_View = new(EmbedRecordWithMedia_View) return glex.UnmarshalCBORBytes(b, t.EmbedRecordWithMedia_View) case "app.bsky.embed.record#view": t.EmbedRecord_View = new(EmbedRecord_View) return glex.UnmarshalCBORBytes(b, t.EmbedRecord_View) case "app.bsky.embed.video#view": t.EmbedVideo_View = new(EmbedVideo_View) return glex.UnmarshalCBORBytes(b, t.EmbedVideo_View) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // FeedDefs_ReasonPin is a "reasonPin" in the app.bsky.feed.defs schema. type FeedDefs_ReasonPin struct { LexiconTypeID string `json:"$type,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ReasonPin) RecordTypeID() string { return "app.bsky.feed.defs#reasonPin" } func (t *FeedDefs_ReasonPin) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#reasonPin" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ReasonPin) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_ReasonRepost is a "reasonRepost" in the app.bsky.feed.defs schema. type FeedDefs_ReasonRepost struct { LexiconTypeID string `json:"$type,omitempty"` By ActorDefs_ProfileViewBasic `json:"by"` Cid *string `json:"cid,omitempty"` IndexedAt string `json:"indexedAt"` Uri *string `json:"uri,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ReasonRepost) RecordTypeID() string { return "app.bsky.feed.defs#reasonRepost" } func (t *FeedDefs_ReasonRepost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#reasonRepost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ReasonRepost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_ReplyRef is a "replyRef" in the app.bsky.feed.defs schema. type FeedDefs_ReplyRef struct { LexiconTypeID string `json:"$type,omitempty"` // grandparentAuthor: When parent is a reply to another post, this is the author of that post. GrandparentAuthor *ActorDefs_ProfileViewBasic `json:"grandparentAuthor,omitempty"` Parent FeedDefs_ReplyRef_Parent `json:"parent"` Root FeedDefs_ReplyRef_Root `json:"root"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ReplyRef) RecordTypeID() string { return "app.bsky.feed.defs#replyRef" } func (t *FeedDefs_ReplyRef) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#replyRef" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ReplyRef) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } type FeedDefs_ReplyRef_Parent struct { FeedDefs_BlockedPost *FeedDefs_BlockedPost FeedDefs_NotFoundPost *FeedDefs_NotFoundPost FeedDefs_PostView *FeedDefs_PostView // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_ReplyRef_Parent and *FeedDefs_ReplyRef_Parent marshal correctly. func (t FeedDefs_ReplyRef_Parent) MarshalJSON() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return json.Marshal(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return json.Marshal(&cp) } if t.FeedDefs_PostView != nil { cp := *t.FeedDefs_PostView cp.LexiconTypeID = "app.bsky.feed.defs#postView" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_ReplyRef_Parent", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ReplyRef_Parent as JSON") } func (t *FeedDefs_ReplyRef_Parent) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return json.Unmarshal(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return json.Unmarshal(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#postView": t.FeedDefs_PostView = new(FeedDefs_PostView) return json.Unmarshal(b, t.FeedDefs_PostView) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_ReplyRef_Parent) MarshalCBOR() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_PostView != nil { cp := *t.FeedDefs_PostView cp.LexiconTypeID = "app.bsky.feed.defs#postView" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_ReplyRef_Parent", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ReplyRef_Parent as CBOR") } func (t *FeedDefs_ReplyRef_Parent) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#postView": t.FeedDefs_PostView = new(FeedDefs_PostView) return glex.UnmarshalCBORBytes(b, t.FeedDefs_PostView) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } type FeedDefs_ReplyRef_Root struct { FeedDefs_BlockedPost *FeedDefs_BlockedPost FeedDefs_NotFoundPost *FeedDefs_NotFoundPost FeedDefs_PostView *FeedDefs_PostView // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_ReplyRef_Root and *FeedDefs_ReplyRef_Root marshal correctly. func (t FeedDefs_ReplyRef_Root) MarshalJSON() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return json.Marshal(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return json.Marshal(&cp) } if t.FeedDefs_PostView != nil { cp := *t.FeedDefs_PostView cp.LexiconTypeID = "app.bsky.feed.defs#postView" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_ReplyRef_Root", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ReplyRef_Root as JSON") } func (t *FeedDefs_ReplyRef_Root) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return json.Unmarshal(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return json.Unmarshal(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#postView": t.FeedDefs_PostView = new(FeedDefs_PostView) return json.Unmarshal(b, t.FeedDefs_PostView) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_ReplyRef_Root) MarshalCBOR() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_PostView != nil { cp := *t.FeedDefs_PostView cp.LexiconTypeID = "app.bsky.feed.defs#postView" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_ReplyRef_Root", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ReplyRef_Root as CBOR") } func (t *FeedDefs_ReplyRef_Root) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#postView": t.FeedDefs_PostView = new(FeedDefs_PostView) return glex.UnmarshalCBORBytes(b, t.FeedDefs_PostView) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // FeedDefs_SkeletonFeedPost is a "skeletonFeedPost" in the app.bsky.feed.defs schema. type FeedDefs_SkeletonFeedPost struct { LexiconTypeID string `json:"$type,omitempty"` // feedContext: Context that will be passed through to client and may be passed to feed generator back alongside interactions. FeedContext *string `json:"feedContext,omitempty"` Post string `json:"post"` Reason *FeedDefs_SkeletonFeedPost_Reason `json:"reason,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_SkeletonFeedPost) RecordTypeID() string { return "app.bsky.feed.defs#skeletonFeedPost" } func (t *FeedDefs_SkeletonFeedPost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#skeletonFeedPost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_SkeletonFeedPost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } type FeedDefs_SkeletonFeedPost_Reason struct { FeedDefs_SkeletonReasonPin *FeedDefs_SkeletonReasonPin FeedDefs_SkeletonReasonRepost *FeedDefs_SkeletonReasonRepost // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_SkeletonFeedPost_Reason and *FeedDefs_SkeletonFeedPost_Reason marshal correctly. func (t FeedDefs_SkeletonFeedPost_Reason) MarshalJSON() ([]byte, error) { if t.FeedDefs_SkeletonReasonPin != nil { cp := *t.FeedDefs_SkeletonReasonPin cp.LexiconTypeID = "app.bsky.feed.defs#skeletonReasonPin" return json.Marshal(&cp) } if t.FeedDefs_SkeletonReasonRepost != nil { cp := *t.FeedDefs_SkeletonReasonRepost cp.LexiconTypeID = "app.bsky.feed.defs#skeletonReasonRepost" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_SkeletonFeedPost_Reason", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_SkeletonFeedPost_Reason as JSON") } func (t *FeedDefs_SkeletonFeedPost_Reason) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#skeletonReasonPin": t.FeedDefs_SkeletonReasonPin = new(FeedDefs_SkeletonReasonPin) return json.Unmarshal(b, t.FeedDefs_SkeletonReasonPin) case "app.bsky.feed.defs#skeletonReasonRepost": t.FeedDefs_SkeletonReasonRepost = new(FeedDefs_SkeletonReasonRepost) return json.Unmarshal(b, t.FeedDefs_SkeletonReasonRepost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_SkeletonFeedPost_Reason) MarshalCBOR() ([]byte, error) { if t.FeedDefs_SkeletonReasonPin != nil { cp := *t.FeedDefs_SkeletonReasonPin cp.LexiconTypeID = "app.bsky.feed.defs#skeletonReasonPin" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_SkeletonReasonRepost != nil { cp := *t.FeedDefs_SkeletonReasonRepost cp.LexiconTypeID = "app.bsky.feed.defs#skeletonReasonRepost" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_SkeletonFeedPost_Reason", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_SkeletonFeedPost_Reason as CBOR") } func (t *FeedDefs_SkeletonFeedPost_Reason) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#skeletonReasonPin": t.FeedDefs_SkeletonReasonPin = new(FeedDefs_SkeletonReasonPin) return glex.UnmarshalCBORBytes(b, t.FeedDefs_SkeletonReasonPin) case "app.bsky.feed.defs#skeletonReasonRepost": t.FeedDefs_SkeletonReasonRepost = new(FeedDefs_SkeletonReasonRepost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_SkeletonReasonRepost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // FeedDefs_SkeletonReasonPin is a "skeletonReasonPin" in the app.bsky.feed.defs schema. type FeedDefs_SkeletonReasonPin struct { LexiconTypeID string `json:"$type,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_SkeletonReasonPin) RecordTypeID() string { return "app.bsky.feed.defs#skeletonReasonPin" } func (t *FeedDefs_SkeletonReasonPin) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#skeletonReasonPin" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_SkeletonReasonPin) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_SkeletonReasonRepost is a "skeletonReasonRepost" in the app.bsky.feed.defs schema. type FeedDefs_SkeletonReasonRepost struct { LexiconTypeID string `json:"$type,omitempty"` Repost string `json:"repost"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_SkeletonReasonRepost) RecordTypeID() string { return "app.bsky.feed.defs#skeletonReasonRepost" } func (t *FeedDefs_SkeletonReasonRepost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#skeletonReasonRepost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_SkeletonReasonRepost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_ThreadContext is a "threadContext" in the app.bsky.feed.defs schema. // // Metadata about this post within the context of the thread it is in. type FeedDefs_ThreadContext struct { LexiconTypeID string `json:"$type,omitempty"` RootAuthorLike *string `json:"rootAuthorLike,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ThreadContext) RecordTypeID() string { return "app.bsky.feed.defs#threadContext" } func (t *FeedDefs_ThreadContext) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#threadContext" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ThreadContext) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_ThreadViewPost is a "threadViewPost" in the app.bsky.feed.defs schema. type FeedDefs_ThreadViewPost struct { LexiconTypeID string `json:"$type,omitempty"` Parent *FeedDefs_ThreadViewPost_Parent `json:"parent,omitempty"` Post FeedDefs_PostView `json:"post"` Replies []FeedDefs_ThreadViewPost_Replies_Elem `json:"replies,omitempty"` ThreadContext *FeedDefs_ThreadContext `json:"threadContext,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ThreadViewPost) RecordTypeID() string { return "app.bsky.feed.defs#threadViewPost" } func (t *FeedDefs_ThreadViewPost) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#threadViewPost" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ThreadViewPost) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } type FeedDefs_ThreadViewPost_Parent struct { FeedDefs_BlockedPost *FeedDefs_BlockedPost FeedDefs_NotFoundPost *FeedDefs_NotFoundPost FeedDefs_ThreadViewPost *FeedDefs_ThreadViewPost // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_ThreadViewPost_Parent and *FeedDefs_ThreadViewPost_Parent marshal correctly. func (t FeedDefs_ThreadViewPost_Parent) MarshalJSON() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return json.Marshal(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return json.Marshal(&cp) } if t.FeedDefs_ThreadViewPost != nil { cp := *t.FeedDefs_ThreadViewPost cp.LexiconTypeID = "app.bsky.feed.defs#threadViewPost" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_ThreadViewPost_Parent", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ThreadViewPost_Parent as JSON") } func (t *FeedDefs_ThreadViewPost_Parent) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return json.Unmarshal(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return json.Unmarshal(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#threadViewPost": t.FeedDefs_ThreadViewPost = new(FeedDefs_ThreadViewPost) return json.Unmarshal(b, t.FeedDefs_ThreadViewPost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_ThreadViewPost_Parent) MarshalCBOR() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_ThreadViewPost != nil { cp := *t.FeedDefs_ThreadViewPost cp.LexiconTypeID = "app.bsky.feed.defs#threadViewPost" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_ThreadViewPost_Parent", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ThreadViewPost_Parent as CBOR") } func (t *FeedDefs_ThreadViewPost_Parent) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#threadViewPost": t.FeedDefs_ThreadViewPost = new(FeedDefs_ThreadViewPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_ThreadViewPost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } type FeedDefs_ThreadViewPost_Replies_Elem struct { FeedDefs_BlockedPost *FeedDefs_BlockedPost FeedDefs_NotFoundPost *FeedDefs_NotFoundPost FeedDefs_ThreadViewPost *FeedDefs_ThreadViewPost // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord } // MarshalJSON emits the set variant, stamped with its $type, per the atproto // union wire format. The value receiver stamps a copy, so the variant is // never mutated and both FeedDefs_ThreadViewPost_Replies_Elem and *FeedDefs_ThreadViewPost_Replies_Elem marshal correctly. func (t FeedDefs_ThreadViewPost_Replies_Elem) MarshalJSON() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return json.Marshal(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return json.Marshal(&cp) } if t.FeedDefs_ThreadViewPost != nil { cp := *t.FeedDefs_ThreadViewPost cp.LexiconTypeID = "app.bsky.feed.defs#threadViewPost" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedDefs_ThreadViewPost_Replies_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ThreadViewPost_Replies_Elem as JSON") } func (t *FeedDefs_ThreadViewPost_Replies_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return json.Unmarshal(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return json.Unmarshal(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#threadViewPost": t.FeedDefs_ThreadViewPost = new(FeedDefs_ThreadViewPost) return json.Unmarshal(b, t.FeedDefs_ThreadViewPost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil } } // MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped // with its $type) per the atproto union wire format. go-dasl invokes this // when the union appears inside another record, so nested unions serialize // correctly. func (t FeedDefs_ThreadViewPost_Replies_Elem) MarshalCBOR() ([]byte, error) { if t.FeedDefs_BlockedPost != nil { cp := *t.FeedDefs_BlockedPost cp.LexiconTypeID = "app.bsky.feed.defs#blockedPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_NotFoundPost != nil { cp := *t.FeedDefs_NotFoundPost cp.LexiconTypeID = "app.bsky.feed.defs#notFoundPost" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_ThreadViewPost != nil { cp := *t.FeedDefs_ThreadViewPost cp.LexiconTypeID = "app.bsky.feed.defs#threadViewPost" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedDefs_ThreadViewPost_Replies_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedDefs_ThreadViewPost_Replies_Elem as CBOR") } func (t *FeedDefs_ThreadViewPost_Replies_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "app.bsky.feed.defs#blockedPost": t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_BlockedPost) case "app.bsky.feed.defs#notFoundPost": t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_NotFoundPost) case "app.bsky.feed.defs#threadViewPost": t.FeedDefs_ThreadViewPost = new(FeedDefs_ThreadViewPost) return glex.UnmarshalCBORBytes(b, t.FeedDefs_ThreadViewPost) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // FeedDefs_ThreadgateView is a "threadgateView" in the app.bsky.feed.defs schema. type FeedDefs_ThreadgateView struct { LexiconTypeID string `json:"$type,omitempty"` Cid *string `json:"cid,omitempty"` Lists []GraphDefs_ListViewBasic `json:"lists,omitempty"` Record *glex.LexiconTypeDecoder `json:"record,omitempty"` Uri *string `json:"uri,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ThreadgateView) RecordTypeID() string { return "app.bsky.feed.defs#threadgateView" } func (t *FeedDefs_ThreadgateView) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#threadgateView" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ThreadgateView) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // FeedDefs_ViewerState is a "viewerState" in the app.bsky.feed.defs schema. // // Metadata about the requesting account's relationship with the subject content. Only has meaningful content for authed requests. type FeedDefs_ViewerState struct { LexiconTypeID string `json:"$type,omitempty"` Bookmarked *bool `json:"bookmarked,omitempty"` EmbeddingDisabled *bool `json:"embeddingDisabled,omitempty"` Like *string `json:"like,omitempty"` Pinned *bool `json:"pinned,omitempty"` ReplyDisabled *bool `json:"replyDisabled,omitempty"` Repost *string `json:"repost,omitempty"` ThreadMuted *bool `json:"threadMuted,omitempty"` } // RecordTypeID implements glex.Record. func (t *FeedDefs_ViewerState) RecordTypeID() string { return "app.bsky.feed.defs#viewerState" } func (t *FeedDefs_ViewerState) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.defs#viewerState" return glex.MarshalCBOR(w, &cp) } func (t *FeedDefs_ViewerState) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }