Add constructor

This commit is contained in:
Adrian Woźniak 2023-04-13 11:35:10 +02:00
parent c0f0f4d3ec
commit ee8a6a913d

View File

@ -66,7 +66,13 @@ pub trait ReadCredential {
#[derive(Debug)] #[derive(Debug)]
pub struct ReadCredDir<R: ReadEnv = EnvPath>(R); pub struct ReadCredDir<R: ReadEnv = EnvPath>(R);
impl<R: ReadEnv> ReadCredential for ReadCredDir<R> { impl<R: ReadEnv> ReadCredDir<R> {
pub fn new(env_reader: R) -> Self {
Self(env_reader)
}
}
impl<R: ReadEnv> ReadCredential for ReadCredDir<R> {
fn read_credential(&self, name: &str) -> Result<Option<String>> { fn read_credential(&self, name: &str) -> Result<Option<String>> {
let credentials_dir = self.0.read_env(CREDENTIALS_DIRECTORY); let credentials_dir = self.0.read_env(CREDENTIALS_DIRECTORY);
let Ok(creds_dir) = credentials_dir.map(PathBuf::from) else { let Ok(creds_dir) = credentials_dir.map(PathBuf::from) else {