// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. // Lexicon schema: org.tangled.snippet.string package tangledlex import ( "bytes" "encoding/json" "fmt" "io" lexutil "github.com/bluesky-social/indigo/lex/util" cbg "github.com/whyrusleeping/cbor-gen" ) func init() { lexutil.RegisterType("org.tangled.snippet.string", &SnippetString{}) } type SnippetString struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=org.tangled.snippet.string"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` Description *string `json:"description,omitempty" cborgen:"description,omitempty"` Snippet *SnippetString_Snippet `json:"snippet" cborgen:"snippet"` } type SnippetString_Snippet struct { SnippetString_TextFile *SnippetString_TextFile } func (t *SnippetString_Snippet) MarshalJSON() ([]byte, error) { if t.SnippetString_TextFile != nil { t.SnippetString_TextFile.LexiconTypeID = "org.tangled.snippet.string#textFile" return json.Marshal(t.SnippetString_TextFile) } return nil, fmt.Errorf("can not marshal empty union as JSON") } func (t *SnippetString_Snippet) UnmarshalJSON(b []byte) error { typ, err := lexutil.TypeExtract(b) if err != nil { return err } switch typ { case "org.tangled.snippet.string#textFile": t.SnippetString_TextFile = new(SnippetString_TextFile) return json.Unmarshal(b, t.SnippetString_TextFile) default: return nil } } func (t *SnippetString_Snippet) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.SnippetString_TextFile != nil { return t.SnippetString_TextFile.MarshalCBOR(w) } return fmt.Errorf("can not marshal empty union as CBOR") } func (t *SnippetString_Snippet) UnmarshalCBOR(r io.Reader) error { typ, b, err := lexutil.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "org.tangled.snippet.string#textFile": t.SnippetString_TextFile = new(SnippetString_TextFile) return t.SnippetString_TextFile.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } } // SnippetString_TextFile is a "textFile" in the org.tangled.snippet.string schema. type SnippetString_TextFile struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=org.tangled.snippet.string#textFile"` Content *lexutil.LexBlob `json:"content" cborgen:"content"` // name: file name Name string `json:"name" cborgen:"name"` }