github.com/quantosnetwork/Quantos@v0.0.0-20220306172517-e20b28c5a29a/protocol/marshaler.go (about)

     1  package protocol
     2  
     3  import (
     4  	"github.com/quantosnetwork/Quantos/decoder"
     5  	"github.com/quantosnetwork/Quantos/encoder"
     6  )
     7  
     8  func MarshalTo(dst []byte, data interface{}) ([]byte, error) {
     9  	var e encoder.Encoder
    10  	return e.EncodeTo(dst, data)
    11  }
    12  
    13  func Marshal(data interface{}) ([]byte, error) {
    14  	var e encoder.Encoder
    15  	return e.EncodeTo(nil, data)
    16  }
    17  
    18  func Unmashal(data []byte) (interface{}, error) {
    19  	var d decoder.Decoder
    20  	return d.Decode(data)
    21  }