diff --git a/src/bucket.rs b/src/bucket.rs index bbdf9d3..6e5a8d5 100644 --- a/src/bucket.rs +++ b/src/bucket.rs @@ -56,6 +56,7 @@ pub struct Bucket { } #[allow(dead_code)] +#[allow(clippy::assigning_clones)] // false-positive warnings impl Bucket { fn host_domain(&self) -> String { match self.host.domain() { diff --git a/src/credentials.rs b/src/credentials.rs index 3d552f3..2d1a238 100644 --- a/src/credentials.rs +++ b/src/credentials.rs @@ -5,7 +5,7 @@ use std::env; use std::fmt::{Debug, Formatter}; #[derive(Debug, Clone)] -pub struct AccessKeyId(String); +pub struct AccessKeyId(pub String); impl AsRef for AccessKeyId { fn as_ref(&self) -> &str { @@ -20,7 +20,7 @@ impl AccessKeyId { } #[derive(Clone)] -pub struct AccessKeySecret(String); +pub struct AccessKeySecret(pub String); impl Debug for AccessKeySecret { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { @@ -47,6 +47,16 @@ pub struct Credentials { } impl Credentials { + pub fn new(key: S, secret: S) -> Self + where + S: Into, + { + Self { + access_key_id: AccessKeyId(key.into()), + access_key_secret: AccessKeySecret(secret.into()), + } + } + pub fn try_from_env() -> Result { let access_key_id = env::var("S3_ACCESS_KEY_ID")?; let access_key_secret = env::var("S3_ACCESS_KEY_SECRET")?; diff --git a/src/lib.rs b/src/lib.rs index 2e8b94c..dba8eb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,9 +30,16 @@ mod types; /// S3 Region Wrapper #[derive(Debug, Clone)] -pub struct Region(String); +pub struct Region(pub String); impl Region { + pub fn new(region: S) -> Self + where + S: Into, + { + Self(region.into()) + } + pub fn try_from_env() -> Result { Ok(Self(env::var("S3_REGION")?)) }