// Code generated by glex; DO NOT EDIT. // Lexicon schema: place.stream.badge.def package placestream import ( "encoding/json" "io" glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" ) func init() { glex.RegisterType("place.stream.badge.def", &BadgeDef{}) } // Defines a badge's visual appearance and type. Created by the issuer and referenced by issuance records. type BadgeDef struct { LexiconTypeID string `json:"$type,omitempty"` // badgeType: The category of this badge, used for scope and display rules. BadgeType string `json:"badgeType"` CreatedAt string `json:"createdAt"` // description: Optional description of the badge. Description *string `json:"description,omitempty"` // image: Badge icon image. Image *glex.Blob `json:"image,omitempty"` // name: Display name for this badge. Name string `json:"name"` } // RecordTypeID implements glex.Record. func (t *BadgeDef) RecordTypeID() string { return "place.stream.badge.def" } // MarshalJSON stamps the $type field, like MarshalCBOR does. The value // receiver operates on a copy, so the record is never mutated and both // BadgeDef and *BadgeDef marshal with $type. func (t BadgeDef) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.badge.def" type alias BadgeDef return json.Marshal((alias)(t)) } func (t *BadgeDef) 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.badge.def" return glex.MarshalCBOR(w, &cp) } func (t *BadgeDef) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }