conspire/geometry/ntree/write/
mod.rs1use crate::geometry::ntree::node::cell::Cell;
2use crate::geometry::ntree::node::slot::Slot;
3pub(super) mod htg;
4
5use crate::{
6 geometry::ntree::Orthotree,
7 io::{Write, write::Compression},
8};
9use std::{io::Error as ErrorIO, path::Path};
10
11use htg::WriteHtg;
12
13pub enum Output<P>
14where
15 P: AsRef<Path>,
16{
17 Htg(Compression<P>),
18}
19
20impl<P> AsRef<Path> for Output<P>
21where
22 P: AsRef<Path>,
23{
24 fn as_ref(&self) -> &Path {
25 match self {
26 Output::Htg(htg) => htg.as_ref(),
27 }
28 }
29}
30
31impl<const D: usize, const L: usize, const M: usize, const N: usize, T, U, P> Write<Output<P>>
32 for Orthotree<D, L, M, N, T, U>
33where
34 P: AsRef<Path>,
35 T: Cell,
36 U: Slot,
37{
38 type Error = ErrorIO;
39 fn write(&self, output: Output<P>) -> Result<(), Self::Error> {
40 match output {
41 Output::Htg(Compression::On(path)) => self.write_htg_compressed(path)?,
42 Output::Htg(Compression::Off(path)) => self.write_htg(path)?,
43 }
44 Ok(())
45 }
46}