Serialize encodes this component as a sequence of bytes which can later be passed to [NewComponentDeserialize] to recover the same component without recompiling.
()
| 74 | // passed to [NewComponentDeserialize] to recover the same component without |
| 75 | // recompiling. |
| 76 | func (c *Component) Serialize() ([]byte, error) { |
| 77 | retVec := C.wasm_byte_vec_t{} |
| 78 | err := C.wasmtime_component_serialize(c.ptr(), &retVec) |
| 79 | runtime.KeepAlive(c) |
| 80 | if err != nil { |
| 81 | return nil, mkError(err) |
| 82 | } |
| 83 | ret := C.GoBytes(unsafe.Pointer(retVec.data), C.int(retVec.size)) |
| 84 | C.wasm_byte_vec_delete(&retVec) |
| 85 | return ret, nil |
| 86 | } |
| 87 | |
| 88 | // NewComponentDeserialize decodes serialized bytes previously produced by |
| 89 | // [Component.Serialize] back into a [Component]. |