diff options
Diffstat (limited to 'src/loading/mod.rs')
| -rw-r--r-- | src/loading/mod.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/loading/mod.rs b/src/loading/mod.rs index 818e7e3c..b4e5d160 100644 --- a/src/loading/mod.rs +++ b/src/loading/mod.rs @@ -6,6 +6,7 @@ mod fs; #[cfg(feature = "fs")] pub use fs::*; +use std::path::Path; use std::rc::Rc; use crate::font::FaceInfo; @@ -18,13 +19,22 @@ pub trait Loader { /// Descriptions of all font faces this loader serves. fn faces(&self) -> &[FaceInfo]; + /// Resolve a hash that is the same for all paths pointing to the same file. + /// + /// Should return `None` if the file does not exist. + fn resolve(&self, path: &Path) -> Option<FileHash>; + /// Load the font face with the given index in [`faces()`](Self::faces). fn load_face(&mut self, idx: usize) -> Option<Buffer>; /// Load a file from a path. - fn load_file(&mut self, path: &str) -> Option<Buffer>; + fn load_file(&mut self, path: &Path) -> Option<Buffer>; } +/// A hash that must be the same for all paths pointing to the same file. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct FileHash(pub u64); + /// A loader which serves nothing. pub struct BlankLoader; @@ -33,11 +43,15 @@ impl Loader for BlankLoader { &[] } + fn resolve(&self, _: &Path) -> Option<FileHash> { + None + } + fn load_face(&mut self, _: usize) -> Option<Buffer> { None } - fn load_file(&mut self, _: &str) -> Option<Buffer> { + fn load_file(&mut self, _: &Path) -> Option<Buffer> { None } } |
