Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
8.1 kB · 207 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208// Code generated by glex; DO NOT EDIT.
// Lexicon schema: place.stream.game.search
package placestream
import ( "context" "encoding/json" "fmt" "io"
glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" gamesgamesgamesgamesgames "stream.place/streamplace/pkg/gamesgamesgamesgamesgames")
type GameSearch_Output struct { LexiconTypeID string `json:"$type,omitempty"` Cursor *string `json:"cursor,omitempty"` Results []GameSearch_Output_Results_Elem `json:"results"` TotalResults *int64 `json:"totalResults,omitempty"`}
// RecordTypeID implements glex.Record.func (t *GameSearch_Output) RecordTypeID() string { return "place.stream.game.search" }
func (t *GameSearch_Output) 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 = "place.stream.game.search" return glex.MarshalCBOR(w, &cp)}
func (t *GameSearch_Output) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type GameSearch_Output_Results_Elem struct { Defs_CollectionSummaryView *gamesgamesgamesgamesgames.Defs_CollectionSummaryView Defs_EngineSummaryView *gamesgamesgamesgamesgames.Defs_EngineSummaryView Defs_GameSummaryView *gamesgamesgamesgamesgames.Defs_GameSummaryView Defs_PlatformSummaryView *gamesgamesgamesgamesgames.Defs_PlatformSummaryView Defs_ProfileSummaryView *gamesgamesgamesgamesgames.Defs_ProfileSummaryView // 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 GameSearch_Output_Results_Elem and *GameSearch_Output_Results_Elem marshal correctly.func (t GameSearch_Output_Results_Elem) MarshalJSON() ([]byte, error) { if t.Defs_CollectionSummaryView != nil { cp := *t.Defs_CollectionSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#collectionSummaryView" return json.Marshal(&cp) } if t.Defs_EngineSummaryView != nil { cp := *t.Defs_EngineSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#engineSummaryView" return json.Marshal(&cp) } if t.Defs_GameSummaryView != nil { cp := *t.Defs_GameSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#gameSummaryView" return json.Marshal(&cp) } if t.Defs_PlatformSummaryView != nil { cp := *t.Defs_PlatformSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#platformSummaryView" return json.Marshal(&cp) } if t.Defs_ProfileSummaryView != nil { cp := *t.Defs_ProfileSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#profileSummaryView" 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 GameSearch_Output_Results_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union GameSearch_Output_Results_Elem as JSON")}
func (t *GameSearch_Output_Results_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "games.gamesgamesgamesgames.defs#collectionSummaryView": t.Defs_CollectionSummaryView = new(gamesgamesgamesgamesgames.Defs_CollectionSummaryView) return json.Unmarshal(b, t.Defs_CollectionSummaryView) case "games.gamesgamesgamesgames.defs#engineSummaryView": t.Defs_EngineSummaryView = new(gamesgamesgamesgamesgames.Defs_EngineSummaryView) return json.Unmarshal(b, t.Defs_EngineSummaryView) case "games.gamesgamesgamesgames.defs#gameSummaryView": t.Defs_GameSummaryView = new(gamesgamesgamesgamesgames.Defs_GameSummaryView) return json.Unmarshal(b, t.Defs_GameSummaryView) case "games.gamesgamesgamesgames.defs#platformSummaryView": t.Defs_PlatformSummaryView = new(gamesgamesgamesgamesgames.Defs_PlatformSummaryView) return json.Unmarshal(b, t.Defs_PlatformSummaryView) case "games.gamesgamesgamesgames.defs#profileSummaryView": t.Defs_ProfileSummaryView = new(gamesgamesgamesgamesgames.Defs_ProfileSummaryView) return json.Unmarshal(b, t.Defs_ProfileSummaryView) 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 GameSearch_Output_Results_Elem) MarshalCBOR() ([]byte, error) { if t.Defs_CollectionSummaryView != nil { cp := *t.Defs_CollectionSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#collectionSummaryView" return glex.MarshalCBORBytes(&cp) } if t.Defs_EngineSummaryView != nil { cp := *t.Defs_EngineSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#engineSummaryView" return glex.MarshalCBORBytes(&cp) } if t.Defs_GameSummaryView != nil { cp := *t.Defs_GameSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#gameSummaryView" return glex.MarshalCBORBytes(&cp) } if t.Defs_PlatformSummaryView != nil { cp := *t.Defs_PlatformSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#platformSummaryView" return glex.MarshalCBORBytes(&cp) } if t.Defs_ProfileSummaryView != nil { cp := *t.Defs_ProfileSummaryView cp.LexiconTypeID = "games.gamesgamesgamesgames.defs#profileSummaryView" 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 GameSearch_Output_Results_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union GameSearch_Output_Results_Elem as CBOR")}
func (t *GameSearch_Output_Results_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "games.gamesgamesgamesgames.defs#collectionSummaryView": t.Defs_CollectionSummaryView = new(gamesgamesgamesgamesgames.Defs_CollectionSummaryView) return glex.UnmarshalCBORBytes(b, t.Defs_CollectionSummaryView) case "games.gamesgamesgamesgames.defs#engineSummaryView": t.Defs_EngineSummaryView = new(gamesgamesgamesgamesgames.Defs_EngineSummaryView) return glex.UnmarshalCBORBytes(b, t.Defs_EngineSummaryView) case "games.gamesgamesgamesgames.defs#gameSummaryView": t.Defs_GameSummaryView = new(gamesgamesgamesgamesgames.Defs_GameSummaryView) return glex.UnmarshalCBORBytes(b, t.Defs_GameSummaryView) case "games.gamesgamesgamesgames.defs#platformSummaryView": t.Defs_PlatformSummaryView = new(gamesgamesgamesgamesgames.Defs_PlatformSummaryView) return glex.UnmarshalCBORBytes(b, t.Defs_PlatformSummaryView) case "games.gamesgamesgamesgames.defs#profileSummaryView": t.Defs_ProfileSummaryView = new(gamesgamesgamesgamesgames.Defs_ProfileSummaryView) return glex.UnmarshalCBORBytes(b, t.Defs_ProfileSummaryView) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// GameSearch calls the XRPC method "place.stream.game.search".//// Search for games and other entities via the games.gamesgamesgamesgames catalog. Proxied from the configured games API.func GameSearch(ctx context.Context, c glex.LexClient, cursor string, limit *int64, q string) (*GameSearch_Output, error) { var out GameSearch_Output
params := map[string]interface{}{} if cursor != "" { params["cursor"] = cursor } if limit != nil { params["limit"] = *limit } params["q"] = q
if err := c.LexDo(ctx, glex.Query, "", "place.stream.game.search", params, nil, &out); err != nil { return nil, err } return &out, nil}