1use crate::{
2 Result,
3 Error,
4};
5
6#[derive(Debug, Clone, Copy)]
7pub enum EnvironmentVariable {
8 DailymotionClientId,
9 DailymotionClientSecret,
10}
11
12impl EnvironmentVariable {
13 #[must_use]
14 pub fn get_env_var_key(&self) -> &'static str {
15 match self {
16 Self::DailymotionClientId => "DAILYMOTION_CLIENT_ID",
17 Self::DailymotionClientSecret => "DAILYMOTION_CLIENT_SECRET",
18 }
19 }
20
21 pub fn get_value(&self) -> Result<String> {
26 std::env::var(self.get_env_var_key())
27 .map_err(|_| Error::MissingEnvironmentVariable(*self))
28 }
29}
30
31impl std::fmt::Display for EnvironmentVariable {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 f.write_str(self.get_env_var_key())
34 }
35}
36