github.com/annchain/OG@v0.0.9/tests/msg_marshal/msg_gen.go (about) 1 package msg_marshal 2 3 // Code generated by github.com/tinylib/msgp DO NOT EDIT. 4 5 import ( 6 "github.com/tinylib/msgp/msgp" 7 ) 8 9 // DecodeMsg implements msgp.Decodable 10 func (z *Person) DecodeMsg(dc *msgp.Reader) (err error) { 11 var zb0001 uint32 12 zb0001, err = dc.ReadArrayHeader() 13 if err != nil { 14 return 15 } 16 if zb0001 != 3 { 17 err = msgp.ArrayError{Wanted: 3, Got: zb0001} 18 return 19 } 20 z.Name, err = dc.ReadString() 21 if err != nil { 22 return 23 } 24 z.Age, err = dc.ReadInt() 25 if err != nil { 26 return 27 } 28 z.Type, err = dc.ReadUint16() 29 if err != nil { 30 return 31 } 32 return 33 } 34 35 // EncodeMsg implements msgp.Encodable 36 func (z Person) EncodeMsg(en *msgp.Writer) (err error) { 37 // array header, size 3 38 err = en.Append(0x93) 39 if err != nil { 40 return 41 } 42 err = en.WriteString(z.Name) 43 if err != nil { 44 return 45 } 46 err = en.WriteInt(z.Age) 47 if err != nil { 48 return 49 } 50 err = en.WriteUint16(z.Type) 51 if err != nil { 52 return 53 } 54 return 55 } 56 57 // MarshalMsg implements msgp.Marshaler 58 func (z Person) MarshalMsg(b []byte) (o []byte, err error) { 59 o = msgp.Require(b, z.Msgsize()) 60 // array header, size 3 61 o = append(o, 0x93) 62 o = msgp.AppendString(o, z.Name) 63 o = msgp.AppendInt(o, z.Age) 64 o = msgp.AppendUint16(o, z.Type) 65 return 66 } 67 68 // UnmarshalMsg implements msgp.Unmarshaler 69 func (z *Person) UnmarshalMsg(bts []byte) (o []byte, err error) { 70 var zb0001 uint32 71 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 72 if err != nil { 73 return 74 } 75 if zb0001 != 3 { 76 err = msgp.ArrayError{Wanted: 3, Got: zb0001} 77 return 78 } 79 z.Name, bts, err = msgp.ReadStringBytes(bts) 80 if err != nil { 81 return 82 } 83 z.Age, bts, err = msgp.ReadIntBytes(bts) 84 if err != nil { 85 return 86 } 87 z.Type, bts, err = msgp.ReadUint16Bytes(bts) 88 if err != nil { 89 return 90 } 91 o = bts 92 return 93 } 94 95 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 96 func (z Person) Msgsize() (s int) { 97 s = 1 + msgp.StringPrefixSize + len(z.Name) + msgp.IntSize + msgp.Uint16Size 98 return 99 } 100 101 // DecodeMsg implements msgp.Decodable 102 func (z *Student) DecodeMsg(dc *msgp.Reader) (err error) { 103 var zb0001 uint32 104 zb0001, err = dc.ReadArrayHeader() 105 if err != nil { 106 return 107 } 108 if zb0001 != 2 { 109 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 110 return 111 } 112 var zb0002 uint32 113 zb0002, err = dc.ReadArrayHeader() 114 if err != nil { 115 return 116 } 117 if zb0002 != 3 { 118 err = msgp.ArrayError{Wanted: 3, Got: zb0002} 119 return 120 } 121 z.Person.Name, err = dc.ReadString() 122 if err != nil { 123 return 124 } 125 z.Person.Age, err = dc.ReadInt() 126 if err != nil { 127 return 128 } 129 z.Person.Type, err = dc.ReadUint16() 130 if err != nil { 131 return 132 } 133 z.Score, err = dc.ReadInt() 134 if err != nil { 135 return 136 } 137 return 138 } 139 140 // EncodeMsg implements msgp.Encodable 141 func (z *Student) EncodeMsg(en *msgp.Writer) (err error) { 142 // array header, size 2 143 // array header, size 3 144 err = en.Append(0x92, 0x93) 145 if err != nil { 146 return 147 } 148 err = en.WriteString(z.Person.Name) 149 if err != nil { 150 return 151 } 152 err = en.WriteInt(z.Person.Age) 153 if err != nil { 154 return 155 } 156 err = en.WriteUint16(z.Person.Type) 157 if err != nil { 158 return 159 } 160 err = en.WriteInt(z.Score) 161 if err != nil { 162 return 163 } 164 return 165 } 166 167 // MarshalMsg implements msgp.Marshaler 168 func (z *Student) MarshalMsg(b []byte) (o []byte, err error) { 169 o = msgp.Require(b, z.Msgsize()) 170 // array header, size 2 171 // array header, size 3 172 o = append(o, 0x92, 0x93) 173 o = msgp.AppendString(o, z.Person.Name) 174 o = msgp.AppendInt(o, z.Person.Age) 175 o = msgp.AppendUint16(o, z.Person.Type) 176 o = msgp.AppendInt(o, z.Score) 177 return 178 } 179 180 // UnmarshalMsg implements msgp.Unmarshaler 181 func (z *Student) UnmarshalMsg(bts []byte) (o []byte, err error) { 182 var zb0001 uint32 183 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 184 if err != nil { 185 return 186 } 187 if zb0001 != 2 { 188 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 189 return 190 } 191 var zb0002 uint32 192 zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) 193 if err != nil { 194 return 195 } 196 if zb0002 != 3 { 197 err = msgp.ArrayError{Wanted: 3, Got: zb0002} 198 return 199 } 200 z.Person.Name, bts, err = msgp.ReadStringBytes(bts) 201 if err != nil { 202 return 203 } 204 z.Person.Age, bts, err = msgp.ReadIntBytes(bts) 205 if err != nil { 206 return 207 } 208 z.Person.Type, bts, err = msgp.ReadUint16Bytes(bts) 209 if err != nil { 210 return 211 } 212 z.Score, bts, err = msgp.ReadIntBytes(bts) 213 if err != nil { 214 return 215 } 216 o = bts 217 return 218 } 219 220 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 221 func (z *Student) Msgsize() (s int) { 222 s = 1 + 1 + msgp.StringPrefixSize + len(z.Person.Name) + msgp.IntSize + msgp.Uint16Size + msgp.IntSize 223 return 224 } 225 226 // DecodeMsg implements msgp.Decodable 227 func (z *Teacher) DecodeMsg(dc *msgp.Reader) (err error) { 228 var zb0001 uint32 229 zb0001, err = dc.ReadArrayHeader() 230 if err != nil { 231 return 232 } 233 if zb0001 != 2 { 234 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 235 return 236 } 237 var zb0002 uint32 238 zb0002, err = dc.ReadArrayHeader() 239 if err != nil { 240 return 241 } 242 if zb0002 != 3 { 243 err = msgp.ArrayError{Wanted: 3, Got: zb0002} 244 return 245 } 246 z.Person.Name, err = dc.ReadString() 247 if err != nil { 248 return 249 } 250 z.Person.Age, err = dc.ReadInt() 251 if err != nil { 252 return 253 } 254 z.Person.Type, err = dc.ReadUint16() 255 if err != nil { 256 return 257 } 258 z.Teach, err = dc.ReadBool() 259 if err != nil { 260 return 261 } 262 return 263 } 264 265 // EncodeMsg implements msgp.Encodable 266 func (z *Teacher) EncodeMsg(en *msgp.Writer) (err error) { 267 // array header, size 2 268 // array header, size 3 269 err = en.Append(0x92, 0x93) 270 if err != nil { 271 return 272 } 273 err = en.WriteString(z.Person.Name) 274 if err != nil { 275 return 276 } 277 err = en.WriteInt(z.Person.Age) 278 if err != nil { 279 return 280 } 281 err = en.WriteUint16(z.Person.Type) 282 if err != nil { 283 return 284 } 285 err = en.WriteBool(z.Teach) 286 if err != nil { 287 return 288 } 289 return 290 } 291 292 // MarshalMsg implements msgp.Marshaler 293 func (z *Teacher) MarshalMsg(b []byte) (o []byte, err error) { 294 o = msgp.Require(b, z.Msgsize()) 295 // array header, size 2 296 // array header, size 3 297 o = append(o, 0x92, 0x93) 298 o = msgp.AppendString(o, z.Person.Name) 299 o = msgp.AppendInt(o, z.Person.Age) 300 o = msgp.AppendUint16(o, z.Person.Type) 301 o = msgp.AppendBool(o, z.Teach) 302 return 303 } 304 305 // UnmarshalMsg implements msgp.Unmarshaler 306 func (z *Teacher) UnmarshalMsg(bts []byte) (o []byte, err error) { 307 var zb0001 uint32 308 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 309 if err != nil { 310 return 311 } 312 if zb0001 != 2 { 313 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 314 return 315 } 316 var zb0002 uint32 317 zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) 318 if err != nil { 319 return 320 } 321 if zb0002 != 3 { 322 err = msgp.ArrayError{Wanted: 3, Got: zb0002} 323 return 324 } 325 z.Person.Name, bts, err = msgp.ReadStringBytes(bts) 326 if err != nil { 327 return 328 } 329 z.Person.Age, bts, err = msgp.ReadIntBytes(bts) 330 if err != nil { 331 return 332 } 333 z.Person.Type, bts, err = msgp.ReadUint16Bytes(bts) 334 if err != nil { 335 return 336 } 337 z.Teach, bts, err = msgp.ReadBoolBytes(bts) 338 if err != nil { 339 return 340 } 341 o = bts 342 return 343 } 344 345 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 346 func (z *Teacher) Msgsize() (s int) { 347 s = 1 + 1 + msgp.StringPrefixSize + len(z.Person.Name) + msgp.IntSize + msgp.Uint16Size + msgp.BoolSize 348 return 349 }