| 102 | } |
| 103 | |
| 104 | fn create_instance( |
| 105 | &self, |
| 106 | module: &Module, |
| 107 | fuel: u64, |
| 108 | _memory_bytes: usize, |
| 109 | ) -> crate::Result<PooledInstance> { |
| 110 | let mut store = Store::new(&self.engine, ()); |
| 111 | store.set_fuel(fuel).map_err(|e| crate::Error::Internal { |
| 112 | detail: format!("failed to set WASM fuel: {e}"), |
| 113 | })?; |
| 114 | |
| 115 | // WASI restrictions: no imports provided → pure compute only. |
| 116 | // Any attempt to call filesystem/network/clock functions will trap. |
| 117 | let instance = |
| 118 | Instance::new(&mut store, module, &[]).map_err(|e| crate::Error::BadRequest { |
| 119 | detail: format!("WASM instantiation failed: {e}"), |
| 120 | })?; |
| 121 | |
| 122 | Ok(PooledInstance { store, instance }) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | #[cfg(test)] |