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