(&self, engine: &Engine, instance_id: Option<u64>)
| 364 | } |
| 365 | |
| 366 | fn new_store(&self, engine: &Engine, instance_id: Option<u64>) -> Result<Store<Host>> { |
| 367 | let mut builder = WasiCtxBuilder::new(); |
| 368 | self.run.configure_wasip2(&mut builder)?; |
| 369 | |
| 370 | if let Some(instance_id) = instance_id { |
| 371 | builder.env("INSTANCE_ID", instance_id.to_string()); |
| 372 | } |
| 373 | |
| 374 | let stdout_prefix: String; |
| 375 | let stderr_prefix: String; |
| 376 | match instance_id { |
| 377 | Some(instance_id) if !self.no_logging_prefix => { |
| 378 | stdout_prefix = format!("stdout [{instance_id}] :: "); |
| 379 | stderr_prefix = format!("stderr [{instance_id}] :: "); |
| 380 | } |
| 381 | _ => { |
| 382 | stdout_prefix = "".to_string(); |
| 383 | stderr_prefix = "".to_string(); |
| 384 | } |
| 385 | } |
| 386 | builder.stdout(LogStream::new(stdout_prefix, Output::Stdout)); |
| 387 | builder.stderr(LogStream::new(stderr_prefix, Output::Stderr)); |
| 388 | |
| 389 | let mut table = wasmtime::component::ResourceTable::new(); |
| 390 | if let Some(max) = self.run.common.wasi.max_resources { |
| 391 | table.set_max_capacity(max); |
| 392 | } |
| 393 | let mut host = Host { |
| 394 | table, |
| 395 | ctx: builder.build(), |
| 396 | http: self.run.wasi_http_ctx()?, |
| 397 | hooks: self.run.wasi_http_hooks(), |
| 398 | |
| 399 | limits: StoreLimits::default(), |
| 400 | |
| 401 | #[cfg(feature = "wasi-nn")] |
| 402 | nn: None, |
| 403 | #[cfg(feature = "wasi-config")] |
| 404 | wasi_config: None, |
| 405 | #[cfg(feature = "wasi-keyvalue")] |
| 406 | wasi_keyvalue: None, |
| 407 | #[cfg(feature = "profiling")] |
| 408 | guest_profiler: None, |
| 409 | write_profile: None, |
| 410 | }; |
| 411 | |
| 412 | if self.run.common.wasi.nn == Some(true) { |
| 413 | #[cfg(feature = "wasi-nn")] |
| 414 | { |
| 415 | let graphs = self |
| 416 | .run |
| 417 | .common |
| 418 | .wasi |
| 419 | .nn_graph |
| 420 | .iter() |
| 421 | .map(|g| (g.format.clone(), g.dir.clone())) |
| 422 | .collect::<Vec<_>>(); |
| 423 | let (backends, registry) = wasmtime_wasi_nn::preload(&graphs)?; |
no test coverage detected