github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/wasm/binary/custom.go (about)

     1  package binary
     2  
     3  import (
     4  	"bytes"
     5  
     6  	"github.com/tetratelabs/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  }