github.com/annchain/OG@v0.0.9/p2p/discv5/topic_gen.go (about)

     1  package discv5
     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 *Topic) DecodeMsg(dc *msgp.Reader) (err error) {
    11  	{
    12  		var zb0001 string
    13  		zb0001, err = dc.ReadString()
    14  		if err != nil {
    15  			return
    16  		}
    17  		(*z) = Topic(zb0001)
    18  	}
    19  	return
    20  }
    21  
    22  // EncodeMsg implements msgp.Encodable
    23  func (z Topic) EncodeMsg(en *msgp.Writer) (err error) {
    24  	err = en.WriteString(string(z))
    25  	if err != nil {
    26  		return
    27  	}
    28  	return
    29  }
    30  
    31  // MarshalMsg implements msgp.Marshaler
    32  func (z Topic) MarshalMsg(b []byte) (o []byte, err error) {
    33  	o = msgp.Require(b, z.Msgsize())
    34  	o = msgp.AppendString(o, string(z))
    35  	return
    36  }
    37  
    38  // UnmarshalMsg implements msgp.Unmarshaler
    39  func (z *Topic) UnmarshalMsg(bts []byte) (o []byte, err error) {
    40  	{
    41  		var zb0001 string
    42  		zb0001, bts, err = msgp.ReadStringBytes(bts)
    43  		if err != nil {
    44  			return
    45  		}
    46  		(*z) = Topic(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 Topic) Msgsize() (s int) {
    54  	s = msgp.StringPrefixSize + len(string(z))
    55  	return
    56  }
    57  
    58  // DecodeMsg implements msgp.Decodable
    59  func (z *Topics) DecodeMsg(dc *msgp.Reader) (err error) {
    60  	var zb0002 uint32
    61  	zb0002, err = dc.ReadArrayHeader()
    62  	if err != nil {
    63  		return
    64  	}
    65  	if cap((*z)) >= int(zb0002) {
    66  		(*z) = (*z)[:zb0002]
    67  	} else {
    68  		(*z) = make(Topics, zb0002)
    69  	}
    70  	for zb0001 := range *z {
    71  		{
    72  			var zb0003 string
    73  			zb0003, err = dc.ReadString()
    74  			if err != nil {
    75  				return
    76  			}
    77  			(*z)[zb0001] = Topic(zb0003)
    78  		}
    79  	}
    80  	return
    81  }
    82  
    83  // EncodeMsg implements msgp.Encodable
    84  func (z Topics) EncodeMsg(en *msgp.Writer) (err error) {
    85  	err = en.WriteArrayHeader(uint32(len(z)))
    86  	if err != nil {
    87  		return
    88  	}
    89  	for zb0004 := range z {
    90  		err = en.WriteString(string(z[zb0004]))
    91  		if err != nil {
    92  			return
    93  		}
    94  	}
    95  	return
    96  }
    97  
    98  // MarshalMsg implements msgp.Marshaler
    99  func (z Topics) MarshalMsg(b []byte) (o []byte, err error) {
   100  	o = msgp.Require(b, z.Msgsize())
   101  	o = msgp.AppendArrayHeader(o, uint32(len(z)))
   102  	for zb0004 := range z {
   103  		o = msgp.AppendString(o, string(z[zb0004]))
   104  	}
   105  	return
   106  }
   107  
   108  // UnmarshalMsg implements msgp.Unmarshaler
   109  func (z *Topics) UnmarshalMsg(bts []byte) (o []byte, err error) {
   110  	var zb0002 uint32
   111  	zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
   112  	if err != nil {
   113  		return
   114  	}
   115  	if cap((*z)) >= int(zb0002) {
   116  		(*z) = (*z)[:zb0002]
   117  	} else {
   118  		(*z) = make(Topics, zb0002)
   119  	}
   120  	for zb0001 := range *z {
   121  		{
   122  			var zb0003 string
   123  			zb0003, bts, err = msgp.ReadStringBytes(bts)
   124  			if err != nil {
   125  				return
   126  			}
   127  			(*z)[zb0001] = Topic(zb0003)
   128  		}
   129  	}
   130  	o = bts
   131  	return
   132  }
   133  
   134  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   135  func (z Topics) Msgsize() (s int) {
   136  	s = msgp.ArrayHeaderSize
   137  	for zb0004 := range z {
   138  		s += msgp.StringPrefixSize + len(string(z[zb0004]))
   139  	}
   140  	return
   141  }