Skip to content

Commit

Permalink
Add documentation for internal code where needed
Browse files Browse the repository at this point in the history
Related to #3
  • Loading branch information
pohlm01 committed Oct 16, 2023
1 parent 454a1e9 commit 3e49422
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ pub struct ImageThumbs<T> {

#[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,
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use crate::Error::NotSupported;
use crate::{ImageThumbs, ThumbsResult};

impl<T: ObjectStore> ImageThumbs<T> {
/// 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()
Expand Down Expand Up @@ -60,7 +64,7 @@ impl<T: ObjectStore> ImageThumbs<T> {
})
}

pub(crate) fn extract_stem(path: &Path) -> ThumbsResult<&str> {
fn extract_stem(path: &Path) -> ThumbsResult<&str> {
let (stem, _) = path
.filename()
.ok_or(NotSupported)?
Expand Down

0 comments on commit 3e49422

Please sign in to comment.