wasmtime_c_api/types/
exn.rs1use crate::{wasm_tagtype_t, wasm_valtype_vec_t, wasmtime_error_t};
2use std::mem::MaybeUninit;
3use wasmtime::ExnType;
4
5#[derive(Clone)]
6pub struct wasmtime_exn_type_t {
7 pub(crate) ty: ExnType,
8}
9wasmtime_c_api_macros::declare_ty!(wasmtime_exn_type_t);
10
11#[unsafe(no_mangle)]
12pub extern "C" fn wasmtime_exn_type_new(
13 engine: &crate::wasm_engine_t,
14 params: &wasm_valtype_vec_t,
15 out: &mut MaybeUninit<Box<wasmtime_exn_type_t>>,
16) -> Option<Box<wasmtime_error_t>> {
17 crate::handle_result(
18 ExnType::new(
19 &engine.engine,
20 params
21 .as_slice()
22 .iter()
23 .map(|t| (**t.as_ref().unwrap()).clone()),
24 ),
25 |ty| {
26 out.write(Box::new(wasmtime_exn_type_t { ty }));
27 },
28 )
29}
30
31#[unsafe(no_mangle)]
32pub extern "C" fn wasmtime_exn_type_tag_type(ty: &wasmtime_exn_type_t) -> Box<wasm_tagtype_t> {
33 Box::new(wasm_tagtype_t::new(ty.ty.tag_type()))
34}