Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
5.0 kB · 144 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.actor.profile
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.actor.profile", &ActorProfile{})}
// A declaration of a Bluesky account profile.type ActorProfile struct { LexiconTypeID string `json:"$type,omitempty"` // avatar: Small image to be displayed next to posts from account. AKA, 'profile picture' Avatar *glex.Blob `json:"avatar,omitempty"` // banner: Larger horizontal image to display behind profile view. Banner *glex.Blob `json:"banner,omitempty"` CreatedAt *string `json:"createdAt,omitempty"` // description: Free-form profile description text. Description *string `json:"description,omitempty"` DisplayName *string `json:"displayName,omitempty"` JoinedViaStarterPack *comatproto.RepoStrongRef `json:"joinedViaStarterPack,omitempty"` // labels: Self-label values, specific to the Bluesky application, on the overall account. Labels *ActorProfile_Labels `json:"labels,omitempty"` PinnedPost *comatproto.RepoStrongRef `json:"pinnedPost,omitempty"` // pronouns: Free-form pronouns text. Pronouns *string `json:"pronouns,omitempty"` Website *string `json:"website,omitempty"`}
// RecordTypeID implements glex.Record.func (t *ActorProfile) RecordTypeID() string { return "app.bsky.actor.profile" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// ActorProfile and *ActorProfile marshal with $type.func (t ActorProfile) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.actor.profile" type alias ActorProfile return json.Marshal((alias)(t))}
func (t *ActorProfile) 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.actor.profile" return glex.MarshalCBOR(w, &cp)}
func (t *ActorProfile) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// Self-label values, specific to the Bluesky application, on the overall account.type ActorProfile_Labels struct { LabelDefs_SelfLabels *comatproto.LabelDefs_SelfLabels // 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 ActorProfile_Labels and *ActorProfile_Labels marshal correctly.func (t ActorProfile_Labels) MarshalJSON() ([]byte, error) { if t.LabelDefs_SelfLabels != nil { cp := *t.LabelDefs_SelfLabels cp.LexiconTypeID = "com.atproto.label.defs#selfLabels" 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 ActorProfile_Labels", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union ActorProfile_Labels as JSON")}
func (t *ActorProfile_Labels) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "com.atproto.label.defs#selfLabels": t.LabelDefs_SelfLabels = new(comatproto.LabelDefs_SelfLabels) return json.Unmarshal(b, t.LabelDefs_SelfLabels) 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 ActorProfile_Labels) MarshalCBOR() ([]byte, error) { if t.LabelDefs_SelfLabels != nil { cp := *t.LabelDefs_SelfLabels cp.LexiconTypeID = "com.atproto.label.defs#selfLabels" 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 ActorProfile_Labels", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union ActorProfile_Labels as CBOR")}
func (t *ActorProfile_Labels) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "com.atproto.label.defs#selfLabels": t.LabelDefs_SelfLabels = new(comatproto.LabelDefs_SelfLabels) return glex.UnmarshalCBORBytes(b, t.LabelDefs_SelfLabels) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}