diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-20 18:35:05 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-20 18:35:05 +0200 |
| commit | 8000783f95ee007d9dda6f1dcc1c42c8e607b122 (patch) | |
| tree | 85f959948efb97bfc36e4f46c817b21c813e9744 /src/image.rs | |
| parent | 5edbd3a5b58c11939ea9823c6a847ba447254cb6 (diff) | |
FileId instead of Path + FileHash
Diffstat (limited to 'src/image.rs')
| -rw-r--r-- | src/image.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/image.rs b/src/image.rs index f4617c5a..28283259 100644 --- a/src/image.rs +++ b/src/image.rs @@ -3,13 +3,12 @@ use std::collections::{hash_map::Entry, HashMap}; use std::fmt::{self, Debug, Formatter}; use std::io::Cursor; -use std::path::Path; use image::io::Reader as ImageReader; use image::{DynamicImage, GenericImageView, ImageFormat}; use serde::{Deserialize, Serialize}; -use crate::loading::Loader; +use crate::loading::{FileId, Loader}; /// A loaded image. pub struct Image { @@ -69,11 +68,10 @@ impl ImageCache { } /// Load and decode an image file from a path. - pub fn load(&mut self, loader: &mut dyn Loader, path: &Path) -> Option<ImageId> { - let hash = loader.resolve(path)?; - let id = ImageId(hash.into_raw()); + pub fn load(&mut self, loader: &mut dyn Loader, file: FileId) -> Option<ImageId> { + let id = ImageId(file.into_raw()); if let Entry::Vacant(entry) = self.images.entry(id) { - let buffer = loader.load_file(path)?; + let buffer = loader.load_file(file)?; let image = Image::parse(&buffer)?; if let Some(callback) = &self.on_load { callback(id, &image); |
