From f70917c8aae0d184ed7ce5e63e6347fdc21921e3 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Fri, 17 Jul 2026 18:43:05 -0700 Subject: load a texture image also refactor buffer management a little this doesn't yet draw the texture Change-Id: Id2efa761223a588bf599041ac525c3b988f0113b Force-Push: yes --- src/error.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index f034683..729ff23 100644 --- a/src/error.rs +++ b/src/error.rs @@ -90,6 +90,31 @@ impl From for Error { } } +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error { + message: format!("System I/O error: {}", e), + } + } +} + +impl From for Error { + fn from(e: png::DecodingError) -> Self { + match e { + png::DecodingError::IoError(e) => Self::from(e), + png::DecodingError::Format(_) => Error { + message: "Texture image is not a valid PNG.".to_string(), + }, + png::DecodingError::Parameter(e) => Error { + message: format!("PNG library misusage: {}", e), + }, + png::DecodingError::LimitsExceeded => Error { + message: "PNG needed too much memory to decode.".to_string(), + } + } + } +} + pub fn ignore_errors(mut body: impl FnMut() -> Result<()>) -> () { if let Err(e) = body() { eprintln!("Error: {}", e); -- cgit 1.4.1