pub struct ThumbnailService { /* private fields */ }Expand description
Thumbnail service with LRU cache management
Implementations§
Source§impl ThumbnailService
impl ThumbnailService
Sourcepub fn new<P: AsRef<Path>>(drive_root: P, max_cache_gb: f64) -> Result<Self>
pub fn new<P: AsRef<Path>>(drive_root: P, max_cache_gb: f64) -> Result<Self>
Create a new thumbnail service for a drive
Sourcepub fn prewarm_small(
&self,
items: &[(PathBuf, String, i32)],
cancel: &AtomicBool,
) -> usize
pub fn prewarm_small( &self, items: &[(PathBuf, String, i32)], cancel: &AtomicBool, ) -> usize
Prewarm Small thumbnails for a batch of photos. Skips any that
already exist on disk (cheap stat). Runs in parallel via Rayon —
the concurrency limiter inside generate_thumbnail caps the
number of in-flight image decodes at 4 to avoid OOM.
Aborts as soon as cancel is set so a fresh scan or app-exit
can stop prewarm immediately. Returns the number of newly
generated thumbnails.
Sourcepub fn generate_thumbnail(
&self,
photo_path: &Path,
file_hash: &str,
orientation: i32,
size: ThumbnailSize,
) -> Result<PathBuf, String>
pub fn generate_thumbnail( &self, photo_path: &Path, file_hash: &str, orientation: i32, size: ThumbnailSize, ) -> Result<PathBuf, String>
Generate a thumbnail synchronously with a timeout guard.
Call this from a background task (spawn_blocking) after get_thumbnail returns Pending.
pub fn generate_thumbnail_background( &self, photo_path: &Path, file_hash: &str, orientation: i32, size: ThumbnailSize, ) -> Result<PathBuf, String>
Sourcepub fn load_existing_thumbnails(&self) -> Result<()>
pub fn load_existing_thumbnails(&self) -> Result<()>
Scan existing thumbnails on disk and populate cache
Auto Trait Implementations§
impl Freeze for ThumbnailService
impl RefUnwindSafe for ThumbnailService
impl Send for ThumbnailService
impl Sync for ThumbnailService
impl Unpin for ThumbnailService
impl UnsafeUnpin for ThumbnailService
impl UnwindSafe for ThumbnailService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more