Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
11 kB · 334 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.embed.recordWithMedia
package appbsky
import ( "encoding/json" "fmt" "io"
glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen")
func init() { glex.RegisterType("app.bsky.embed.recordWithMedia#main", &EmbedRecordWithMedia{})}
type EmbedRecordWithMedia struct { LexiconTypeID string `json:"$type,omitempty"` Media EmbedRecordWithMedia_Media `json:"media"` Record EmbedRecord `json:"record"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecordWithMedia) RecordTypeID() string { return "app.bsky.embed.recordWithMedia" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// EmbedRecordWithMedia and *EmbedRecordWithMedia marshal with $type.func (t EmbedRecordWithMedia) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.embed.recordWithMedia" type alias EmbedRecordWithMedia return json.Marshal((alias)(t))}
func (t *EmbedRecordWithMedia) 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.recordWithMedia" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecordWithMedia) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type EmbedRecordWithMedia_Media struct { EmbedExternal *EmbedExternal EmbedGallery *EmbedGallery EmbedImages *EmbedImages EmbedVideo *EmbedVideo // 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 EmbedRecordWithMedia_Media and *EmbedRecordWithMedia_Media marshal correctly.func (t EmbedRecordWithMedia_Media) MarshalJSON() ([]byte, error) { if t.EmbedExternal != nil { cp := *t.EmbedExternal cp.LexiconTypeID = "app.bsky.embed.external" return json.Marshal(&cp) } if t.EmbedGallery != nil { cp := *t.EmbedGallery cp.LexiconTypeID = "app.bsky.embed.gallery" return json.Marshal(&cp) } if t.EmbedImages != nil { cp := *t.EmbedImages cp.LexiconTypeID = "app.bsky.embed.images" return json.Marshal(&cp) } if t.EmbedVideo != nil { cp := *t.EmbedVideo cp.LexiconTypeID = "app.bsky.embed.video" 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 EmbedRecordWithMedia_Media", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecordWithMedia_Media as JSON")}
func (t *EmbedRecordWithMedia_Media) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.external": t.EmbedExternal = new(EmbedExternal) return json.Unmarshal(b, t.EmbedExternal) case "app.bsky.embed.gallery": t.EmbedGallery = new(EmbedGallery) return json.Unmarshal(b, t.EmbedGallery) case "app.bsky.embed.images": t.EmbedImages = new(EmbedImages) return json.Unmarshal(b, t.EmbedImages) case "app.bsky.embed.video": t.EmbedVideo = new(EmbedVideo) return json.Unmarshal(b, t.EmbedVideo) 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 EmbedRecordWithMedia_Media) MarshalCBOR() ([]byte, error) { if t.EmbedExternal != nil { cp := *t.EmbedExternal cp.LexiconTypeID = "app.bsky.embed.external" return glex.MarshalCBORBytes(&cp) } if t.EmbedGallery != nil { cp := *t.EmbedGallery cp.LexiconTypeID = "app.bsky.embed.gallery" return glex.MarshalCBORBytes(&cp) } if t.EmbedImages != nil { cp := *t.EmbedImages cp.LexiconTypeID = "app.bsky.embed.images" return glex.MarshalCBORBytes(&cp) } if t.EmbedVideo != nil { cp := *t.EmbedVideo cp.LexiconTypeID = "app.bsky.embed.video" 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 EmbedRecordWithMedia_Media", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecordWithMedia_Media as CBOR")}
func (t *EmbedRecordWithMedia_Media) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.external": t.EmbedExternal = new(EmbedExternal) return glex.UnmarshalCBORBytes(b, t.EmbedExternal) case "app.bsky.embed.gallery": t.EmbedGallery = new(EmbedGallery) return glex.UnmarshalCBORBytes(b, t.EmbedGallery) case "app.bsky.embed.images": t.EmbedImages = new(EmbedImages) return glex.UnmarshalCBORBytes(b, t.EmbedImages) case "app.bsky.embed.video": t.EmbedVideo = new(EmbedVideo) return glex.UnmarshalCBORBytes(b, t.EmbedVideo) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// EmbedRecordWithMedia_View is a "view" in the app.bsky.embed.recordWithMedia schema.type EmbedRecordWithMedia_View struct { LexiconTypeID string `json:"$type,omitempty"` Media EmbedRecordWithMedia_View_Media `json:"media"` Record EmbedRecord_View `json:"record"`}
// RecordTypeID implements glex.Record.func (t *EmbedRecordWithMedia_View) RecordTypeID() string { return "app.bsky.embed.recordWithMedia#view"}
func (t *EmbedRecordWithMedia_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.recordWithMedia#view" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedRecordWithMedia_View) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type EmbedRecordWithMedia_View_Media struct { EmbedExternal_View *EmbedExternal_View EmbedGallery_View *EmbedGallery_View EmbedImages_View *EmbedImages_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 EmbedRecordWithMedia_View_Media and *EmbedRecordWithMedia_View_Media marshal correctly.func (t EmbedRecordWithMedia_View_Media) 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.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 EmbedRecordWithMedia_View_Media", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecordWithMedia_View_Media as JSON")}
func (t *EmbedRecordWithMedia_View_Media) 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.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 EmbedRecordWithMedia_View_Media) 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.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 EmbedRecordWithMedia_View_Media", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedRecordWithMedia_View_Media as CBOR")}
func (t *EmbedRecordWithMedia_View_Media) 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.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 }}