From 24f907b59bba232b20a1038cc67770034bae6701 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sat, 2 Apr 2022 17:01:00 +0200 Subject: [PATCH] Add configuration for image size. --- source/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/lib.rs b/source/lib.rs index 0b85abf..abbd3d0 100644 --- a/source/lib.rs +++ b/source/lib.rs @@ -26,12 +26,14 @@ #[derive(Debug)] pub struct Generator { pub base_url: String, + pub image_size: Option, } impl Default for Generator { fn default() -> Self { Self { base_url: "www.gravatar.com".to_string(), + image_size: None, } } } @@ -80,4 +82,19 @@ impl Generator { ..self } } + + /// Configures the Generator to include a `s=` in the URL. + /// + /// ```rust + /// use gravatar_rs::Generator; + /// + /// // Get 128px images instead of the default 80px. + /// Generator::default().set_image_size(128); + /// ``` + pub fn set_image_size(self, image_size: i32) -> Self { + Self { + image_size: Some(image_size), + ..self + } + } }