MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / Serialize

Method Serialize

module_feat_cranelift.go:59–70  ·  view source on GitHub ↗

Serialize will convert this in-memory compiled module into a list of bytes. The purpose of this method is to extract an artifact which can be stored elsewhere from this `Module`. The returned bytes can, for example, be stored on disk or in an object store. The `NewModuleDeserialize` function can be

()

Source from the content-addressed store, hash-verified

57// used to deserialize the returned bytes at a later date to get the module
58// back.
59func (m *Module) Serialize() ([]byte, error) {
60 retVec := C.wasm_byte_vec_t{}
61 err := C.wasmtime_module_serialize(m.ptr(), &retVec)
62 runtime.KeepAlive(m)
63
64 if err != nil {
65 return nil, mkError(err)
66 }
67 ret := C.GoBytes(unsafe.Pointer(retVec.data), C.int(retVec.size))
68 C.wasm_byte_vec_delete(&retVec)
69 return ret, nil
70}

Callers 5

ExampleModule_serializeFunction · 0.95
TestModuleSerializeFunction · 0.95
mainFunction · 0.95

Calls 2

ptrMethod · 0.95
mkErrorFunction · 0.85