diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-08-31 12:48:34 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-08-31 12:48:34 -0400 |
commit | 78e23d75de3ece52c91bb9aeb1bceb085e1fe557 (patch) | |
tree | b95569193fb20368b0c2be139d8f5b754acde569 /src/context | |
parent | 639307ab5ed2683ff25eb9e5310dcf6a9fb3dff3 (diff) |
rework previews to have loading state as well
Diffstat (limited to 'src/context')
-rw-r--r-- | src/context/preview_context.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/context/preview_context.rs b/src/context/preview_context.rs index 05adc5e..51e593d 100644 --- a/src/context/preview_context.rs +++ b/src/context/preview_context.rs @@ -1,10 +1,12 @@ use std::collections::HashMap; use std::path; -use crate::preview::preview_file::FilePreview; +use crate::preview::preview_file::PreviewFileState; + +type FilePreviewMetadata = HashMap<path::PathBuf, PreviewFileState>; pub struct PreviewContext { - previews: HashMap<path::PathBuf, Option<FilePreview>>, + previews: FilePreviewMetadata, } impl PreviewContext { @@ -14,14 +16,10 @@ impl PreviewContext { } } - pub fn get_preview_ref(&self, p: &path::Path) -> Option<&Option<FilePreview>> { - self.previews.get(p) - } - pub fn get_preview_mut(&mut self, p: &path::Path) -> Option<&mut Option<FilePreview>> { - self.previews.get_mut(p) + pub fn previews_ref(&self) -> &FilePreviewMetadata { + &self.previews } - - pub fn insert_preview(&mut self, p: path::PathBuf, preview: Option<FilePreview>) { - self.previews.insert(p, preview); + pub fn previews_mut(&mut self) -> &mut FilePreviewMetadata { + &mut self.previews } } |