envman/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]
pub use envman_derive::EnvMan;

pub trait EnvMan {
    /// Load environment variables
    fn load() -> Result<Self, EnvManError>
    where
        Self: std::marker::Sized;
}

#[derive(thiserror::Error, Debug)]
/// Error type for [`EnvMan`]
pub enum EnvManError {
    #[error("failed to read environment variable of {key}")]
    /// Failed to read environment variable
    NotFound { key: String },
    /// Failed to parse environment variable
    /// I didn't include a value just in case.
    #[error("failed to parse environment variable of {key}")]
    Parse { key: String },
}