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

Function NewComponentDeserialize

component_feat_component_model.go:93–108  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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].
93func 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`.

Callers 1

Calls 3

mkErrorFunction · 0.85
mkComponentFunction · 0.85
ptrMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…