// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. package tangled // schema: sh.tangled.embed.commit import ( "bytes" "encoding/json" "fmt" "io" "github.com/bluesky-social/indigo/lex/util" cbg "github.com/whyrusleeping/cbor-gen" ) const ( EmbedCommitNSID = "sh.tangled.embed.commit" ) func init() { util.RegisterType("sh.tangled.embed.commit#main", &EmbedCommit{}) } // EmbedCommit is a "main" in the sh.tangled.embed.commit schema. // RECORDTYPE: EmbedCommit type EmbedCommit struct { LexiconTypeID string `json:"$type,const=sh.tangled.embed.commit" cborgen:"$type,const=sh.tangled.embed.commit"` Commit *EmbedCommit_Commit `json:"commit" cborgen:"commit"` Repo string `json:"repo" cborgen:"repo"` } type EmbedCommit_Commit struct { GitOid *GitOid } func (t *EmbedCommit_Commit) MarshalJSON() ([]byte, error) { if t.GitOid != nil { t.GitOid.LexiconTypeID = "sh.tangled.git.oid" return json.Marshal(t.GitOid) } return nil, fmt.Errorf("cannot marshal empty enum") } func (t *EmbedCommit_Commit) UnmarshalJSON(b []byte) error { typ, err := util.TypeExtract(b) if err != nil { return err } switch typ { case "sh.tangled.git.oid": t.GitOid = new(GitOid) return json.Unmarshal(b, t.GitOid) default: return nil } } func (t *EmbedCommit_Commit) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.GitOid != nil { return t.GitOid.MarshalCBOR(w) } return fmt.Errorf("cannot cbor marshal empty enum") } func (t *EmbedCommit_Commit) UnmarshalCBOR(r io.Reader) error { typ, b, err := util.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "sh.tangled.git.oid": t.GitOid = new(GitOid) return t.GitOid.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } }