// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
package org_tangled
// schema: org.tangled.snippet.string
import (
"bytes"
"encoding/json"
"fmt"
"io"
"github.com/bluesky-social/indigo/lex/util"
cbg "github.com/whyrusleeping/cbor-gen"
)
const (
SnippetStringNSID = "org.tangled.snippet.string"
)
func init() {
util.RegisterType("org.tangled.snippet.string", &SnippetString{})
} //
// RECORDTYPE: SnippetString
type SnippetString struct {
LexiconTypeID string `json:"$type,const=org.tangled.snippet.string" 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("cannot marshal empty enum")
}
func (t *SnippetString_Snippet) UnmarshalJSON(b []byte) error {
typ, err := util.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("cannot cbor marshal empty enum")
}
func (t *SnippetString_Snippet) UnmarshalCBOR(r io.Reader) error {
typ, b, err := util.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.
//
// RECORDTYPE: SnippetString_TextFile
type SnippetString_TextFile struct {
LexiconTypeID string `json:"$type,const=org.tangled.snippet.string#textFile" cborgen:"$type,const=org.tangled.snippet.string#textFile"`
Content *util.LexBlob `json:"content" cborgen:"content"`
// name: file name
Name string `json:"name" cborgen:"name"`
}