Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
7.0 kB · 207 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208// Code generated by glex; DO NOT EDIT.
// Lexicon schema: place.stream.chat.access
package placestream
import ( "encoding/json" "fmt" "io"
glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen")
func init() { glex.RegisterType("place.stream.chat.access", &ChatAccess{})}
// A rule about who may chat on this streamer's streams. Rules are evaluated per streamer: when any allow rule exists, only accounts matching an allow rule may chat; accounts matching a deny rule never may. A streamer with no rules has open chat.type ChatAccess struct { LexiconTypeID string `json:"$type,omitempty"` // action: Whether accounts matching the subject may chat (allow) or may not (deny). Deny wins over allow. Action string `json:"action"` // createdAt: Client-declared timestamp when this rule was created. CreatedAt string `json:"createdAt"` // subject: Who the rule matches. Open: a node ignores subject types it does not understand. Subject ChatAccess_Subject `json:"subject"`}
// RecordTypeID implements glex.Record.func (t *ChatAccess) RecordTypeID() string { return "place.stream.chat.access" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// ChatAccess and *ChatAccess marshal with $type.func (t ChatAccess) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.chat.access" type alias ChatAccess return json.Marshal((alias)(t))}
func (t *ChatAccess) 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.chat.access" return glex.MarshalCBOR(w, &cp)}
func (t *ChatAccess) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// Who the rule matches. Open: a node ignores subject types it does not understand.type ChatAccess_Subject struct { ChatAccess_Label *ChatAccess_Label ChatAccess_Verifier *ChatAccess_Verifier // 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 ChatAccess_Subject and *ChatAccess_Subject marshal correctly.func (t ChatAccess_Subject) MarshalJSON() ([]byte, error) { if t.ChatAccess_Label != nil { cp := *t.ChatAccess_Label cp.LexiconTypeID = "place.stream.chat.access#label" return json.Marshal(&cp) } if t.ChatAccess_Verifier != nil { cp := *t.ChatAccess_Verifier cp.LexiconTypeID = "place.stream.chat.access#verifier" 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 ChatAccess_Subject", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union ChatAccess_Subject as JSON")}
func (t *ChatAccess_Subject) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "place.stream.chat.access#label": t.ChatAccess_Label = new(ChatAccess_Label) return json.Unmarshal(b, t.ChatAccess_Label) case "place.stream.chat.access#verifier": t.ChatAccess_Verifier = new(ChatAccess_Verifier) return json.Unmarshal(b, t.ChatAccess_Verifier) 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 ChatAccess_Subject) MarshalCBOR() ([]byte, error) { if t.ChatAccess_Label != nil { cp := *t.ChatAccess_Label cp.LexiconTypeID = "place.stream.chat.access#label" return glex.MarshalCBORBytes(&cp) } if t.ChatAccess_Verifier != nil { cp := *t.ChatAccess_Verifier cp.LexiconTypeID = "place.stream.chat.access#verifier" 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 ChatAccess_Subject", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union ChatAccess_Subject as CBOR")}
func (t *ChatAccess_Subject) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "place.stream.chat.access#label": t.ChatAccess_Label = new(ChatAccess_Label) return glex.UnmarshalCBORBytes(b, t.ChatAccess_Label) case "place.stream.chat.access#verifier": t.ChatAccess_Verifier = new(ChatAccess_Verifier) return glex.UnmarshalCBORBytes(b, t.ChatAccess_Verifier) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// ChatAccess_Label is a "label" in the place.stream.chat.access schema.//// Accounts carrying this label from this labeler. A node that sees a rule naming a labeler starts mirroring its matching labels.type ChatAccess_Label struct { LexiconTypeID string `json:"$type,omitempty"` // labeler: The labeler's DID. Labeler string `json:"labeler"` // value: The label value that matches; a trailing * matches any label with that prefix. Value string `json:"value"`}
// RecordTypeID implements glex.Record.func (t *ChatAccess_Label) RecordTypeID() string { return "place.stream.chat.access#label" }
func (t *ChatAccess_Label) 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.chat.access#label" return glex.MarshalCBOR(w, &cp)}
func (t *ChatAccess_Label) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// ChatAccess_Verifier is a "verifier" in the place.stream.chat.access schema.//// Accounts that hold an app.bsky.graph.verification record issued by this DID. A node that sees a rule naming a verifier starts indexing that verifier's records.type ChatAccess_Verifier struct { LexiconTypeID string `json:"$type,omitempty"` // did: The verifier's DID. Did string `json:"did"`}
// RecordTypeID implements glex.Record.func (t *ChatAccess_Verifier) RecordTypeID() string { return "place.stream.chat.access#verifier" }
func (t *ChatAccess_Verifier) 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.chat.access#verifier" return glex.MarshalCBOR(w, &cp)}
func (t *ChatAccess_Verifier) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}