pub(crate) mod audio;
pub(crate) mod font;
pub(crate) mod shader;
pub(crate) mod sprite;
use downcast_rs::Downcast;
use super::Id;
use crate::context::ContextInner;
pub trait Loadable: Downcast {
fn load_if_exists(id: &Id, ctx: &mut ContextInner) -> Option<Self>
where
Self: Sized;
#[inline]
#[must_use]
fn load(id: &Id, ctx: &mut ContextInner) -> Self
where
Self: Sized,
{
Self::load_if_exists(id, ctx)
.unwrap_or_else(|| panic!("Error loading asset: '{id}' does not exist"))
}
#[inline]
#[must_use]
fn new() -> Self
where
Self: Default,
{
Self::default()
}
}
downcast_rs::impl_downcast!(Loadable);