pub struct ImageCache { /* private fields */ }Expand description
Thread-safe cache of image load states, shared across clones (like the GitHub
caches). Cheap to clone: just bumps the inner Arc.
Implementations§
Source§impl ImageCache
impl ImageCache
pub fn new() -> Self
pub fn get(&self, url: &str) -> Option<ImageState>
Sourcepub fn contains(&self, url: &str) -> bool
pub fn contains(&self, url: &str) -> bool
Presence check without cloning the (image-bearing) state — for the load guard.
pub fn mark_loading(&self, url: &str)
pub fn set_loaded(&self, url: &str, image: LoadedImage)
pub fn set_failed(&self, url: &str)
Sourcepub fn set_failed_with(&self, url: &str, reason: impl Into<Arc<str>>)
pub fn set_failed_with(&self, url: &str, reason: impl Into<Arc<str>>)
Mark failed with a short reason (mermaid/LaTeX syntax error) shown in the placeholder.
Sourcepub fn store_render(
&self,
url: &str,
result: Result<LoadedImage, Option<String>>,
)
pub fn store_render( &self, url: &str, result: Result<LoadedImage, Option<String>>, )
Store the outcome of an off-thread render: Ok → loaded, Err(Some) → failed with a
reason shown in the placeholder (collapsed + length-capped), Err(None) → generic
failure. Shared by the mermaid and math render paths.
Trait Implementations§
Source§impl Clone for ImageCache
impl Clone for ImageCache
Source§fn clone(&self) -> ImageCache
fn clone(&self) -> ImageCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ImageCache
impl Default for ImageCache
Source§fn default() -> ImageCache
fn default() -> ImageCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ImageCache
impl RefUnwindSafe for ImageCache
impl Send for ImageCache
impl Sync for ImageCache
impl Unpin for ImageCache
impl UnsafeUnpin for ImageCache
impl UnwindSafe for ImageCache
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.