From 6043c23c19c0369acc1a47b9f4de75dd5ae459ae Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 01:50:10 -0800 Subject: [PATCH] couple tools --- src/texture_loader.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/texture_loader.rs b/src/texture_loader.rs index 4b2aee9..7f74f0d 100644 --- a/src/texture_loader.rs +++ b/src/texture_loader.rs @@ -12,6 +12,13 @@ pub enum TextureLoader{ pub enum Texture{ ImageDDS(Vec), } +impl AsRef<[u8]> for Texture{ + fn as_ref(&self)->&[u8]{ + match self{ + Texture::ImageDDS(data)=>data.as_ref(), + } + } +} pub struct Textures{ textures:Vec, @@ -25,6 +32,9 @@ impl Textures{ pub fn get_texture(&self,texture_id:TextureId)->Option<&Texture>{ self.textures.get(texture_id.get() as usize) } + pub fn into_iter(self)->impl Iterator{ + self.textures.into_iter().enumerate().map(|(texture_id,texture)|(TextureId::new(texture_id as u32),texture)) + } } pub trait TextureLoaderTrait{