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

Function NewModuleDeserialize

module.go:120–140  ·  view source on GitHub ↗

NewModuleDeserialize decodes and deserializes in-memory bytes previously produced by `module.Serialize()`. This function does not take a WebAssembly binary as input. It takes as input the results of a previous call to `Serialize()`, and only takes that as input. If deserialization is successful th

(engine *Engine, encoded []byte)

Source from the content-addressed store, hash-verified

118// produced with an `Engine` that has the same compilation options as the
119// provided engine, and from the same version of this library.
120func NewModuleDeserialize(engine *Engine, encoded []byte) (*Module, error) {
121 var encodedPtr *C.uint8_t
122 var ptr *C.wasmtime_module_t
123 if len(encoded) > 0 {
124 encodedPtr = (*C.uint8_t)(unsafe.Pointer(&encoded[0]))
125 }
126 err := C.wasmtime_module_deserialize(
127 engine.ptr(),
128 encodedPtr,
129 C.size_t(len(encoded)),
130 &ptr,
131 )
132 runtime.KeepAlive(engine)
133 runtime.KeepAlive(encoded)
134
135 if err != nil {
136 return nil, mkError(err)
137 }
138
139 return mkModule(ptr), nil
140}
141
142// NewModuleDeserializeFile is the same as `NewModuleDeserialize` except that
143// the bytes are read from a file instead of provided as an argument.

Callers 1

TestModuleSerializeFunction · 0.85

Calls 3

mkErrorFunction · 0.85
mkModuleFunction · 0.85
ptrMethod · 0.45

Tested by 1

TestModuleSerializeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…