aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/draw/texture/resolver.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:21 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:21 +0100
commit2111c1248b08236a839dcf22036f92735bceb31c (patch)
tree9313da344b7134a913d1d917162e55b35fe1e74f /stockton-render/src/draw/texture/resolver.rs
parent102e166b040030b590df83888a1d1a47d0130f10 (diff)
chore(all): style formatting and clippy fixes
Diffstat (limited to 'stockton-render/src/draw/texture/resolver.rs')
-rw-r--r--stockton-render/src/draw/texture/resolver.rs47
1 files changed, 21 insertions, 26 deletions
diff --git a/stockton-render/src/draw/texture/resolver.rs b/stockton-render/src/draw/texture/resolver.rs
index 5867171..5fab16a 100644
--- a/stockton-render/src/draw/texture/resolver.rs
+++ b/stockton-render/src/draw/texture/resolver.rs
@@ -17,44 +17,39 @@
use stockton_levels::traits::textures::Texture;
-use image::{
- RgbaImage,
- io::Reader
-};
+use image::{io::Reader, RgbaImage};
use std::path::Path;
/// An object that can be used to resolve a texture from a BSP File
pub trait TextureResolver {
- /// Get the given texture, or None if it's corrupt/not there.
- fn resolve(&mut self, texture: &Texture) -> Option<RgbaImage>;
+ /// Get the given texture, or None if it's corrupt/not there.
+ fn resolve(&mut self, texture: &Texture) -> Option<RgbaImage>;
}
/// A basic filesystem resolver which expects no file extension and guesses the image format
pub struct BasicFSResolver<'a> {
- path: &'a Path
+ path: &'a Path,
}
impl<'a> BasicFSResolver<'a> {
- pub fn new(path: &'a Path) -> BasicFSResolver<'a> {
- BasicFSResolver {
- path
- }
- }
+ pub fn new(path: &'a Path) -> BasicFSResolver<'a> {
+ BasicFSResolver { path }
+ }
}
impl<'a> TextureResolver for BasicFSResolver<'a> {
- fn resolve(&mut self, tex: &Texture) -> Option<RgbaImage> {
- let path = self.path.join(&tex.name);
-
- if let Ok(file) = Reader::open(path) {
- if let Ok(guessed) = file.with_guessed_format() {
- if let Ok(decoded) = guessed.decode() {
- return Some(decoded.into_rgba());
- }
- }
- }
-
- None
- }
-} \ No newline at end of file
+ fn resolve(&mut self, tex: &Texture) -> Option<RgbaImage> {
+ let path = self.path.join(&tex.name);
+
+ if let Ok(file) = Reader::open(path) {
+ if let Ok(guessed) = file.with_guessed_format() {
+ if let Ok(decoded) = guessed.decode() {
+ return Some(decoded.into_rgba());
+ }
+ }
+ }
+
+ None
+ }
+}