MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / WitOption

Class WitOption

crates/c-api/include/wasmtime/component/val.hh:286–314  ·  view source on GitHub ↗

Class representing a component model `option` value.

Source from the content-addressed store, hash-verified

284
285/// Class representing a component model `option` value.
286class WitOption {
287 friend class Val;
288
289 VAL_REPR(WitOption, wasmtime_component_val_t *);
290
291 static void transfer(Raw &&from, Raw &to) {
292 to = from;
293 from = nullptr;
294 }
295
296 void copy(const Raw &other) {
297 if (other) {
298 wasmtime_component_val_t clone;
299 wasmtime_component_val_clone(other, &clone);
300 raw = wasmtime_component_val_new(&clone);
301 } else {
302 raw = nullptr;
303 }
304 }
305
306 void destroy() { wasmtime_component_val_free(raw); }
307
308public:
309 /// Constructs a new option value with the provided value.
310 explicit WitOption(std::optional<Val> val);
311
312 /// Returns the optional payload value associated with this option.
313 const Val *value() const { return detail::val_from_capi(raw); }
314};
315
316/// Class representing a component model `result` value.
317class WitResult {

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68