Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
9.1 kB · 268 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.richtext.facet
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.richtext.facet#main", &RichtextFacet{})}
// Annotation of a sub-string within rich text.type RichtextFacet struct { LexiconTypeID string `json:"$type,omitempty"` Features []RichtextFacet_Features_Elem `json:"features"` Index RichtextFacet_ByteSlice `json:"index"`}
// RecordTypeID implements glex.Record.func (t *RichtextFacet) RecordTypeID() string { return "app.bsky.richtext.facet" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// RichtextFacet and *RichtextFacet marshal with $type.func (t RichtextFacet) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.richtext.facet" type alias RichtextFacet return json.Marshal((alias)(t))}
func (t *RichtextFacet) 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.richtext.facet" return glex.MarshalCBOR(w, &cp)}
func (t *RichtextFacet) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type RichtextFacet_Features_Elem struct { RichtextFacet_Link *RichtextFacet_Link RichtextFacet_Mention *RichtextFacet_Mention RichtextFacet_Tag *RichtextFacet_Tag // 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 RichtextFacet_Features_Elem and *RichtextFacet_Features_Elem marshal correctly.func (t RichtextFacet_Features_Elem) MarshalJSON() ([]byte, error) { if t.RichtextFacet_Link != nil { cp := *t.RichtextFacet_Link cp.LexiconTypeID = "app.bsky.richtext.facet#link" return json.Marshal(&cp) } if t.RichtextFacet_Mention != nil { cp := *t.RichtextFacet_Mention cp.LexiconTypeID = "app.bsky.richtext.facet#mention" return json.Marshal(&cp) } if t.RichtextFacet_Tag != nil { cp := *t.RichtextFacet_Tag cp.LexiconTypeID = "app.bsky.richtext.facet#tag" 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 RichtextFacet_Features_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union RichtextFacet_Features_Elem as JSON")}
func (t *RichtextFacet_Features_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.richtext.facet#link": t.RichtextFacet_Link = new(RichtextFacet_Link) return json.Unmarshal(b, t.RichtextFacet_Link) case "app.bsky.richtext.facet#mention": t.RichtextFacet_Mention = new(RichtextFacet_Mention) return json.Unmarshal(b, t.RichtextFacet_Mention) case "app.bsky.richtext.facet#tag": t.RichtextFacet_Tag = new(RichtextFacet_Tag) return json.Unmarshal(b, t.RichtextFacet_Tag) 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 RichtextFacet_Features_Elem) MarshalCBOR() ([]byte, error) { if t.RichtextFacet_Link != nil { cp := *t.RichtextFacet_Link cp.LexiconTypeID = "app.bsky.richtext.facet#link" return glex.MarshalCBORBytes(&cp) } if t.RichtextFacet_Mention != nil { cp := *t.RichtextFacet_Mention cp.LexiconTypeID = "app.bsky.richtext.facet#mention" return glex.MarshalCBORBytes(&cp) } if t.RichtextFacet_Tag != nil { cp := *t.RichtextFacet_Tag cp.LexiconTypeID = "app.bsky.richtext.facet#tag" 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 RichtextFacet_Features_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union RichtextFacet_Features_Elem as CBOR")}
func (t *RichtextFacet_Features_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.richtext.facet#link": t.RichtextFacet_Link = new(RichtextFacet_Link) return glex.UnmarshalCBORBytes(b, t.RichtextFacet_Link) case "app.bsky.richtext.facet#mention": t.RichtextFacet_Mention = new(RichtextFacet_Mention) return glex.UnmarshalCBORBytes(b, t.RichtextFacet_Mention) case "app.bsky.richtext.facet#tag": t.RichtextFacet_Tag = new(RichtextFacet_Tag) return glex.UnmarshalCBORBytes(b, t.RichtextFacet_Tag) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// RichtextFacet_ByteSlice is a "byteSlice" in the app.bsky.richtext.facet schema.//// Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.type RichtextFacet_ByteSlice struct { LexiconTypeID string `json:"$type,omitempty"` ByteEnd int64 `json:"byteEnd"` ByteStart int64 `json:"byteStart"`}
// RecordTypeID implements glex.Record.func (t *RichtextFacet_ByteSlice) RecordTypeID() string { return "app.bsky.richtext.facet#byteSlice" }
func (t *RichtextFacet_ByteSlice) 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.richtext.facet#byteSlice" return glex.MarshalCBOR(w, &cp)}
func (t *RichtextFacet_ByteSlice) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// RichtextFacet_Link is a "link" in the app.bsky.richtext.facet schema.//// Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.type RichtextFacet_Link struct { LexiconTypeID string `json:"$type,omitempty"` Uri string `json:"uri"`}
// RecordTypeID implements glex.Record.func (t *RichtextFacet_Link) RecordTypeID() string { return "app.bsky.richtext.facet#link" }
func (t *RichtextFacet_Link) 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.richtext.facet#link" return glex.MarshalCBOR(w, &cp)}
func (t *RichtextFacet_Link) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// RichtextFacet_Mention is a "mention" in the app.bsky.richtext.facet schema.//// Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.type RichtextFacet_Mention struct { LexiconTypeID string `json:"$type,omitempty"` Did string `json:"did"`}
// RecordTypeID implements glex.Record.func (t *RichtextFacet_Mention) RecordTypeID() string { return "app.bsky.richtext.facet#mention" }
func (t *RichtextFacet_Mention) 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.richtext.facet#mention" return glex.MarshalCBOR(w, &cp)}
func (t *RichtextFacet_Mention) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// RichtextFacet_Tag is a "tag" in the app.bsky.richtext.facet schema.//// Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').type RichtextFacet_Tag struct { LexiconTypeID string `json:"$type,omitempty"` Tag string `json:"tag"`}
// RecordTypeID implements glex.Record.func (t *RichtextFacet_Tag) RecordTypeID() string { return "app.bsky.richtext.facet#tag" }
func (t *RichtextFacet_Tag) 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.richtext.facet#tag" return glex.MarshalCBOR(w, &cp)}
func (t *RichtextFacet_Tag) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}