github.com/moreal/bencodex-go@v0.0.0-20231021172012-18277a477d15/bencodex.go (about)

     1  package bencode
     2  
     3  import (
     4  	"github.com/moreal/bencodex-go/internal"
     5  	"github.com/moreal/bencodex-go/internal/decoder"
     6  	"github.com/moreal/bencodex-go/internal/encoder"
     7  )
     8  
     9  type BencodexDictionary map[internal.BencodexBytesLike]interface{}
    10  
    11  func MarshalTo(dst []byte, data interface{}) ([]byte, error) {
    12  	var e encoder.Encoder
    13  	return e.EncodeTo(dst, data)
    14  }
    15  
    16  func Marshal(data interface{}) ([]byte, error) {
    17  	var e encoder.Encoder
    18  	return e.EncodeTo(nil, data)
    19  }
    20  
    21  func Unmarshal(data []byte) (interface{}, error) {
    22  	var d decoder.Decoder
    23  	return d.Decode(data)
    24  }