1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.actor.status
6
7import (
8 "bytes"
9 "encoding/json"
10 "fmt"
11 "io"
12
13 "github.com/bluesky-social/indigo/lex/util"
14 cbg "github.com/whyrusleeping/cbor-gen"
15)
16
17func init() {
18 util.RegisterType("app.bsky.actor.status", &ActorStatus{})
19} //
20// RECORDTYPE: ActorStatus
21type ActorStatus struct {
22 LexiconTypeID string `json:"$type,const=app.bsky.actor.status" cborgen:"$type,const=app.bsky.actor.status"`
23 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
24 // durationMinutes: The duration of the status in minutes. Applications can choose to impose minimum and maximum limits.
25 DurationMinutes *int64 `json:"durationMinutes,omitempty" cborgen:"durationMinutes,omitempty"`
26 // embed: An optional embed associated with the status.
27 Embed *ActorStatus_Embed `json:"embed,omitempty" cborgen:"embed,omitempty"`
28 // status: The status for the account.
29 Status string `json:"status" cborgen:"status"`
30}
31
32// An optional embed associated with the status.
33type ActorStatus_Embed struct {
34 EmbedExternal *EmbedExternal
35}
36
37func (t *ActorStatus_Embed) MarshalJSON() ([]byte, error) {
38 if t.EmbedExternal != nil {
39 t.EmbedExternal.LexiconTypeID = "app.bsky.embed.external"
40 return json.Marshal(t.EmbedExternal)
41 }
42 return nil, fmt.Errorf("cannot marshal empty enum")
43}
44func (t *ActorStatus_Embed) UnmarshalJSON(b []byte) error {
45 typ, err := util.TypeExtract(b)
46 if err != nil {
47 return err
48 }
49
50 switch typ {
51 case "app.bsky.embed.external":
52 t.EmbedExternal = new(EmbedExternal)
53 return json.Unmarshal(b, t.EmbedExternal)
54
55 default:
56 return nil
57 }
58}
59
60func (t *ActorStatus_Embed) MarshalCBOR(w io.Writer) error {
61
62 if t == nil {
63 _, err := w.Write(cbg.CborNull)
64 return err
65 }
66 if t.EmbedExternal != nil {
67 return t.EmbedExternal.MarshalCBOR(w)
68 }
69 return fmt.Errorf("cannot cbor marshal empty enum")
70}
71func (t *ActorStatus_Embed) UnmarshalCBOR(r io.Reader) error {
72 typ, b, err := util.CborTypeExtractReader(r)
73 if err != nil {
74 return err
75 }
76
77 switch typ {
78 case "app.bsky.embed.external":
79 t.EmbedExternal = new(EmbedExternal)
80 return t.EmbedExternal.UnmarshalCBOR(bytes.NewReader(b))
81
82 default:
83 return nil
84 }
85}