wasmer_vm/
function_env.rs1use std::any::Any;
2
3pub struct VMFunctionEnvironment {
5 contents: Box<dyn Any + Send + 'static>,
6}
7
8impl std::fmt::Debug for VMFunctionEnvironment {
9 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 f.debug_struct("VMFunctionEnvironment")
11 .field("contents", &(&*self.contents as *const _))
12 .finish()
13 }
14}
15
16impl VMFunctionEnvironment {
17 pub fn new(val: impl Any + Send + 'static) -> Self {
19 Self {
20 contents: Box::new(val),
21 }
22 }
23
24 #[allow(clippy::should_implement_trait)]
25 pub fn as_ref(&self) -> &(dyn Any + Send + 'static) {
27 &*self.contents
28 }
29
30 #[allow(clippy::should_implement_trait)]
31 pub fn as_mut(&mut self) -> &mut (dyn Any + Send + 'static) {
33 &mut *self.contents
34 }
35}