use std::error::Error; use std::str::FromStr; #[cfg(all(feature = "textures-fast", feature = "textures-slow"))] compile_error!("Mutually exclusive modules textures-fast and textures-slow selected."); #[cfg(not(any(feature = "textures-fast", feature = "textures-slow")))] compile_error!("Required feature textures not specified. Please specify one of textures-fast, textures-slow"); #[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(()) } } }