use std::fmt::Display;
use std::fmt::Write;
#[derive(Debug, Clone)]
pub enum AssetError {
AssetNotFound,
ResponseNotOk(u16),
}
impl Display for AssetError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AssetError::AssetNotFound => write!(f, "Asset not found"),
AssetError::ResponseNotOk(code) => write!(f, "Server response was not ok {}", code),
}
}
}
impl std::error::Error for AssetError {}
#[derive(Debug, Clone)]
pub struct ImgData {
pub bytes: Vec<u8>,
pub width: u32,
pub height: u32,
}
pub trait AssetLoader {
fn new() -> Self;
fn get(&self, local_path: impl Into<String>) -> Option<ImgData>;
}