#![doc = include_str!("../README.md")]

mod error;
mod filter;
mod normalize;

use std::fmt::Display;
use std::str::FromStr;

use toml_edit::DocumentMut;

pub use error::Error;
pub use filter::DependencyFilter;

pub use cfg_expr;

/// Parsed TOML manifest
#[derive(Debug)]
pub struct Manifest {
    toml: DocumentMut,
}

impl FromStr for Manifest {
    type Err = toml_edit::TomlError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let toml: DocumentMut = s.parse()?;
        Ok(Manifest { toml })
    }
}

impl Display for Manifest {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.toml)
    }
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn smoke() {
        let _manifest: Manifest = include_str!("../Cargo.toml").parse().unwrap();
    }
}
