1use crate::{
2 WasmtimeStoreContext, WasmtimeStoreContextMut, handle_result, wasm_tagtype_t, wasmtime_error_t,
3};
4use std::mem::MaybeUninit;
5use wasmtime::Tag;
6
7#[unsafe(no_mangle)]
9pub unsafe extern "C" fn wasmtime_tag_new(
10 mut store: WasmtimeStoreContextMut<'_>,
11 tt: &wasm_tagtype_t,
12 ret: &mut MaybeUninit<Tag>,
13) -> Option<Box<wasmtime_error_t>> {
14 let tag_type = tt.to_tag_type(store.engine());
15 handle_result(Tag::new(&mut store, &tag_type), |tag| {
16 ret.write(tag);
17 })
18}
19
20#[unsafe(no_mangle)]
22pub extern "C" fn wasmtime_tag_type(
23 store: WasmtimeStoreContext<'_>,
24 tag: &Tag,
25) -> Box<wasm_tagtype_t> {
26 let ty = tag.ty(store);
27 Box::new(wasm_tagtype_t::from_tag_type(ty))
28}
29
30#[unsafe(no_mangle)]
32pub extern "C" fn wasmtime_tag_eq(store: WasmtimeStoreContext<'_>, a: &Tag, b: &Tag) -> bool {
33 Tag::eq(a, b, store)
34}