diff --git a/src/main.rs b/src/main.rs
@@ -3,7 +3,7 @@ use std::fs::{self, File};
use std::io::{self, Write};
use std::path::PathBuf;
use std::process::exit;
-use types::{Escaped, PictureInfo};
+use types::{Escaped, Picture};
mod types;
@@ -38,7 +38,7 @@ fn main() -> io::Result<()> {
};
let f = File::open(config);
- match f.map(serde_yaml::from_reader::<_, Vec<PictureInfo>>) {
+ match f.map(serde_yaml::from_reader::<_, Vec<Picture>>) {
// Error opening the config file
Err(err) => {
eprintln!("ERROR: Couldn't open {config:?}: {err}");
@@ -50,13 +50,13 @@ fn main() -> io::Result<()> {
usage_config();
exit(1)
}
- Ok(Ok(pic_infos)) => render_gallery(pic_infos),
+ Ok(Ok(pics)) => render_gallery(pics),
}
}
/// Coordinates the rendering of all the pages and file conversions
-fn render_gallery(pic_infos: Vec<PictureInfo>) -> io::Result<()> {
- for pic in &pic_infos {
+fn render_gallery(pics: Vec<Picture>) -> io::Result<()> {
+ for pic in &pics {
let mut target_path = PathBuf::new();
target_path.push(TARGET_PATH);
target_path.push(PHOTOS_PATH);
@@ -73,7 +73,7 @@ fn render_gallery(pic_infos: Vec<PictureInfo>) -> io::Result<()> {
}
// Warn the user if a particular path doesn't have an associated alt string
- for pic in &pic_infos {
+ for pic in &pics {
if pic.alt.is_empty() {
println!(
"WARNING: Empty text alternative was specified for the file {name:?}",
@@ -86,20 +86,20 @@ fn render_gallery(pic_infos: Vec<PictureInfo>) -> io::Result<()> {
let mut thumb_path = PathBuf::new();
thumb_path.push(TARGET_PATH);
thumb_path.push(THUMBS_PATH);
- for pic in &pic_infos {
+ for pic in &pics {
pic.render_thumbnail(&thumb_path)?;
}
- render_index(&pic_infos)?;
+ render_index(&pics)?;
- for pic in pic_infos {
+ for pic in pics {
render_pic_page(&pic)?;
}
Ok(())
}
-fn render_index(pic_infos: &Vec<PictureInfo>) -> io::Result<()> {
+fn render_index(pics: &Vec<Picture>) -> io::Result<()> {
let mut path = PathBuf::from(TARGET_PATH);
path.push("index.html");
@@ -112,7 +112,7 @@ fn render_index(pic_infos: &Vec<PictureInfo>) -> io::Result<()> {
writeln!(f, "<title>{PAGE_TITLE}</title>")?;
write_head(&mut f)?;
- for pic in &pic_infos[0..10] {
+ for pic in &pics[0..10] {
writeln!(
f,
"<link rel=\"preload\" as=\"image\" href=\"/{THUMBS_PATH}/{name}.webp\">",
@@ -127,7 +127,7 @@ fn render_index(pic_infos: &Vec<PictureInfo>) -> io::Result<()> {
writeln!(f, "<main>")?;
writeln!(f, "<ul id=\"gallery\">")?;
- for pic in pic_infos {
+ for pic in pics {
writeln!(f, "<li>")?;
writeln!(
f,
@@ -151,7 +151,7 @@ fn render_index(pic_infos: &Vec<PictureInfo>) -> io::Result<()> {
writeln!(f, "</html>")
}
-fn render_pic_page(pic: &PictureInfo) -> io::Result<()> {
+fn render_pic_page(pic: &Picture) -> io::Result<()> {
let mut path = PathBuf::new();
path.push(TARGET_PATH);
path.push(PAGES_PATH);
diff --git a/src/types.rs b/src/types.rs
@@ -19,7 +19,7 @@ const HORIZONTAL_THUMB_HEIGHT: u32 = 300;
const VERTICAL_THUMB_HEIGHT: u32 = 800;
#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct PictureInfo {
+pub struct Picture {
pub path: PathBuf,
pub file_name: String,
pub alt: String,
@@ -27,7 +27,7 @@ pub struct PictureInfo {
pub struct Escaped<'a>(pub &'a str);
-impl PictureInfo {
+impl Picture {
pub fn render_thumbnail(&self, target_dir: &PathBuf) -> io::Result<()> {
let thumb_path = target_dir.join(self.file_name.clone() + ".webp");
@@ -93,7 +93,7 @@ impl PictureInfo {
}
}
-impl<'de> Deserialize<'de> for PictureInfo {
+impl<'de> Deserialize<'de> for Picture {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,