use std::error::Error; use std::str::FromStr; #[cfg(all(feature = "textures-fast", feature = "textures-slow"))] compile_error!("You cannot use both texture loaders. Please only enable one of the textures-fast or textures-slow feature."); #[cfg(not(any(feature = "textures-fast", feature = "textures-slow")))] compile_error!("You need to enable a texture loader. Please enable one of the textures-fast, textures-slow feature."); #[cfg(feature = "textures-fast")] #[path = "loader_fast.rs"] pub mod loader; #[cfg(feature = "textures-slow")] #[path = "loader_slow.rs"] pub mod loader; pub trait TextureManager { fn load(size: TextureSize) -> Result> where Self: Sized; fn get_texture(&self, texture_id: &str) -> Option; } #[derive(Debug, Copy, Clone)] pub enum TextureSize { Full, Scaled375, Scaled125 } impl ToString for TextureSize { fn to_string(&self) -> String { match self { TextureSize::Full => "full".to_string(), TextureSize::Scaled375 => "375".to_string(), TextureSize::Scaled125 => "125".to_string() } } } impl FromStr for TextureSize { type Err = (); fn from_str(s: &str) -> Result { match s { "full" => Ok(TextureSize::Full), "375" => Ok(TextureSize::Scaled375), "125" => Ok(TextureSize::Scaled125), _ => Err(()) } } }