wrath 0.1.0

A structured approach to accessing environment variables
Documentation
//! Errors that can occur while parsing the environment

use std::{convert::Infallible, ffi::OsString};

/// An error parsing a type via the [`FromStr`](std::str::FromStr) trait
#[derive(Debug)]
pub enum FromStr<E> {
    /// Conversion from an [`OsString`] failed
    Convert(OsString),

    /// Parsing via [`FromStr`](std::str::FromStr) failed
    Parse(E),
}

/// Errors relating to environment variable values
#[derive(Debug)]
pub enum Value<U, P> {
    /// A value was required but none was given
    Unset(U),

    /// Parsing the given value failed
    Parse(P),
}

/// Types that indicate whether being unset is a possible error
pub trait Unset: sealed::Sealed {}

/// Being unset is an error
impl Unset for () {}

/// Being unset is not an error
impl Unset for Infallible {}

mod sealed {
    //! Sealed module

    use std::convert::Infallible;

    /// Sealed trait
    pub trait Sealed {}

    impl Sealed for () {}
    impl Sealed for Infallible {}
}