Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
9.8 kB · 287 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.embed.gallery
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.gallery#main", &EmbedGallery{})}
type EmbedGallery struct { LexiconTypeID string `json:"$type,omitempty"` // items: The schema-level maxLength of 20 is a future-proof ceiling. Clients should currently enforce a soft limit of 10 items in authoring UIs. Items []EmbedGallery_Items_Elem `json:"items"`}
// RecordTypeID implements glex.Record.func (t *EmbedGallery) RecordTypeID() string { return "app.bsky.embed.gallery" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// EmbedGallery and *EmbedGallery marshal with $type.func (t EmbedGallery) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.embed.gallery" type alias EmbedGallery return json.Marshal((alias)(t))}
func (t *EmbedGallery) 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.gallery" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedGallery) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// The media items in the gallery. Each item may be of a different type, but all types must be supported by the client.type EmbedGallery_Items_Elem struct { EmbedGallery_Image *EmbedGallery_Image // 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 EmbedGallery_Items_Elem and *EmbedGallery_Items_Elem marshal correctly.func (t EmbedGallery_Items_Elem) MarshalJSON() ([]byte, error) { if t.EmbedGallery_Image != nil { cp := *t.EmbedGallery_Image cp.LexiconTypeID = "app.bsky.embed.gallery#image" 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 EmbedGallery_Items_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedGallery_Items_Elem as JSON")}
func (t *EmbedGallery_Items_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.gallery#image": t.EmbedGallery_Image = new(EmbedGallery_Image) return json.Unmarshal(b, t.EmbedGallery_Image) 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 EmbedGallery_Items_Elem) MarshalCBOR() ([]byte, error) { if t.EmbedGallery_Image != nil { cp := *t.EmbedGallery_Image cp.LexiconTypeID = "app.bsky.embed.gallery#image" 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 EmbedGallery_Items_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedGallery_Items_Elem as CBOR")}
func (t *EmbedGallery_Items_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.gallery#image": t.EmbedGallery_Image = new(EmbedGallery_Image) return glex.UnmarshalCBORBytes(b, t.EmbedGallery_Image) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// EmbedGallery_Image is a "image" in the app.bsky.embed.gallery schema.type EmbedGallery_Image struct { LexiconTypeID string `json:"$type,omitempty"` // alt: Alt text description of the image, for accessibility. Alt string `json:"alt"` AspectRatio EmbedDefs_AspectRatio `json:"aspectRatio"` Image glex.Blob `json:"image"`}
// RecordTypeID implements glex.Record.func (t *EmbedGallery_Image) RecordTypeID() string { return "app.bsky.embed.gallery#image" }
func (t *EmbedGallery_Image) 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.gallery#image" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedGallery_Image) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// EmbedGallery_View is a "view" in the app.bsky.embed.gallery schema.type EmbedGallery_View struct { LexiconTypeID string `json:"$type,omitempty"` Items []EmbedGallery_View_Items_Elem `json:"items"`}
// RecordTypeID implements glex.Record.func (t *EmbedGallery_View) RecordTypeID() string { return "app.bsky.embed.gallery#view" }
func (t *EmbedGallery_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.gallery#view" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedGallery_View) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type EmbedGallery_View_Items_Elem struct { EmbedGallery_ViewImage *EmbedGallery_ViewImage // 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 EmbedGallery_View_Items_Elem and *EmbedGallery_View_Items_Elem marshal correctly.func (t EmbedGallery_View_Items_Elem) MarshalJSON() ([]byte, error) { if t.EmbedGallery_ViewImage != nil { cp := *t.EmbedGallery_ViewImage cp.LexiconTypeID = "app.bsky.embed.gallery#viewImage" 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 EmbedGallery_View_Items_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedGallery_View_Items_Elem as JSON")}
func (t *EmbedGallery_View_Items_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.gallery#viewImage": t.EmbedGallery_ViewImage = new(EmbedGallery_ViewImage) return json.Unmarshal(b, t.EmbedGallery_ViewImage) 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 EmbedGallery_View_Items_Elem) MarshalCBOR() ([]byte, error) { if t.EmbedGallery_ViewImage != nil { cp := *t.EmbedGallery_ViewImage cp.LexiconTypeID = "app.bsky.embed.gallery#viewImage" 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 EmbedGallery_View_Items_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union EmbedGallery_View_Items_Elem as CBOR")}
func (t *EmbedGallery_View_Items_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.embed.gallery#viewImage": t.EmbedGallery_ViewImage = new(EmbedGallery_ViewImage) return glex.UnmarshalCBORBytes(b, t.EmbedGallery_ViewImage) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// EmbedGallery_ViewImage is a "viewImage" in the app.bsky.embed.gallery schema.type EmbedGallery_ViewImage struct { LexiconTypeID string `json:"$type,omitempty"` // alt: Alt text description of the image, for accessibility. Alt string `json:"alt"` AspectRatio EmbedDefs_AspectRatio `json:"aspectRatio"` // fullsize: Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View. Fullsize string `json:"fullsize"` // thumbnail: Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View. Thumbnail string `json:"thumbnail"`}
// RecordTypeID implements glex.Record.func (t *EmbedGallery_ViewImage) RecordTypeID() string { return "app.bsky.embed.gallery#viewImage" }
func (t *EmbedGallery_ViewImage) 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.gallery#viewImage" return glex.MarshalCBOR(w, &cp)}
func (t *EmbedGallery_ViewImage) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}