* \brief Serializes this module to a list of bytes. * * The returned bytes can then be used to later pass to `deserialize` to * quickly recreate this module in a different process perhaps. */
| 150 | * quickly recreate this module in a different process perhaps. |
| 151 | */ |
| 152 | Result<std::vector<uint8_t>> serialize() const { |
| 153 | wasm_byte_vec_t bytes; |
| 154 | auto *error = wasmtime_module_serialize(ptr.get(), &bytes); |
| 155 | if (error != nullptr) { |
| 156 | return Error(error); |
| 157 | } |
| 158 | std::vector<uint8_t> ret; |
| 159 | // NOLINTNEXTLINE TODO can this be done without triggering lints? |
| 160 | Span<uint8_t> raw(reinterpret_cast<uint8_t *>(bytes.data), bytes.size); |
| 161 | ret.assign(raw.begin(), raw.end()); |
| 162 | wasm_byte_vec_delete(&bytes); |
| 163 | return ret; |
| 164 | } |
| 165 | #endif // WASMTIME_FEATURE_COMPILER |
| 166 | }; |
| 167 |