pub struct AssetLoader { /* private fields */ }Expand description
An asynchronous asset loader that fetches resources over HTTP
and populates a shared AssetCache.
Implementations§
Source§impl AssetLoader
Implements asynchronous asset loading for AssetLoader.
impl AssetLoader
Implements asynchronous asset loading for AssetLoader.
Sourcepub fn load_image(&mut self, url: String)
pub fn load_image(&mut self, url: String)
Begins loading an image asset from the given URL.
Creates an HtmlImageElement, sets its src, and registers onload/onerror
callbacks to update the shared cache state. The image loads asynchronously.
§Arguments
String- The URL of the image to load.
Sourcepub fn is_all_loaded(&self) -> bool
pub fn is_all_loaded(&self) -> bool
Returns whether all requested assets have finished loading.
§Returns
bool- True if no assets are pending.
Sourcepub fn get_image(&self, url: &str) -> Option<HtmlImageElement>
pub fn get_image(&self, url: &str) -> Option<HtmlImageElement>
Source§impl AssetLoader
Implements static asset creation utilities for AssetLoader.
impl AssetLoader
Implements static asset creation utilities for AssetLoader.
Sourcepub fn create_image_element(url: &str) -> Option<HtmlImageElement>
pub fn create_image_element(url: &str) -> Option<HtmlImageElement>
Creates an HtmlImageElement from the given URL without caching.
The image loads asynchronously. Returns immediately with the image element
whose src is set but may not have finished loading yet.
§Arguments
&str- The image URL.
§Returns
Option<HtmlImageElement>- The image element, orNoneif creation failed.
Source§impl AssetLoader
impl AssetLoader
pub fn get_cache(&self) -> &Rc<RefCell<AssetCache>>
pub fn get_mut_cache(&mut self) -> &mut Rc<RefCell<AssetCache>>
pub fn set_cache(&mut self, val: Rc<RefCell<AssetCache>>) -> &mut Self
Source§impl AssetLoader
impl AssetLoader
Trait Implementations§
Source§impl Clone for AssetLoader
impl Clone for AssetLoader
Source§fn clone(&self) -> AssetLoader
fn clone(&self) -> AssetLoader
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 AssetLoader
Implements Default for AssetLoader as a new empty loader.
impl Default for AssetLoader
Implements Default for AssetLoader as a new empty loader.
Source§fn default() -> AssetLoader
fn default() -> AssetLoader
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for AssetLoader
impl !Send for AssetLoader
impl !Sync for AssetLoader
impl !UnwindSafe for AssetLoader
impl Freeze for AssetLoader
impl Unpin for AssetLoader
impl UnsafeUnpin for AssetLoader
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