Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
6.0 kB · 159 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160// Code generated by glex; DO NOT EDIT.
// Lexicon schema: place.stream.vod.defs
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")
// VodDefs_CommentView is a "commentView" in the place.stream.vod.defs schema.type VodDefs_CommentView struct { LexiconTypeID string `json:"$type,omitempty"` Author appbsky.ActorDefs_ProfileViewBasic `json:"author"` Cid string `json:"cid"` IndexedAt string `json:"indexedAt"` // likeCount: Number of likes on this comment. LikeCount int64 `json:"likeCount"` Record *glex.LexiconTypeDecoder `json:"record"` // replyTo: The parent comment this one replies to, if any. A non-recursive view (it carries no replyTo of its own), so the thread is flattened to a single hop; walk `record.reply` to follow the chain further. ReplyTo *VodDefs_CommentView_ReplyTo `json:"replyTo,omitempty"` Uri string `json:"uri"`}
// RecordTypeID implements glex.Record.func (t *VodDefs_CommentView) RecordTypeID() string { return "place.stream.vod.defs#commentView" }
func (t *VodDefs_CommentView) 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.vod.defs#commentView" return glex.MarshalCBOR(w, &cp)}
func (t *VodDefs_CommentView) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// The parent comment this one replies to, if any. A non-recursive view (it carries no replyTo of its own), so the thread is flattened to a single hop; walk `record.reply` to follow the chain further.type VodDefs_CommentView_ReplyTo struct { VodDefs_CommentViewBasic *VodDefs_CommentViewBasic // 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 VodDefs_CommentView_ReplyTo and *VodDefs_CommentView_ReplyTo marshal correctly.func (t VodDefs_CommentView_ReplyTo) MarshalJSON() ([]byte, error) { if t.VodDefs_CommentViewBasic != nil { cp := *t.VodDefs_CommentViewBasic cp.LexiconTypeID = "place.stream.vod.defs#commentViewBasic" 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 VodDefs_CommentView_ReplyTo", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union VodDefs_CommentView_ReplyTo as JSON")}
func (t *VodDefs_CommentView_ReplyTo) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "place.stream.vod.defs#commentViewBasic": t.VodDefs_CommentViewBasic = new(VodDefs_CommentViewBasic) return json.Unmarshal(b, t.VodDefs_CommentViewBasic) 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 VodDefs_CommentView_ReplyTo) MarshalCBOR() ([]byte, error) { if t.VodDefs_CommentViewBasic != nil { cp := *t.VodDefs_CommentViewBasic cp.LexiconTypeID = "place.stream.vod.defs#commentViewBasic" 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 VodDefs_CommentView_ReplyTo", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union VodDefs_CommentView_ReplyTo as CBOR")}
func (t *VodDefs_CommentView_ReplyTo) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "place.stream.vod.defs#commentViewBasic": t.VodDefs_CommentViewBasic = new(VodDefs_CommentViewBasic) return glex.UnmarshalCBORBytes(b, t.VodDefs_CommentViewBasic) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// VodDefs_CommentViewBasic is a "commentViewBasic" in the place.stream.vod.defs schema.//// A comment view without its own `replyTo`, used to represent the parent of a reply without recursively nesting the whole thread.type VodDefs_CommentViewBasic struct { LexiconTypeID string `json:"$type,omitempty"` Author appbsky.ActorDefs_ProfileViewBasic `json:"author"` Cid string `json:"cid"` IndexedAt string `json:"indexedAt"` // likeCount: Number of likes on this comment. LikeCount int64 `json:"likeCount"` Record *glex.LexiconTypeDecoder `json:"record"` Uri string `json:"uri"`}
// RecordTypeID implements glex.Record.func (t *VodDefs_CommentViewBasic) RecordTypeID() string { return "place.stream.vod.defs#commentViewBasic"}
func (t *VodDefs_CommentViewBasic) 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.vod.defs#commentViewBasic" return glex.MarshalCBOR(w, &cp)}
func (t *VodDefs_CommentViewBasic) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}