wasmer/vm/
impls.rs

1use crate::macros::backend::match_rt;
2
3use super::*;
4
5impl VMExternToExtern for VMExtern {
6    fn to_extern(self, store: &mut impl crate::AsStoreMut) -> crate::Extern {
7        match_rt!(on self => s {
8            s.to_extern(store)
9        })
10    }
11}
12
13impl VMFunctionEnvironment {
14    #[allow(clippy::should_implement_trait)]
15    /// Returns a reference to the underlying value.
16    pub fn as_ref(&self) -> &(dyn std::any::Any + Send + 'static) {
17        match_rt!(on self => s {
18            s.as_ref()
19        })
20    }
21
22    #[allow(clippy::should_implement_trait)]
23    /// Returns a mutable reference to the underlying value.
24    pub fn as_mut(&mut self) -> &mut (dyn std::any::Any + Send + 'static) {
25        match_rt!(on self => s {
26            s.as_mut()
27        })
28    }
29
30    pub fn contents(self) -> Box<(dyn std::any::Any + Send + 'static)> {
31        match_rt!(on self => s {
32            s.contents
33        })
34    }
35}
36
37impl VMFuncRef {
38    /// Converts the `VMFuncRef` into a `RawValue`.
39    pub fn into_raw(self) -> RawValue {
40        match_rt!(on self => s {
41            s.into_raw()
42        })
43    }
44}
45
46impl VMExternRef {
47    /// Converts the `VMExternRef` into a `RawValue`.
48    pub fn into_raw(self) -> RawValue {
49        match_rt!(on self => s {
50            s.into_raw()
51        })
52    }
53}
54
55impl VMExceptionRef {
56    /// Converts the `VMExternRef` into a `RawValue`.
57    pub fn into_raw(self) -> RawValue {
58        match self {
59            #[cfg(feature = "sys")]
60            Self::Sys(s) => s.into_raw(),
61
62            _ => unimplemented!("VMExceptionRef::into_raw is only implemented for the sys backend"),
63        }
64    }
65}