Struct basalt::image_cache::ImageCache
source · pub struct ImageCache { /* private fields */ }
Expand description
System for storing images used within the UI.
Implementations§
source§impl ImageCache
impl ImageCache
sourcepub fn load_raw_image<D: Any + Send + Sync>(
&self,
cache_key: ImageCacheKey,
lifetime: ImageCacheLifetime,
format: ImageFormat,
width: u32,
height: u32,
associated_data: D,
data: ImageData
) -> Result<ImageInfo, String>
pub fn load_raw_image<D: Any + Send + Sync>( &self, cache_key: ImageCacheKey, lifetime: ImageCacheLifetime, format: ImageFormat, width: u32, height: u32, associated_data: D, data: ImageData ) -> Result<ImageInfo, String>
Load an image from raw data. This is not an encoded format like PNG (See load_from_bytes
).
sourcepub fn load_from_bytes<B: AsRef<[u8]>, D: Any + Send + Sync>(
&self,
cache_key: ImageCacheKey,
lifetime: ImageCacheLifetime,
associated_data: D,
bytes: B
) -> Result<ImageInfo, String>
pub fn load_from_bytes<B: AsRef<[u8]>, D: Any + Send + Sync>( &self, cache_key: ImageCacheKey, lifetime: ImageCacheLifetime, associated_data: D, bytes: B ) -> Result<ImageInfo, String>
Load an image from bytes that are encoded format such as PNG.
sourcepub fn load_from_url<U: AsRef<str>, D: Any + Send + Sync>(
&self,
lifetime: ImageCacheLifetime,
associated_data: D,
url: U
) -> Result<ImageInfo, String>
pub fn load_from_url<U: AsRef<str>, D: Any + Send + Sync>( &self, lifetime: ImageCacheLifetime, associated_data: D, url: U ) -> Result<ImageInfo, String>
Download and load the image from the provided URL.
sourcepub fn load_from_path<P: AsRef<Path>, D: Any + Send + Sync>(
&self,
lifetime: ImageCacheLifetime,
associated_data: D,
path: P
) -> Result<ImageInfo, String>
pub fn load_from_path<P: AsRef<Path>, D: Any + Send + Sync>( &self, lifetime: ImageCacheLifetime, associated_data: D, path: P ) -> Result<ImageInfo, String>
Open and load image from the provided path.
sourcepub fn obtain_image_infos<K: IntoIterator<Item = ImageCacheKey>>(
&self,
cache_keys: K
) -> Vec<Option<ImageInfo>>
pub fn obtain_image_infos<K: IntoIterator<Item = ImageCacheKey>>( &self, cache_keys: K ) -> Vec<Option<ImageInfo>>
Retrieve image information for multiple images.
sourcepub fn obtain_image_info(&self, cache_key: ImageCacheKey) -> Option<ImageInfo>
pub fn obtain_image_info(&self, cache_key: ImageCacheKey) -> Option<ImageInfo>
Retrieve image information on a single image.
Note: Where applicable you should use the plural form of this method.
sourcepub fn remove_image(&self, cache_key: ImageCacheKey)
pub fn remove_image(&self, cache_key: ImageCacheKey)
Removes an image from cache. This is useful when an image is added with an Indefinite
ImageCacheLifetime
.
Note: If an image is in use this will change the lifetime of the image to
ImageCacheLifetime::Immeditate
. Allowing it to be removed after it is no longer used.
Auto Trait Implementations§
impl !Freeze for ImageCache
impl !RefUnwindSafe for ImageCache
impl Send for ImageCache
impl Sync for ImageCache
impl Unpin 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
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.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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