// Code generated by glex; DO NOT EDIT. // Lexicon schema: place.stream.video package placestream 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("place.stream.video", &Video{}) } // Some audiovisual content. type Video struct { LexiconTypeID string `json:"$type,omitempty"` // activity: The game or activity in the video. Activity *Video_Activity `json:"activity,omitempty"` // connections: Free-form list of atproto records related in some way to this video Connections []Video_Connections_Elem `json:"connections,omitempty"` // contentRights: copyright and licensing information for this VOD ContentRights *MetadataContentRights `json:"contentRights,omitempty"` // contentWarnings: content warning data for this VOD ContentWarnings *MetadataContentWarnings `json:"contentWarnings,omitempty"` // createdAt: Timestamp when this video record was created. Populated server-side at publication time by place.stream.media.publishVideo. CreatedAt string `json:"createdAt"` // description: Description of this video Description *string `json:"description,omitempty"` // descriptionFacets: Annotations of text (mentions, URLs, etc) DescriptionFacets []RichtextVideoFacet `json:"descriptionFacets,omitempty"` // durationMs: Duration of the video in milliseconds DurationMs int64 `json:"durationMs"` // source: What is the source of this video? Source Video_Source `json:"source"` // 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: Thumbnail image for the video. Thumb *glex.Blob `json:"thumb,omitempty"` // title: Title of the video referenced by this record Title string `json:"title"` } // RecordTypeID implements glex.Record. func (t *Video) RecordTypeID() string { return "place.stream.video" } // MarshalJSON stamps the $type field, like MarshalCBOR does. The value // receiver operates on a copy, so the record is never mutated and both // Video and *Video marshal with $type. func (t Video) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.video" type alias Video return json.Marshal((alias)(t)) } func (t *Video) 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.video" return glex.MarshalCBOR(w, &cp) } func (t *Video) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // The game or activity in the video. type Video_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 Video_Activity and *Video_Activity marshal correctly. func (t Video_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 Video_Activity", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Video_Activity as JSON") } func (t *Video_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 Video_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 Video_Activity", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Video_Activity as CBOR") } func (t *Video_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 } } type Video_Connections_Elem struct { Video_Connection *Video_Connection // 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 Video_Connections_Elem and *Video_Connections_Elem marshal correctly. func (t Video_Connections_Elem) MarshalJSON() ([]byte, error) { if t.Video_Connection != nil { cp := *t.Video_Connection cp.LexiconTypeID = "place.stream.video#connection" 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 Video_Connections_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Video_Connections_Elem as JSON") } func (t *Video_Connections_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "place.stream.video#connection": t.Video_Connection = new(Video_Connection) return json.Unmarshal(b, t.Video_Connection) 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 Video_Connections_Elem) MarshalCBOR() ([]byte, error) { if t.Video_Connection != nil { cp := *t.Video_Connection cp.LexiconTypeID = "place.stream.video#connection" 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 Video_Connections_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Video_Connections_Elem as CBOR") } func (t *Video_Connections_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "place.stream.video#connection": t.Video_Connection = new(Video_Connection) return glex.UnmarshalCBORBytes(b, t.Video_Connection) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // What is the source of this video? type Video_Source struct { MediaDefs_SourceClip *MediaDefs_SourceClip MediaDefs_SourceTracks *MediaDefs_SourceTracks // 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 Video_Source and *Video_Source marshal correctly. func (t Video_Source) MarshalJSON() ([]byte, error) { if t.MediaDefs_SourceClip != nil { cp := *t.MediaDefs_SourceClip cp.LexiconTypeID = "place.stream.media.defs#sourceClip" return json.Marshal(&cp) } if t.MediaDefs_SourceTracks != nil { cp := *t.MediaDefs_SourceTracks cp.LexiconTypeID = "place.stream.media.defs#sourceTracks" 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 Video_Source", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Video_Source as JSON") } func (t *Video_Source) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err } switch typ { case "place.stream.media.defs#sourceClip": t.MediaDefs_SourceClip = new(MediaDefs_SourceClip) return json.Unmarshal(b, t.MediaDefs_SourceClip) case "place.stream.media.defs#sourceTracks": t.MediaDefs_SourceTracks = new(MediaDefs_SourceTracks) return json.Unmarshal(b, t.MediaDefs_SourceTracks) 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 Video_Source) MarshalCBOR() ([]byte, error) { if t.MediaDefs_SourceClip != nil { cp := *t.MediaDefs_SourceClip cp.LexiconTypeID = "place.stream.media.defs#sourceClip" return glex.MarshalCBORBytes(&cp) } if t.MediaDefs_SourceTracks != nil { cp := *t.MediaDefs_SourceTracks cp.LexiconTypeID = "place.stream.media.defs#sourceTracks" 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 Video_Source", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union Video_Source as CBOR") } func (t *Video_Source) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err } switch typ { case "place.stream.media.defs#sourceClip": t.MediaDefs_SourceClip = new(MediaDefs_SourceClip) return glex.UnmarshalCBORBytes(b, t.MediaDefs_SourceClip) case "place.stream.media.defs#sourceTracks": t.MediaDefs_SourceTracks = new(MediaDefs_SourceTracks) return glex.UnmarshalCBORBytes(b, t.MediaDefs_SourceTracks) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil } } // Video_Connection is a "connection" in the place.stream.video schema. type Video_Connection struct { LexiconTypeID string `json:"$type,omitempty"` Ref *comatproto.RepoStrongRef `json:"ref,omitempty"` } // RecordTypeID implements glex.Record. func (t *Video_Connection) RecordTypeID() string { return "place.stream.video#connection" } func (t *Video_Connection) 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.video#connection" return glex.MarshalCBOR(w, &cp) } func (t *Video_Connection) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }