Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
5.5 kB · 159 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.feed.postgate
package appbsky
import ( "encoding/json" "fmt" "io"
glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen")
func init() { glex.RegisterType("app.bsky.feed.postgate", &FeedPostgate{})}
// Record defining interaction rules for a post. The record key (rkey) of the postgate record must match the record key of the post, and that record must be in the same repository.type FeedPostgate struct { LexiconTypeID string `json:"$type,omitempty"` CreatedAt string `json:"createdAt"` // detachedEmbeddingUris: List of AT-URIs embedding this post that the author has detached from. DetachedEmbeddingUris []string `json:"detachedEmbeddingUris,omitempty"` // embeddingRules: List of rules defining who can embed this post. If value is an empty array or is undefined, no particular rules apply and anyone can embed. EmbeddingRules []FeedPostgate_EmbeddingRules_Elem `json:"embeddingRules,omitempty"` // post: Reference (AT-URI) to the post record. Post string `json:"post"`}
// RecordTypeID implements glex.Record.func (t *FeedPostgate) RecordTypeID() string { return "app.bsky.feed.postgate" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// FeedPostgate and *FeedPostgate marshal with $type.func (t FeedPostgate) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.feed.postgate" type alias FeedPostgate return json.Marshal((alias)(t))}
func (t *FeedPostgate) 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 = "app.bsky.feed.postgate" return glex.MarshalCBOR(w, &cp)}
func (t *FeedPostgate) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type FeedPostgate_EmbeddingRules_Elem struct { FeedPostgate_DisableRule *FeedPostgate_DisableRule // 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 FeedPostgate_EmbeddingRules_Elem and *FeedPostgate_EmbeddingRules_Elem marshal correctly.func (t FeedPostgate_EmbeddingRules_Elem) MarshalJSON() ([]byte, error) { if t.FeedPostgate_DisableRule != nil { cp := *t.FeedPostgate_DisableRule cp.LexiconTypeID = "app.bsky.feed.postgate#disableRule" 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 FeedPostgate_EmbeddingRules_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedPostgate_EmbeddingRules_Elem as JSON")}
func (t *FeedPostgate_EmbeddingRules_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.feed.postgate#disableRule": t.FeedPostgate_DisableRule = new(FeedPostgate_DisableRule) return json.Unmarshal(b, t.FeedPostgate_DisableRule) 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 FeedPostgate_EmbeddingRules_Elem) MarshalCBOR() ([]byte, error) { if t.FeedPostgate_DisableRule != nil { cp := *t.FeedPostgate_DisableRule cp.LexiconTypeID = "app.bsky.feed.postgate#disableRule" 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 FeedPostgate_EmbeddingRules_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedPostgate_EmbeddingRules_Elem as CBOR")}
func (t *FeedPostgate_EmbeddingRules_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.feed.postgate#disableRule": t.FeedPostgate_DisableRule = new(FeedPostgate_DisableRule) return glex.UnmarshalCBORBytes(b, t.FeedPostgate_DisableRule) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// FeedPostgate_DisableRule is a "disableRule" in the app.bsky.feed.postgate schema.//// Disables embedding of this post.type FeedPostgate_DisableRule struct { LexiconTypeID string `json:"$type,omitempty"`}
// RecordTypeID implements glex.Record.func (t *FeedPostgate_DisableRule) RecordTypeID() string { return "app.bsky.feed.postgate#disableRule" }
func (t *FeedPostgate_DisableRule) 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 = "app.bsky.feed.postgate#disableRule" return glex.MarshalCBOR(w, &cp)}
func (t *FeedPostgate_DisableRule) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}