Skip to content

Commit

Permalink
Allow library users to provide configuration directly
Browse files Browse the repository at this point in the history
  • Loading branch information
pohlm01 committed Feb 15, 2024
1 parent 08ff8f7 commit a7ad674
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "image_thumbs"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
repository = "https://github.com/tweedegolf/image-thumbs"
keywords = ["GCS", "image", "thumbnails"]
Expand Down
9 changes: 9 additions & 0 deletions src/gcs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use object_store::gcp::{GoogleCloudStorage, GoogleCloudStorageBuilder};

use crate::model::Params;
use crate::{ImageThumbs, ThumbsResult};

impl ImageThumbs<GoogleCloudStorage> {
Expand All @@ -26,4 +27,12 @@ impl ImageThumbs<GoogleCloudStorage> {
settings: Self::settings(config)?,
})
}

pub async fn new_with_settings(settings: Vec<Params>) -> ThumbsResult<Self> {
let client = GoogleCloudStorageBuilder::from_env()
.with_client_options(Self::client_options())
.build()?;

Ok(Self { client, settings })
}
}
2 changes: 1 addition & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct ImageThumbs<T> {
}

#[derive(Deserialize, Debug, Clone)]
pub(crate) struct Params {
pub struct Params {
/// Can be used as `{thumb_name}` in the `naming_pattern`.
/// If the naming_pattern is not explicitly given, the default is
/// "`/{thumb_name}/{image_name}.{image_extension}`"
Expand Down

0 comments on commit a7ad674

Please sign in to comment.