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)
| 118 | // produced with an `Engine` that has the same compilation options as the |
| 119 | // provided engine, and from the same version of this library. |
| 120 | func 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. |
searching dependent graphs…