github.com/annchain/OG@v0.0.9/tests/Bytes_gen.go (about)

     1  package main
     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 *Bytes) DecodeMsg(dc *msgp.Reader) (err error) {
    11  	{
    12  		var zb0001 []byte
    13  		zb0001, err = dc.ReadBytes([]byte((*z)))
    14  		if err != nil {
    15  			return
    16  		}
    17  		(*z) = Bytes(zb0001)
    18  	}
    19  	return
    20  }
    21  
    22  // EncodeMsg implements msgp.Encodable
    23  func (z Bytes) EncodeMsg(en *msgp.Writer) (err error) {
    24  	err = en.WriteBytes([]byte(z))
    25  	if err != nil {
    26  		return
    27  	}
    28  	return
    29  }
    30  
    31  // MarshalMsg implements msgp.Marshaler
    32  func (z Bytes) MarshalMsg(b []byte) (o []byte, err error) {
    33  	o = msgp.Require(b, z.Msgsize())
    34  	o = msgp.AppendBytes(o, []byte(z))
    35  	return
    36  }
    37  
    38  // UnmarshalMsg implements msgp.Unmarshaler
    39  func (z *Bytes) UnmarshalMsg(bts []byte) (o []byte, err error) {
    40  	{
    41  		var zb0001 []byte
    42  		zb0001, bts, err = msgp.ReadBytesBytes(bts, []byte((*z)))
    43  		if err != nil {
    44  			return
    45  		}
    46  		(*z) = Bytes(zb0001)
    47  	}
    48  	o = bts
    49  	return
    50  }
    51  
    52  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
    53  func (z Bytes) Msgsize() (s int) {
    54  	s = msgp.BytesPrefixSize + len([]byte(z))
    55  	return
    56  }
    57  
    58  // DecodeMsg implements msgp.Decodable
    59  func (z *Person) DecodeMsg(dc *msgp.Reader) (err error) {
    60  	var zb0001 uint32
    61  	zb0001, err = dc.ReadArrayHeader()
    62  	if err != nil {
    63  		return
    64  	}
    65  	if zb0001 != 2 {
    66  		err = msgp.ArrayError{Wanted: 2, Got: zb0001}
    67  		return
    68  	}
    69  	z.Name, err = dc.ReadString()
    70  	if err != nil {
    71  		return
    72  	}
    73  	z.Id, err = dc.ReadString()
    74  	if err != nil {
    75  		return
    76  	}
    77  	return
    78  }
    79  
    80  // EncodeMsg implements msgp.Encodable
    81  func (z Person) EncodeMsg(en *msgp.Writer) (err error) {
    82  	// array header, size 2
    83  	err = en.Append(0x92)
    84  	if err != nil {
    85  		return
    86  	}
    87  	err = en.WriteString(z.Name)
    88  	if err != nil {
    89  		return
    90  	}
    91  	err = en.WriteString(z.Id)
    92  	if err != nil {
    93  		return
    94  	}
    95  	return
    96  }
    97  
    98  // MarshalMsg implements msgp.Marshaler
    99  func (z Person) MarshalMsg(b []byte) (o []byte, err error) {
   100  	o = msgp.Require(b, z.Msgsize())
   101  	// array header, size 2
   102  	o = append(o, 0x92)
   103  	o = msgp.AppendString(o, z.Name)
   104  	o = msgp.AppendString(o, z.Id)
   105  	return
   106  }
   107  
   108  // UnmarshalMsg implements msgp.Unmarshaler
   109  func (z *Person) UnmarshalMsg(bts []byte) (o []byte, err error) {
   110  	var zb0001 uint32
   111  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
   112  	if err != nil {
   113  		return
   114  	}
   115  	if zb0001 != 2 {
   116  		err = msgp.ArrayError{Wanted: 2, Got: zb0001}
   117  		return
   118  	}
   119  	z.Name, bts, err = msgp.ReadStringBytes(bts)
   120  	if err != nil {
   121  		return
   122  	}
   123  	z.Id, bts, err = msgp.ReadStringBytes(bts)
   124  	if err != nil {
   125  		return
   126  	}
   127  	o = bts
   128  	return
   129  }
   130  
   131  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   132  func (z Person) Msgsize() (s int) {
   133  	s = 1 + msgp.StringPrefixSize + len(z.Name) + msgp.StringPrefixSize + len(z.Id)
   134  	return
   135  }