github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/wasm/binary/custom.go (about)

     1  package binary
     2  
     3  import (
     4  	"bytes"
     5  
     6  	"github.com/bananabytelabs/wazero/internal/wasm"
     7  )
     8  
     9  // decodeCustomSection deserializes the data **not** associated with the "name" key in SectionIDCustom.
    10  //
    11  // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#custom-section%E2%91%A0
    12  func decodeCustomSection(r *bytes.Reader, name string, limit uint64) (result *wasm.CustomSection, err error) {
    13  	buf := make([]byte, limit)
    14  	_, err = r.Read(buf)
    15  
    16  	result = &wasm.CustomSection{
    17  		Name: name,
    18  		Data: buf,
    19  	}
    20  
    21  	return
    22  }