Discover books, shows, and movies at your level. Track your progress by filling your Shelf with what you find, and share with other language learners. *No dusting required. shlf.space
at master 184 lines 3.9 kB view raw
1// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 3package shlf 4 5import ( 6 "fmt" 7 "io" 8 "math" 9 "sort" 10 11 cid "github.com/ipfs/go-cid" 12 cbg "github.com/whyrusleeping/cbor-gen" 13 xerrors "golang.org/x/xerrors" 14) 15 16var _ = xerrors.Errorf 17var _ = cid.Undef 18var _ = math.E 19var _ = sort.Sort 20 21func (t *ActorProfile) MarshalCBOR(w io.Writer) error { 22 if t == nil { 23 _, err := w.Write(cbg.CborNull) 24 return err 25 } 26 27 cw := cbg.NewCborWriter(w) 28 29 if _, err := cw.Write([]byte{163}); err != nil { 30 return err 31 } 32 33 // t.LexiconTypeID (string) (string) 34 if len("$type") > 1000000 { 35 return xerrors.Errorf("Value in field \"$type\" was too long") 36 } 37 38 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 39 return err 40 } 41 if _, err := cw.WriteString(string("$type")); err != nil { 42 return err 43 } 44 45 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("space.shlf.actor.profile"))); err != nil { 46 return err 47 } 48 if _, err := cw.WriteString(string("space.shlf.actor.profile")); err != nil { 49 return err 50 } 51 52 // t.CreatedAt (string) (string) 53 if len("createdAt") > 1000000 { 54 return xerrors.Errorf("Value in field \"createdAt\" was too long") 55 } 56 57 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 58 return err 59 } 60 if _, err := cw.WriteString(string("createdAt")); err != nil { 61 return err 62 } 63 64 if len(t.CreatedAt) > 1000000 { 65 return xerrors.Errorf("Value in field t.CreatedAt was too long") 66 } 67 68 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 69 return err 70 } 71 if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 72 return err 73 } 74 75 // t.DisplayName (string) (string) 76 if len("displayName") > 1000000 { 77 return xerrors.Errorf("Value in field \"displayName\" was too long") 78 } 79 80 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("displayName"))); err != nil { 81 return err 82 } 83 if _, err := cw.WriteString(string("displayName")); err != nil { 84 return err 85 } 86 87 if len(t.DisplayName) > 1000000 { 88 return xerrors.Errorf("Value in field t.DisplayName was too long") 89 } 90 91 if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.DisplayName))); err != nil { 92 return err 93 } 94 if _, err := cw.WriteString(string(t.DisplayName)); err != nil { 95 return err 96 } 97 return nil 98} 99 100func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { 101 *t = ActorProfile{} 102 103 cr := cbg.NewCborReader(r) 104 105 maj, extra, err := cr.ReadHeader() 106 if err != nil { 107 return err 108 } 109 defer func() { 110 if err == io.EOF { 111 err = io.ErrUnexpectedEOF 112 } 113 }() 114 115 if maj != cbg.MajMap { 116 return fmt.Errorf("cbor input should be of type map") 117 } 118 119 if extra > cbg.MaxLength { 120 return fmt.Errorf("ActorProfile: map struct too large (%d)", extra) 121 } 122 123 n := extra 124 125 nameBuf := make([]byte, 11) 126 for i := uint64(0); i < n; i++ { 127 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 128 if err != nil { 129 return err 130 } 131 132 if !ok { 133 // Field doesn't exist on this type, so ignore it 134 if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 135 return err 136 } 137 continue 138 } 139 140 switch string(nameBuf[:nameLen]) { 141 // t.LexiconTypeID (string) (string) 142 case "$type": 143 144 { 145 sval, err := cbg.ReadStringWithMax(cr, 1000000) 146 if err != nil { 147 return err 148 } 149 150 t.LexiconTypeID = string(sval) 151 } 152 // t.CreatedAt (string) (string) 153 case "createdAt": 154 155 { 156 sval, err := cbg.ReadStringWithMax(cr, 1000000) 157 if err != nil { 158 return err 159 } 160 161 t.CreatedAt = string(sval) 162 } 163 // t.DisplayName (string) (string) 164 case "displayName": 165 166 { 167 sval, err := cbg.ReadStringWithMax(cr, 1000000) 168 if err != nil { 169 return err 170 } 171 172 t.DisplayName = string(sval) 173 } 174 175 default: 176 // Field doesn't exist on this type, so ignore it 177 if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 178 return err 179 } 180 } 181 } 182 183 return nil 184}