Struct ImageStore
pub struct ImageStore { /* private fields */ }Expand description
A cheap-to-clone handle to a shared image cache whose loads run off the
UI thread — on the toolkit’s Background for ImageStore::new, or
in the host for ImageStore::host_driven.
Implementations§
§impl ImageStore
impl ImageStore
pub fn with_host_factory_with_max_dimension<R>(
factory: Rc<dyn Fn(u32) -> ImageStore>,
construct: impl FnOnce() -> R,
) -> R
pub fn with_host_factory_with_max_dimension<R>( factory: Rc<dyn Fn(u32) -> ImageStore>, construct: impl FnOnce() -> R, ) -> R
Construct app caches under a host’s asynchronous service while retaining the requested decoded-image bound and component wake custody.
pub fn new(
fetch: &Arc<dyn Fn(&str) -> Option<Vec<u8>> + Send + Sync>,
) -> ImageStore
pub fn new( fetch: &Arc<dyn Fn(&str) -> Option<Vec<u8>> + Send + Sync>, ) -> ImageStore
Build a store with the default worker count.
pub fn with_workers(
fetch: &Arc<dyn Fn(&str) -> Option<Vec<u8>> + Send + Sync>,
workers: usize,
) -> ImageStore
pub fn with_workers( fetch: &Arc<dyn Fn(&str) -> Option<Vec<u8>> + Send + Sync>, workers: usize, ) -> ImageStore
Build a store that runs at most workers fetch/decode jobs at once,
clamped to 1..=4 so one store cannot monopolise the background pool.
pub fn with_max_dimension(
fetch: &Arc<dyn Fn(&str) -> Option<Vec<u8>> + Send + Sync>,
max_dimension: u32,
) -> ImageStore
pub fn with_max_dimension( fetch: &Arc<dyn Fn(&str) -> Option<Vec<u8>> + Send + Sync>, max_dimension: u32, ) -> ImageStore
Build a store for document images instead of small thumbnails.
Decoded dimensions are bounded to 1..=4096; the worker, queue and total cache memory limits remain the same as for the thumbnail store.
pub fn host_driven() -> (ImageStore, HostImageLoader)
pub fn host_driven() -> (ImageStore, HostImageLoader)
A thumbnail store whose loading the host drives through the returned
HostImageLoader; no background work is spawned.
pub fn host_driven_with_max_dimension(
max_dimension: u32,
) -> (ImageStore, HostImageLoader)
pub fn host_driven_with_max_dimension( max_dimension: u32, ) -> (ImageStore, HostImageLoader)
A host-driven store with a bounded document-image decode dimension (clamped to 1..=4096).
pub fn get(&self, url: &str) -> Option<ImageData>
pub fn get(&self, url: &str) -> Option<ImageData>
Decoded image for url, kicking off an async load the first time a URL
is seen. Returns None while loading or after a failure — the caller
paints a placeholder until a later frame returns Some.
pub fn is_known(&self, url: &str) -> bool
pub fn is_known(&self, url: &str) -> bool
Whether url has been requested yet (Ready/Loading/Failed all count).
pub fn block_until_idle(&self, timeout: Duration)
pub fn block_until_idle(&self, timeout: Duration)
Block until all in-flight loads settle or timeout elapses on the
store’s executor clock. For the synchronous --shots pre-warm and
tests only — never call this on a live app’s UI thread. A host-driven
store settles only when its host completes requests.
Trait Implementations§
§impl Clone for ImageStore
impl Clone for ImageStore
§fn clone(&self) -> ImageStore
fn clone(&self) -> ImageStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ImageStore
impl !RefUnwindSafe for ImageStore
impl Send for ImageStore
impl Sync for ImageStore
impl Unpin for ImageStore
impl UnsafeUnpin for ImageStore
impl !UnwindSafe for ImageStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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>
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>
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