~james/core

core/api/org_tangled/snippetstring.go -rw-r--r-- 2.6 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 14 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// 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"`
}