wasmer/entities/tag/
mod.rs1pub(crate) mod inner;
2pub(crate) use inner::*;
3use wasmer_types::{TagType, Type};
4
5use crate::{
6 AsStoreMut, AsStoreRef, ExportError, Exportable, Extern,
7 vm::{VMExtern, VMExternTag},
8};
9
10#[derive(Debug, Clone, PartialEq, Eq, derive_more::From)]
16#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
17pub struct Tag(pub(crate) BackendTag);
18
19impl Tag {
20 pub fn new<P: Into<Box<[Type]>>>(store: &mut impl AsStoreMut, params: P) -> Self {
32 Self(BackendTag::new(store, params))
33 }
34
35 pub fn ty(&self, store: &impl AsStoreRef) -> TagType {
37 self.0.ty(store)
38 }
39
40 pub(crate) fn from_vm_extern(store: &mut impl AsStoreMut, vm_extern: VMExternTag) -> Self {
41 Self(BackendTag::from_vm_extern(store, vm_extern))
42 }
43
44 pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
46 self.0.is_from_store(store)
47 }
48
49 pub(crate) fn to_vm_extern(&self) -> VMExtern {
51 self.0.to_vm_extern()
52 }
53}
54
55impl<'a> Exportable<'a> for Tag {
56 fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError> {
57 match _extern {
58 Extern::Tag(tag) => Ok(tag),
59 _ => Err(ExportError::IncompatibleType),
60 }
61 }
62}