From 3e49422180b74cc4bcee15f989a3ca212f65e5bb Mon Sep 17 00:00:00 2001 From: Maximilian Pohl Date: Mon, 16 Oct 2023 08:59:18 +0200 Subject: [PATCH] Add documentation for internal code where needed Related to #3 --- src/model.rs | 8 ++++++++ src/storage.rs | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/model.rs b/src/model.rs index f074bfe..fc41179 100644 --- a/src/model.rs +++ b/src/model.rs @@ -10,7 +10,9 @@ pub struct ImageThumbs { #[derive(Deserialize, Debug, Clone)] pub(crate) struct Params { + /// this name will be added to the thumbnail with an underscore (_) pub(crate) name: String, + /// PNG ignores this variable as it is always lossless pub(crate) quality: u8, pub(crate) size: (u32, u32), pub(crate) mode: Mode, @@ -19,12 +21,18 @@ pub(crate) struct Params { #[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "snake_case")] pub(crate) enum Mode { + /// The image's aspect ratio is preserved. The image is scaled to the maximum possible size that + /// fits within the bounds. Fit, + /// The image's aspect ratio is preserved. The image is scaled to the maximum possible size that + /// fits within the larger (relative to aspect ratio) of the bounds, then cropped to fit within + /// the other bound. Crop, } #[derive(Debug)] pub(crate) struct ImageDetails { + /// image filename without path and extension pub(crate) stem: String, pub(crate) format: ImageFormat, pub(crate) path: Path, diff --git a/src/storage.rs b/src/storage.rs index 4ecc61f..1613aaf 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -7,6 +7,10 @@ use crate::Error::NotSupported; use crate::{ImageThumbs, ThumbsResult}; impl ImageThumbs { + /// returns options for an [`object_store`] client that maps the file extensions `.jpeg`, + /// `.jpg`, and `.png` to its MIME types. + /// + /// Allows `http` connections in case of tests pub(crate) fn client_options() -> ClientOptions { #[allow(unused_mut)] let mut client_options = ClientOptions::new() @@ -60,7 +64,7 @@ impl ImageThumbs { }) } - pub(crate) fn extract_stem(path: &Path) -> ThumbsResult<&str> { + fn extract_stem(path: &Path) -> ThumbsResult<&str> { let (stem, _) = path .filename() .ok_or(NotSupported)?