From af65f622a62540b72cfab47c19d64c609eb6e122 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 24 Oct 2026 19:33:20 +0100 Subject: [PATCH] Write file load/save helpers for Image --- src/image.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/image.rs b/src/image.rs index 977da9e..dcbacfe 100644 --- a/src/image.rs +++ b/src/image.rs @@ -111,3 +111,15 @@ impl From for Error { Error::Io(error) } } + +impl Image { + pub fn load(path: &str) -> Result { + let file = std::fs::File::open(path)?; + F::read(&mut std::io::BufReader::new(file)) + } + + pub fn save(&self, path: &str) -> std::io::Result<()> { + let file = std::fs::File::create(path)?; + F::write(&mut std::io::BufWriter::new(file), self) + } +}