Class representing a component model `option` value.
| 284 | |
| 285 | /// Class representing a component model `option` value. |
| 286 | class 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 | |
| 308 | public: |
| 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. |
| 317 | class WitResult { |