Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
20 kB · 544 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.embed.record
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")
func init() { glex.RegisterType("app.bsky.embed.record#main", &EmbedRecord{})}
type EmbedRecord struct { LexiconTypeID string `json:"$type,omitempty"` Record comatproto.RepoStrongRef `json:"record"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecord) RecordTypeID() string { return "app.bsky.embed.record" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// EmbedRecord and *EmbedRecord marshal with $type.func (t EmbedRecord) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.embed.record" type alias EmbedRecord return json.Marshal((alias)(t))}
func (t *EmbedRecord) 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.embed.record" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecord) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// EmbedRecord_View is a "view" in the app.bsky.embed.record schema.type EmbedRecord_View struct { LexiconTypeID string `json:"$type,omitempty"` Record EmbedRecord_View_Record `json:"record"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecord_View) RecordTypeID() string { return "app.bsky.embed.record#view" }
func (t *EmbedRecord_View) 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.embed.record#view" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecord_View) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type EmbedRecord_View_Record struct { EmbedRecord_ViewBlocked *EmbedRecord_ViewBlocked EmbedRecord_ViewDetached *EmbedRecord_ViewDetached EmbedRecord_ViewNotFound *EmbedRecord_ViewNotFound EmbedRecord_ViewRecord *EmbedRecord_ViewRecord FeedDefs_GeneratorView *FeedDefs_GeneratorView GraphDefs_ListView *GraphDefs_ListView GraphDefs_StarterPackViewBasic *GraphDefs_StarterPackViewBasic LabelerDefs_LabelerView *LabelerDefs_LabelerView // 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 EmbedRecord_View_Record and *EmbedRecord_View_Record marshal correctly.func (t EmbedRecord_View_Record) MarshalJSON() ([]byte, error) { if t.EmbedRecord_ViewBlocked != nil { cp := *t.EmbedRecord_ViewBlocked cp.LexiconTypeID = "app.bsky.embed.record#viewBlocked" return json.Marshal(&cp) } if t.EmbedRecord_ViewDetached != nil { cp := *t.EmbedRecord_ViewDetached cp.LexiconTypeID = "app.bsky.embed.record#viewDetached" return json.Marshal(&cp) } if t.EmbedRecord_ViewNotFound != nil { cp := *t.EmbedRecord_ViewNotFound cp.LexiconTypeID = "app.bsky.embed.record#viewNotFound" return json.Marshal(&cp) } if t.EmbedRecord_ViewRecord != nil { cp := *t.EmbedRecord_ViewRecord cp.LexiconTypeID = "app.bsky.embed.record#viewRecord" return json.Marshal(&cp) } if t.FeedDefs_GeneratorView != nil { cp := *t.FeedDefs_GeneratorView cp.LexiconTypeID = "app.bsky.feed.defs#generatorView" return json.Marshal(&cp) } if t.GraphDefs_ListView != nil { cp := *t.GraphDefs_ListView cp.LexiconTypeID = "app.bsky.graph.defs#listView" return json.Marshal(&cp) } if t.GraphDefs_StarterPackViewBasic != nil { cp := *t.GraphDefs_StarterPackViewBasic cp.LexiconTypeID = "app.bsky.graph.defs#starterPackViewBasic" return json.Marshal(&cp) } if t.LabelerDefs_LabelerView != nil { cp := *t.LabelerDefs_LabelerView cp.LexiconTypeID = "app.bsky.labeler.defs#labelerView" 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 EmbedRecord_View_Record", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecord_View_Record as JSON")}
func (t *EmbedRecord_View_Record) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.record#viewBlocked": t.EmbedRecord_ViewBlocked = new(EmbedRecord_ViewBlocked) return json.Unmarshal(b, t.EmbedRecord_ViewBlocked) case "app.bsky.embed.record#viewDetached": t.EmbedRecord_ViewDetached = new(EmbedRecord_ViewDetached) return json.Unmarshal(b, t.EmbedRecord_ViewDetached) case "app.bsky.embed.record#viewNotFound": t.EmbedRecord_ViewNotFound = new(EmbedRecord_ViewNotFound) return json.Unmarshal(b, t.EmbedRecord_ViewNotFound) case "app.bsky.embed.record#viewRecord": t.EmbedRecord_ViewRecord = new(EmbedRecord_ViewRecord) return json.Unmarshal(b, t.EmbedRecord_ViewRecord) case "app.bsky.feed.defs#generatorView": t.FeedDefs_GeneratorView = new(FeedDefs_GeneratorView) return json.Unmarshal(b, t.FeedDefs_GeneratorView) case "app.bsky.graph.defs#listView": t.GraphDefs_ListView = new(GraphDefs_ListView) return json.Unmarshal(b, t.GraphDefs_ListView) case "app.bsky.graph.defs#starterPackViewBasic": t.GraphDefs_StarterPackViewBasic = new(GraphDefs_StarterPackViewBasic) return json.Unmarshal(b, t.GraphDefs_StarterPackViewBasic) case "app.bsky.labeler.defs#labelerView": t.LabelerDefs_LabelerView = new(LabelerDefs_LabelerView) return json.Unmarshal(b, t.LabelerDefs_LabelerView) 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 EmbedRecord_View_Record) MarshalCBOR() ([]byte, error) { if t.EmbedRecord_ViewBlocked != nil { cp := *t.EmbedRecord_ViewBlocked cp.LexiconTypeID = "app.bsky.embed.record#viewBlocked" return glex.MarshalCBORBytes(&cp) } if t.EmbedRecord_ViewDetached != nil { cp := *t.EmbedRecord_ViewDetached cp.LexiconTypeID = "app.bsky.embed.record#viewDetached" return glex.MarshalCBORBytes(&cp) } if t.EmbedRecord_ViewNotFound != nil { cp := *t.EmbedRecord_ViewNotFound cp.LexiconTypeID = "app.bsky.embed.record#viewNotFound" return glex.MarshalCBORBytes(&cp) } if t.EmbedRecord_ViewRecord != nil { cp := *t.EmbedRecord_ViewRecord cp.LexiconTypeID = "app.bsky.embed.record#viewRecord" return glex.MarshalCBORBytes(&cp) } if t.FeedDefs_GeneratorView != nil { cp := *t.FeedDefs_GeneratorView cp.LexiconTypeID = "app.bsky.feed.defs#generatorView" return glex.MarshalCBORBytes(&cp) } if t.GraphDefs_ListView != nil { cp := *t.GraphDefs_ListView cp.LexiconTypeID = "app.bsky.graph.defs#listView" return glex.MarshalCBORBytes(&cp) } if t.GraphDefs_StarterPackViewBasic != nil { cp := *t.GraphDefs_StarterPackViewBasic cp.LexiconTypeID = "app.bsky.graph.defs#starterPackViewBasic" return glex.MarshalCBORBytes(&cp) } if t.LabelerDefs_LabelerView != nil { cp := *t.LabelerDefs_LabelerView cp.LexiconTypeID = "app.bsky.labeler.defs#labelerView" 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 EmbedRecord_View_Record", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecord_View_Record as CBOR")}
func (t *EmbedRecord_View_Record) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.record#viewBlocked": t.EmbedRecord_ViewBlocked = new(EmbedRecord_ViewBlocked) return glex.UnmarshalCBORBytes(b, t.EmbedRecord_ViewBlocked) case "app.bsky.embed.record#viewDetached": t.EmbedRecord_ViewDetached = new(EmbedRecord_ViewDetached) return glex.UnmarshalCBORBytes(b, t.EmbedRecord_ViewDetached) case "app.bsky.embed.record#viewNotFound": t.EmbedRecord_ViewNotFound = new(EmbedRecord_ViewNotFound) return glex.UnmarshalCBORBytes(b, t.EmbedRecord_ViewNotFound) case "app.bsky.embed.record#viewRecord": t.EmbedRecord_ViewRecord = new(EmbedRecord_ViewRecord) return glex.UnmarshalCBORBytes(b, t.EmbedRecord_ViewRecord) case "app.bsky.feed.defs#generatorView": t.FeedDefs_GeneratorView = new(FeedDefs_GeneratorView) return glex.UnmarshalCBORBytes(b, t.FeedDefs_GeneratorView) case "app.bsky.graph.defs#listView": t.GraphDefs_ListView = new(GraphDefs_ListView) return glex.UnmarshalCBORBytes(b, t.GraphDefs_ListView) case "app.bsky.graph.defs#starterPackViewBasic": t.GraphDefs_StarterPackViewBasic = new(GraphDefs_StarterPackViewBasic) return glex.UnmarshalCBORBytes(b, t.GraphDefs_StarterPackViewBasic) case "app.bsky.labeler.defs#labelerView": t.LabelerDefs_LabelerView = new(LabelerDefs_LabelerView) return glex.UnmarshalCBORBytes(b, t.LabelerDefs_LabelerView) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// EmbedRecord_ViewBlocked is a "viewBlocked" in the app.bsky.embed.record schema.type EmbedRecord_ViewBlocked 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 *EmbedRecord_ViewBlocked) RecordTypeID() string { return "app.bsky.embed.record#viewBlocked" }
func (t *EmbedRecord_ViewBlocked) 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.embed.record#viewBlocked" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecord_ViewBlocked) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// EmbedRecord_ViewDetached is a "viewDetached" in the app.bsky.embed.record schema.type EmbedRecord_ViewDetached struct { LexiconTypeID string `json:"$type,omitempty"` Detached bool `json:"detached"` Uri string `json:"uri"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecord_ViewDetached) RecordTypeID() string { return "app.bsky.embed.record#viewDetached" }
func (t *EmbedRecord_ViewDetached) 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.embed.record#viewDetached" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecord_ViewDetached) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// EmbedRecord_ViewNotFound is a "viewNotFound" in the app.bsky.embed.record schema.type EmbedRecord_ViewNotFound struct { LexiconTypeID string `json:"$type,omitempty"` NotFound bool `json:"notFound"` Uri string `json:"uri"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecord_ViewNotFound) RecordTypeID() string { return "app.bsky.embed.record#viewNotFound" }
func (t *EmbedRecord_ViewNotFound) 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.embed.record#viewNotFound" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecord_ViewNotFound) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// EmbedRecord_ViewRecord is a "viewRecord" in the app.bsky.embed.record schema.type EmbedRecord_ViewRecord struct { LexiconTypeID string `json:"$type,omitempty"` Author ActorDefs_ProfileViewBasic `json:"author"` Cid string `json:"cid"` Embeds []EmbedRecord_ViewRecord_Embeds_Elem `json:"embeds,omitempty"` IndexedAt string `json:"indexedAt"` Labels []comatproto.LabelDefs_Label `json:"labels,omitempty"` LikeCount *int64 `json:"likeCount,omitempty"` QuoteCount *int64 `json:"quoteCount,omitempty"` ReplyCount *int64 `json:"replyCount,omitempty"` RepostCount *int64 `json:"repostCount,omitempty"` Uri string `json:"uri"` // value: The record data itself. Value *glex.LexiconTypeDecoder `json:"value"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecord_ViewRecord) RecordTypeID() string { return "app.bsky.embed.record#viewRecord" }
func (t *EmbedRecord_ViewRecord) 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.embed.record#viewRecord" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecord_ViewRecord) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type EmbedRecord_ViewRecord_Embeds_Elem 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 EmbedRecord_ViewRecord_Embeds_Elem and *EmbedRecord_ViewRecord_Embeds_Elem marshal correctly.func (t EmbedRecord_ViewRecord_Embeds_Elem) 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 EmbedRecord_ViewRecord_Embeds_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecord_ViewRecord_Embeds_Elem as JSON")}
func (t *EmbedRecord_ViewRecord_Embeds_Elem) 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 EmbedRecord_ViewRecord_Embeds_Elem) 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 EmbedRecord_ViewRecord_Embeds_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecord_ViewRecord_Embeds_Elem as CBOR")}
func (t *EmbedRecord_ViewRecord_Embeds_Elem) 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 }}