diff options
| author | Mica White <botahamec@outlook.com> | 2026-07-03 16:35:05 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-07-03 16:35:05 -0400 |
| commit | bdbd5faeb7be5e5f81c1f4a952c8110df9e9b990 (patch) | |
| tree | 324a84ed9cba6b4ac5427775362ae25c6588b4db /src/file.rs | |
| parent | f31fda79035077a9dab8dee07a11d71fac3ba791 (diff) | |
| parent | cbbe1ca7f7b36b03e813fbf7e0147341090762bb (diff) | |
merge
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, |
