···
1
+
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
11
+
cid "github.com/ipfs/go-cid"
12
+
cbg "github.com/whyrusleeping/cbor-gen"
13
+
xerrors "golang.org/x/xerrors"
16
+
var _ = xerrors.Errorf
21
+
func (t *PublicKey) MarshalCBOR(w io.Writer) error {
23
+
_, err := w.Write(cbg.CborNull)
27
+
cw := cbg.NewCborWriter(w)
29
+
if _, err := cw.Write([]byte{164}); err != nil {
33
+
// t.Key (string) (string)
34
+
if len("key") > 1000000 {
35
+
return xerrors.Errorf("Value in field \"key\" was too long")
38
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
41
+
if _, err := cw.WriteString(string("key")); err != nil {
45
+
if len(t.Key) > 1000000 {
46
+
return xerrors.Errorf("Value in field t.Key was too long")
49
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
52
+
if _, err := cw.WriteString(string(t.Key)); err != nil {
56
+
// t.Name (string) (string)
57
+
if len("name") > 1000000 {
58
+
return xerrors.Errorf("Value in field \"name\" was too long")
61
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil {
64
+
if _, err := cw.WriteString(string("name")); err != nil {
68
+
if len(t.Name) > 1000000 {
69
+
return xerrors.Errorf("Value in field t.Name was too long")
72
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil {
75
+
if _, err := cw.WriteString(string(t.Name)); err != nil {
79
+
// t.LexiconTypeID (string) (string)
80
+
if len("$type") > 1000000 {
81
+
return xerrors.Errorf("Value in field \"$type\" was too long")
84
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
87
+
if _, err := cw.WriteString(string("$type")); err != nil {
91
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.bild.publicKey"))); err != nil {
94
+
if _, err := cw.WriteString(string("sh.bild.publicKey")); err != nil {
98
+
// t.Created (string) (string)
99
+
if len("created") > 1000000 {
100
+
return xerrors.Errorf("Value in field \"created\" was too long")
103
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("created"))); err != nil {
106
+
if _, err := cw.WriteString(string("created")); err != nil {
110
+
if len(t.Created) > 1000000 {
111
+
return xerrors.Errorf("Value in field t.Created was too long")
114
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Created))); err != nil {
117
+
if _, err := cw.WriteString(string(t.Created)); err != nil {
123
+
func (t *PublicKey) UnmarshalCBOR(r io.Reader) (err error) {
126
+
cr := cbg.NewCborReader(r)
128
+
maj, extra, err := cr.ReadHeader()
134
+
err = io.ErrUnexpectedEOF
138
+
if maj != cbg.MajMap {
139
+
return fmt.Errorf("cbor input should be of type map")
142
+
if extra > cbg.MaxLength {
143
+
return fmt.Errorf("PublicKey: map struct too large (%d)", extra)
148
+
nameBuf := make([]byte, 7)
149
+
for i := uint64(0); i < n; i++ {
150
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
156
+
// Field doesn't exist on this type, so ignore it
157
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
163
+
switch string(nameBuf[:nameLen]) {
164
+
// t.Key (string) (string)
168
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
173
+
t.Key = string(sval)
175
+
// t.Name (string) (string)
179
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
184
+
t.Name = string(sval)
186
+
// t.LexiconTypeID (string) (string)
190
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
195
+
t.LexiconTypeID = string(sval)
197
+
// t.Created (string) (string)
201
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
206
+
t.Created = string(sval)
210
+
// Field doesn't exist on this type, so ignore it
211
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {