NewComponentDeserialize decodes serialized bytes previously produced by [Component.Serialize] back into a [Component]. This function does not take a component-model binary as input. It only accepts the result of a prior call to [Component.Serialize].
(engine *Engine, encoded []byte)
| 91 | // This function does not take a component-model binary as input. It only |
| 92 | // accepts the result of a prior call to [Component.Serialize]. |
| 93 | func NewComponentDeserialize(engine *Engine, encoded []byte) (*Component, error) { |
| 94 | var encodedPtr *C.uint8_t |
| 95 | if len(encoded) > 0 { |
| 96 | encodedPtr = (*C.uint8_t)(unsafe.Pointer(&encoded[0])) |
| 97 | } |
| 98 | var ptr *C.wasmtime_component_t |
| 99 | err := C.wasmtime_component_deserialize( |
| 100 | engine.ptr(), encodedPtr, C.size_t(len(encoded)), &ptr, |
| 101 | ) |
| 102 | runtime.KeepAlive(engine) |
| 103 | runtime.KeepAlive(encoded) |
| 104 | if err != nil { |
| 105 | return nil, mkError(err) |
| 106 | } |
| 107 | return mkComponent(ptr, engine), nil |
| 108 | } |
| 109 | |
| 110 | // NewComponentDeserializeFile is the same as [NewComponentDeserialize] except |
| 111 | // the bytes are read from a file at `path`. |
searching dependent graphs…