conspire 0.7.0

The Rust interface to conspire.
Documentation
pub mod abaqus;
#[cfg(feature = "netcdf")]
pub mod exodus;
pub mod medit;
pub mod vtu;

pub use self::abaqus::ReadAbaqus;
#[cfg(feature = "netcdf")]
pub use self::exodus::ReadExodus;
pub use self::medit::ReadMedit;
pub use self::vtu::ReadVtu;

use crate::geometry::mesh::Mesh;
use std::{io::Error as ErrorIO, path::Path};

pub enum Input<P>
where
    P: AsRef<Path>,
{
    Abaqus(P),
    #[cfg(feature = "netcdf")]
    Exodus(P),
    Medit(P),
    Vtu(P),
}

impl<P> AsRef<Path> for Input<P>
where
    P: AsRef<Path>,
{
    fn as_ref(&self) -> &Path {
        match self {
            Input::Abaqus(path) => path.as_ref(),
            #[cfg(feature = "netcdf")]
            Input::Exodus(path) => path.as_ref(),
            Input::Medit(path) => path.as_ref(),
            Input::Vtu(path) => path.as_ref(),
        }
    }
}

impl<const D: usize, P> TryFrom<Input<P>> for Mesh<D>
where
    P: AsRef<Path>,
{
    type Error = ErrorIO;
    fn try_from(input: Input<P>) -> Result<Self, Self::Error> {
        match input {
            Input::Abaqus(path) => Ok(Mesh::read_abaqus(path)?),
            #[cfg(feature = "netcdf")]
            Input::Exodus(path) => Ok(Mesh::read_exodus(path)?),
            Input::Medit(path) => Ok(Mesh::read_medit(path)?),
            Input::Vtu(path) => Ok(Mesh::read_vtu(path)?),
        }
    }
}