MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / create_instance

Method create_instance

nodedb/src/control/planner/wasm/pool.rs:104–123  ·  view source on GitHub ↗
(
        &self,
        module: &Module,
        fuel: u64,
        _memory_bytes: usize,
    )

Source from the content-addressed store, hash-verified

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)]

Callers 2

acquireMethod · 0.80
warmMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected