-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use image::ImageError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error("Storage error: {0}")] | ||
Storage(#[from] object_store::Error), | ||
#[error("Invalid path: {0}")] | ||
Path(#[from] object_store::path::Error), | ||
#[error("Configuration error: {0}")] | ||
Config(#[from] config::ConfigError), | ||
#[error("Image error: {0}")] | ||
Image(#[from] ImageError), | ||
#[error("Image format not supported")] | ||
NotSupported, | ||
#[error("Utf-8 error")] | ||
Utf, | ||
} | ||
|
||
pub type ThumbsResult<T> = Result<T, Error>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use image::ImageFormat; | ||
use object_store::path::Path; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug)] | ||
pub struct ImageThumbs<T> { | ||
pub(crate) client: T, | ||
pub(crate) settings: Vec<Params>, | ||
} | ||
|
||
#[derive(Deserialize, Debug, Clone)] | ||
pub(crate) struct Params { | ||
pub(crate) name: String, | ||
pub(crate) quality: u8, | ||
pub(crate) size: (u32, u32), | ||
pub(crate) mode: Mode, | ||
} | ||
|
||
#[derive(Deserialize, Debug, Clone)] | ||
#[serde(rename_all = "snake_case")] | ||
pub(crate) enum Mode { | ||
Fit, | ||
Crop, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct ImageDetails { | ||
pub(crate) stem: String, | ||
pub(crate) format: ImageFormat, | ||
pub(crate) path: Path, | ||
pub(crate) bytes: Vec<u8>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters