#![allow(dead_code)] use crate::error::S3Error; use std::env; use std::fmt::{Debug, Formatter}; #[derive(Debug, Clone)] pub struct AccessKeyId(String); impl AsRef for AccessKeyId { fn as_ref(&self) -> &str { self.0.as_str() } } impl AccessKeyId { pub fn new(access_key_id: String) -> Self { Self(access_key_id) } } #[derive(Clone)] pub struct AccessKeySecret(String); impl Debug for AccessKeySecret { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "AccessKeySecret()") } } impl AsRef for AccessKeySecret { fn as_ref(&self) -> &str { self.0.as_str() } } impl AccessKeySecret { pub fn new(access_key_secret: String) -> Self { Self(access_key_secret) } } #[derive(Debug, Clone)] pub struct Credentials { pub access_key_id: AccessKeyId, pub access_key_secret: AccessKeySecret, } impl Credentials { 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")?; Ok(Self { access_key_id: AccessKeyId(access_key_id), access_key_secret: AccessKeySecret(access_key_secret), }) } }