github.com/chain5j/chain5j-pkg@v1.0.7/codec/rlp/coder.go (about)

     1  // Package rlp
     2  //
     3  // @author: xwc1125
     4  // @date: 2020/10/20
     5  package rlp
     6  
     7  type Codec struct {
     8  }
     9  
    10  func NewCodec() *Codec {
    11  	return &Codec{}
    12  }
    13  
    14  func (c *Codec) Encode(v interface{}) ([]byte, error) {
    15  	return EncodeToBytes(v)
    16  }
    17  
    18  func (c *Codec) Decode(data []byte, structPrt interface{}) error {
    19  	return DecodeBytes(data, structPrt)
    20  }