// Code generated by glex; DO NOT EDIT. // Lexicon schema: place.stream.livestream package placestream import ( "encoding/json" "fmt" "io" glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" appbsky "stream.place/streamplace/pkg/appbsky" comatproto "stream.place/streamplace/pkg/comatproto" ) func init() { glex.RegisterType("place.stream.livestream", &Livestream{}) } // Record announcing a livestream is happening type Livestream struct { LexiconTypeID string `json:"$type,omitempty"` // activity: The game or activity being streamed. Activity *Livestream_Activity `json:"activity,omitempty"` // agent: The source of the livestream, if available, in a User Agent format: ` / ` e.g. Streamplace/0.7.5 iOS Agent *string `json:"agent,omitempty"` // canonicalUrl: The primary URL where this livestream can be viewed, if available. CanonicalUrl *string `json:"canonicalUrl,omitempty"` // createdAt: Client-declared timestamp when this livestream started. CreatedAt string `json:"createdAt"` // endedAt: Client-declared timestamp when this livestream ended. Ended livestreams are not supposed to start up again. EndedAt *string `json:"endedAt,omitempty"` // idleTimeoutSeconds: Time in seconds after which this livestream should be automatically ended if idle. Zero means no timeout. IdleTimeoutSeconds *int64 `json:"idleTimeoutSeconds,omitempty"` // lastSeenAt: Client-declared timestamp when this livestream was last seen by the Streamplace station. LastSeenAt *string `json:"lastSeenAt,omitempty"` NotificationSettings *Livestream_NotificationSettings `json:"notificationSettings,omitempty"` // post: The post that announced this livestream. Post *comatproto.RepoStrongRef `json:"post,omitempty"` // tags: Freeform tags for this stream. Each tag must be alphanumeric (a-z, A-Z, 0-9) plus colon. Tags with colons indicate a specific tag group (e.g. 'lang:en' indicates the stream's primary language). Tags []string `json:"tags,omitempty"` Thumb *glex.Blob `json:"thumb,omitempty"` // title: The title of the livestream, as it will be announced to followers. Title string `json:"title"` // url: The URL where this stream can be found. This is primarily a hint for other Streamplace nodes to locate and replicate the stream. Url *string `json:"url,omitempty"` } // RecordTypeID implements glex.Record. func (t *Livestream) RecordTypeID() string { return "place.stream.livestream" } // MarshalJSON stamps the $type field, like MarshalCBOR does. The value // receiver operates on a copy, so the record is never mutated and both // Livestream and *Livestream marshal with $type. func (t Livestream) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.livestream" type alias Livestream return json.Marshal((alias)(t)) } func (t *Livestream) 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.livestream" return glex.MarshalCBOR(w, &cp) } func (t *Livestream) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // The game or activity being streamed. type Livestream_Activity struct { Defs_ActivityGame *Defs_ActivityGame Defs_ActivityLabel *Defs_ActivityLabel // 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 Livestream_Activity and *Livestream_Activity marshal correctly. func (t Livestream_Activity) MarshalJSON() ([]byte, error) { if t.Defs_ActivityGame != nil { cp := *t.Defs_ActivityGame cp.LexiconTypeID = "place.stream.defs#activityGame" return json.Marshal(&cp) } if t.Defs_ActivityLabel != nil { cp := *t.Defs_ActivityLabel cp.LexiconTypeID = "place.stream.defs#activityLabel" 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 Livestream_Activity", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Livestream_Activity as JSON") } func (t *Livestream_Activity) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "place.stream.defs#activityGame": t.Defs_ActivityGame = new(Defs_ActivityGame) return json.Unmarshal(b, t.Defs_ActivityGame) case "place.stream.defs#activityLabel": t.Defs_ActivityLabel = new(Defs_ActivityLabel) return json.Unmarshal(b, t.Defs_ActivityLabel) 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 Livestream_Activity) MarshalCBOR() ([]byte, error) { if t.Defs_ActivityGame != nil { cp := *t.Defs_ActivityGame cp.LexiconTypeID = "place.stream.defs#activityGame" return glex.MarshalCBORBytes(&cp) } if t.Defs_ActivityLabel != nil { cp := *t.Defs_ActivityLabel cp.LexiconTypeID = "place.stream.defs#activityLabel" 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 Livestream_Activity", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Livestream_Activity as CBOR") } func (t *Livestream_Activity) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "place.stream.defs#activityGame": t.Defs_ActivityGame = new(Defs_ActivityGame) return glex.UnmarshalCBORBytes(b, t.Defs_ActivityGame) case "place.stream.defs#activityLabel": t.Defs_ActivityLabel = new(Defs_ActivityLabel) return glex.UnmarshalCBORBytes(b, t.Defs_ActivityLabel) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // Livestream_LivestreamView is a "livestreamView" in the place.stream.livestream schema. type Livestream_LivestreamView struct { LexiconTypeID string `json:"$type,omitempty"` Author appbsky.ActorDefs_ProfileViewBasic `json:"author"` Cid string `json:"cid"` IndexedAt string `json:"indexedAt"` Record *glex.LexiconTypeDecoder `json:"record"` Uri string `json:"uri"` // viewerCount: The number of viewers watching this livestream. Use when you can't reasonably use #viewerCount directly. ViewerCount *Livestream_ViewerCount `json:"viewerCount,omitempty"` } // RecordTypeID implements glex.Record. func (t *Livestream_LivestreamView) RecordTypeID() string { return "place.stream.livestream#livestreamView" } func (t *Livestream_LivestreamView) 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.livestream#livestreamView" return glex.MarshalCBOR(w, &cp) } func (t *Livestream_LivestreamView) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Livestream_NotificationSettings is a "notificationSettings" in the place.stream.livestream schema. type Livestream_NotificationSettings struct { LexiconTypeID string `json:"$type,omitempty"` // pushNotification: Whether this livestream should trigger a push notification to followers. PushNotification *bool `json:"pushNotification,omitempty"` } // RecordTypeID implements glex.Record. func (t *Livestream_NotificationSettings) RecordTypeID() string { return "place.stream.livestream#notificationSettings" } func (t *Livestream_NotificationSettings) 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.livestream#notificationSettings" return glex.MarshalCBOR(w, &cp) } func (t *Livestream_NotificationSettings) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Livestream_StreamplaceAnything is a "streamplaceAnything" in the place.stream.livestream schema. type Livestream_StreamplaceAnything struct { LexiconTypeID string `json:"$type,omitempty"` Livestream Livestream_StreamplaceAnything_Livestream `json:"livestream"` } // RecordTypeID implements glex.Record. func (t *Livestream_StreamplaceAnything) RecordTypeID() string { return "place.stream.livestream#streamplaceAnything" } func (t *Livestream_StreamplaceAnything) 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.livestream#streamplaceAnything" return glex.MarshalCBOR(w, &cp) } func (t *Livestream_StreamplaceAnything) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } type Livestream_StreamplaceAnything_Livestream struct { ChatDefs_MessageView *ChatDefs_MessageView ChatDefs_PinnedRecordView *ChatDefs_PinnedRecordView Defs_BlockView *Defs_BlockView Defs_Rendition *Defs_Rendition Defs_Renditions *Defs_Renditions Livestream_LivestreamView *Livestream_LivestreamView Livestream_TeleportArrival *Livestream_TeleportArrival Livestream_TeleportCanceled *Livestream_TeleportCanceled Livestream_ViewerCount *Livestream_ViewerCount // 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 Livestream_StreamplaceAnything_Livestream and *Livestream_StreamplaceAnything_Livestream marshal correctly. func (t Livestream_StreamplaceAnything_Livestream) MarshalJSON() ([]byte, error) { if t.ChatDefs_MessageView != nil { cp := *t.ChatDefs_MessageView cp.LexiconTypeID = "place.stream.chat.defs#messageView" return json.Marshal(&cp) } if t.ChatDefs_PinnedRecordView != nil { cp := *t.ChatDefs_PinnedRecordView cp.LexiconTypeID = "place.stream.chat.defs#pinnedRecordView" return json.Marshal(&cp) } if t.Defs_BlockView != nil { cp := *t.Defs_BlockView cp.LexiconTypeID = "place.stream.defs#blockView" return json.Marshal(&cp) } if t.Defs_Rendition != nil { cp := *t.Defs_Rendition cp.LexiconTypeID = "place.stream.defs#rendition" return json.Marshal(&cp) } if t.Defs_Renditions != nil { cp := *t.Defs_Renditions cp.LexiconTypeID = "place.stream.defs#renditions" return json.Marshal(&cp) } if t.Livestream_LivestreamView != nil { cp := *t.Livestream_LivestreamView cp.LexiconTypeID = "place.stream.livestream#livestreamView" return json.Marshal(&cp) } if t.Livestream_TeleportArrival != nil { cp := *t.Livestream_TeleportArrival cp.LexiconTypeID = "place.stream.livestream#teleportArrival" return json.Marshal(&cp) } if t.Livestream_TeleportCanceled != nil { cp := *t.Livestream_TeleportCanceled cp.LexiconTypeID = "place.stream.livestream#teleportCanceled" return json.Marshal(&cp) } if t.Livestream_ViewerCount != nil { cp := *t.Livestream_ViewerCount cp.LexiconTypeID = "place.stream.livestream#viewerCount" 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 Livestream_StreamplaceAnything_Livestream", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Livestream_StreamplaceAnything_Livestream as JSON") } func (t *Livestream_StreamplaceAnything_Livestream) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "place.stream.chat.defs#messageView": t.ChatDefs_MessageView = new(ChatDefs_MessageView) return json.Unmarshal(b, t.ChatDefs_MessageView) case "place.stream.chat.defs#pinnedRecordView": t.ChatDefs_PinnedRecordView = new(ChatDefs_PinnedRecordView) return json.Unmarshal(b, t.ChatDefs_PinnedRecordView) case "place.stream.defs#blockView": t.Defs_BlockView = new(Defs_BlockView) return json.Unmarshal(b, t.Defs_BlockView) case "place.stream.defs#rendition": t.Defs_Rendition = new(Defs_Rendition) return json.Unmarshal(b, t.Defs_Rendition) case "place.stream.defs#renditions": t.Defs_Renditions = new(Defs_Renditions) return json.Unmarshal(b, t.Defs_Renditions) case "place.stream.livestream#livestreamView": t.Livestream_LivestreamView = new(Livestream_LivestreamView) return json.Unmarshal(b, t.Livestream_LivestreamView) case "place.stream.livestream#teleportArrival": t.Livestream_TeleportArrival = new(Livestream_TeleportArrival) return json.Unmarshal(b, t.Livestream_TeleportArrival) case "place.stream.livestream#teleportCanceled": t.Livestream_TeleportCanceled = new(Livestream_TeleportCanceled) return json.Unmarshal(b, t.Livestream_TeleportCanceled) case "place.stream.livestream#viewerCount": t.Livestream_ViewerCount = new(Livestream_ViewerCount) return json.Unmarshal(b, t.Livestream_ViewerCount) 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 Livestream_StreamplaceAnything_Livestream) MarshalCBOR() ([]byte, error) { if t.ChatDefs_MessageView != nil { cp := *t.ChatDefs_MessageView cp.LexiconTypeID = "place.stream.chat.defs#messageView" return glex.MarshalCBORBytes(&cp) } if t.ChatDefs_PinnedRecordView != nil { cp := *t.ChatDefs_PinnedRecordView cp.LexiconTypeID = "place.stream.chat.defs#pinnedRecordView" return glex.MarshalCBORBytes(&cp) } if t.Defs_BlockView != nil { cp := *t.Defs_BlockView cp.LexiconTypeID = "place.stream.defs#blockView" return glex.MarshalCBORBytes(&cp) } if t.Defs_Rendition != nil { cp := *t.Defs_Rendition cp.LexiconTypeID = "place.stream.defs#rendition" return glex.MarshalCBORBytes(&cp) } if t.Defs_Renditions != nil { cp := *t.Defs_Renditions cp.LexiconTypeID = "place.stream.defs#renditions" return glex.MarshalCBORBytes(&cp) } if t.Livestream_LivestreamView != nil { cp := *t.Livestream_LivestreamView cp.LexiconTypeID = "place.stream.livestream#livestreamView" return glex.MarshalCBORBytes(&cp) } if t.Livestream_TeleportArrival != nil { cp := *t.Livestream_TeleportArrival cp.LexiconTypeID = "place.stream.livestream#teleportArrival" return glex.MarshalCBORBytes(&cp) } if t.Livestream_TeleportCanceled != nil { cp := *t.Livestream_TeleportCanceled cp.LexiconTypeID = "place.stream.livestream#teleportCanceled" return glex.MarshalCBORBytes(&cp) } if t.Livestream_ViewerCount != nil { cp := *t.Livestream_ViewerCount cp.LexiconTypeID = "place.stream.livestream#viewerCount" 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 Livestream_StreamplaceAnything_Livestream", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Livestream_StreamplaceAnything_Livestream as CBOR") } func (t *Livestream_StreamplaceAnything_Livestream) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "place.stream.chat.defs#messageView": t.ChatDefs_MessageView = new(ChatDefs_MessageView) return glex.UnmarshalCBORBytes(b, t.ChatDefs_MessageView) case "place.stream.chat.defs#pinnedRecordView": t.ChatDefs_PinnedRecordView = new(ChatDefs_PinnedRecordView) return glex.UnmarshalCBORBytes(b, t.ChatDefs_PinnedRecordView) case "place.stream.defs#blockView": t.Defs_BlockView = new(Defs_BlockView) return glex.UnmarshalCBORBytes(b, t.Defs_BlockView) case "place.stream.defs#rendition": t.Defs_Rendition = new(Defs_Rendition) return glex.UnmarshalCBORBytes(b, t.Defs_Rendition) case "place.stream.defs#renditions": t.Defs_Renditions = new(Defs_Renditions) return glex.UnmarshalCBORBytes(b, t.Defs_Renditions) case "place.stream.livestream#livestreamView": t.Livestream_LivestreamView = new(Livestream_LivestreamView) return glex.UnmarshalCBORBytes(b, t.Livestream_LivestreamView) case "place.stream.livestream#teleportArrival": t.Livestream_TeleportArrival = new(Livestream_TeleportArrival) return glex.UnmarshalCBORBytes(b, t.Livestream_TeleportArrival) case "place.stream.livestream#teleportCanceled": t.Livestream_TeleportCanceled = new(Livestream_TeleportCanceled) return glex.UnmarshalCBORBytes(b, t.Livestream_TeleportCanceled) case "place.stream.livestream#viewerCount": t.Livestream_ViewerCount = new(Livestream_ViewerCount) return glex.UnmarshalCBORBytes(b, t.Livestream_ViewerCount) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // Livestream_TeleportArrival is a "teleportArrival" in the place.stream.livestream schema. type Livestream_TeleportArrival struct { LexiconTypeID string `json:"$type,omitempty"` // chatProfile: The chat profile of the source streamer ChatProfile *ChatProfile `json:"chatProfile,omitempty"` // source: The streamer who is teleporting their viewers here Source appbsky.ActorDefs_ProfileViewBasic `json:"source"` // startsAt: When this teleport started StartsAt string `json:"startsAt"` // teleportUri: The URI of the teleport record TeleportUri string `json:"teleportUri"` // viewerCount: How many viewers are arriving from this teleport ViewerCount int64 `json:"viewerCount"` } // RecordTypeID implements glex.Record. func (t *Livestream_TeleportArrival) RecordTypeID() string { return "place.stream.livestream#teleportArrival" } func (t *Livestream_TeleportArrival) 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.livestream#teleportArrival" return glex.MarshalCBOR(w, &cp) } func (t *Livestream_TeleportArrival) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Livestream_TeleportCanceled is a "teleportCanceled" in the place.stream.livestream schema. type Livestream_TeleportCanceled struct { LexiconTypeID string `json:"$type,omitempty"` // reason: Why this teleport was canceled Reason string `json:"reason"` // teleportUri: The URI of the teleport record that was canceled TeleportUri string `json:"teleportUri"` } // RecordTypeID implements glex.Record. func (t *Livestream_TeleportCanceled) RecordTypeID() string { return "place.stream.livestream#teleportCanceled" } func (t *Livestream_TeleportCanceled) 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.livestream#teleportCanceled" return glex.MarshalCBOR(w, &cp) } func (t *Livestream_TeleportCanceled) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Livestream_ViewerCount is a "viewerCount" in the place.stream.livestream schema. type Livestream_ViewerCount struct { LexiconTypeID string `json:"$type,omitempty"` Count int64 `json:"count"` } // RecordTypeID implements glex.Record. func (t *Livestream_ViewerCount) RecordTypeID() string { return "place.stream.livestream#viewerCount" } func (t *Livestream_ViewerCount) 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.livestream#viewerCount" return glex.MarshalCBOR(w, &cp) } func (t *Livestream_ViewerCount) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }