Skip to main content

conspire/geometry/ntree/read/
mod.rs

1pub mod htg;
2
3use crate::geometry::ntree::{Orthotree, node::split::Split};
4use std::{io::Error as ErrorIO, ops::Add, path::Path};
5
6use self::htg::ReadHtg;
7
8pub enum Input<P>
9where
10    P: AsRef<Path>,
11{
12    Htg(P),
13}
14
15impl<P> AsRef<Path> for Input<P>
16where
17    P: AsRef<Path>,
18{
19    fn as_ref(&self) -> &Path {
20        match self {
21            Input::Htg(path) => path.as_ref(),
22        }
23    }
24}
25
26impl<const D: usize, const L: usize, const M: usize, const N: usize, T, U, P> TryFrom<Input<P>>
27    for Orthotree<D, L, M, N, T, U>
28where
29    P: AsRef<Path>,
30    T: Add<Output = T> + Copy + Split + Into<usize> + TryFrom<usize>,
31    U: Copy + From<usize> + Into<usize>,
32{
33    type Error = ErrorIO;
34    fn try_from(input: Input<P>) -> Result<Self, Self::Error> {
35        match input {
36            Input::Htg(path) => Self::read_htg(path),
37        }
38    }
39}