Skip to content

Commit

Permalink
Separated source pair importing from file_asset_source. Added importe…
Browse files Browse the repository at this point in the history
…r_type to SourceMetadata to solve a part of issue #8. Added docs to LoadStates.
  • Loading branch information
kabergstrom committed Jul 26, 2019
1 parent a32f34f commit 45d7d66
Show file tree
Hide file tree
Showing 12 changed files with 897 additions and 851 deletions.
159 changes: 26 additions & 133 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mopa = "0.2.2"
serde = "1.0"
serde_derive = "1.0"
erased-serde = "0.3"
bincode = "1.0.1"
bincode = "1.1"
ron = "0.4"
digest = "0.8.0"
meowhash = "0.1.2"
Expand Down
17 changes: 16 additions & 1 deletion daemon/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ use std::{
thread,
};

pub type ImporterMap = HashMap<&'static str, Box<dyn BoxedImporter>>;
#[derive(Default)]
pub struct ImporterMap(HashMap<&'static str, Box<dyn BoxedImporter>>);

impl ImporterMap {
pub fn insert(&mut self, ext: &'static str, importer: Box<dyn BoxedImporter>) {
self.0.insert(ext, importer);
}

pub fn get_by_path<'a>(&'a self, path: &PathBuf) -> Option<&'a dyn BoxedImporter> {
let lower_extension = path
.extension()
.map(|s| s.to_str().unwrap().to_lowercase())
.unwrap_or_else(|| "".to_string());
self.0.get(lower_extension.as_str()).map(|i| i.as_ref())
}
}

pub struct AssetDaemon {
db_dir: PathBuf,
Expand Down
Loading

0 comments on commit 45d7d66

Please sign in to comment.