diff options
| author | Mica White <botahamec@outlook.com> | 2026-07-03 15:33:08 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-07-03 15:33:08 -0400 |
| commit | 73ffbee638c03da132aea0e5d600ca5e8144fd8e (patch) | |
| tree | 4ea897e8b3aaad2876625e241e740493e9b5b8b8 /src/file.rs | |
| parent | bb7525206da1782fd9af49621aa52d87bd227838 (diff) | |
Support WASM, kinda
Diffstat (limited to 'src/file.rs')
| -rw-r--r-- | src/file.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/file.rs b/src/file.rs index 42fecfa..2963879 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsStr, path::Path, sync::Arc}; +use std::{ffi::OsStr, path::Path}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; @@ -9,7 +9,6 @@ use crate::scene::{Scene, scene_id_by_name}; type FileTask = Task<std::io::Result<FileData>>; pub struct FileManager { - pub wasm_compiler: Arc<wasmi::Engine>, active_tasks: FxHashMap<Box<Path>, FileTask>, cache: FxHashMap<Box<Path>, FileData>, } @@ -87,17 +86,20 @@ impl FileData { impl FileManager { pub fn new() -> Self { Self { - wasm_compiler: Arc::new(wasmi::Engine::default()), active_tasks: FxHashMap::default(), cache: FxHashMap::default(), } } - pub fn load_file(&mut self, path: Box<Path>) -> std::io::Result<&FileData> { + pub fn load_file( + &mut self, + path: Box<Path>, + wasm_compiler: &wasmi::Engine, + ) -> std::io::Result<&FileData> { let data = compile_data( path.as_ref(), &std::fs::read(path.as_ref()).map(Vec::into_boxed_slice)?, - &self.wasm_compiler.clone(), + wasm_compiler, )?; self.cache.entry(path.clone()).insert_entry(data); Ok(self.cache.get(&path).unwrap()) @@ -120,9 +122,9 @@ impl FileManager { } } - pub fn start_loading_file(&mut self, path: impl AsRef<Path>) { + pub fn start_loading_file(&mut self, path: impl AsRef<Path>, wasm_compiler: &wasmi::Engine) { let boxed_path = Box::from(path.as_ref()); - let compiler = self.wasm_compiler.clone(); + let compiler = wasm_compiler.clone(); let task = unblock(move || { compile_data( &boxed_path, |
