Skip to main content

trx_rs/io/
mod.rs

1mod archive_edit;
2pub mod directory;
3pub mod filename;
4pub mod zip;
5
6use std::path::Path;
7
8use crate::dtype::TrxScalar;
9use crate::error::{Result, TrxError};
10use crate::trx_file::TrxFile;
11
12/// Load a TRX file, auto-detecting format.
13///
14/// - If `path` is a directory, loads from the directory.
15/// - If `path` has a `.trx` extension (or is a file), loads from zip.
16pub fn load<P: TrxScalar>(path: &Path) -> Result<TrxFile<P>> {
17    if path.is_dir() {
18        directory::load_from_directory(path, None)
19    } else if path.is_file() {
20        zip::load_from_zip(path)
21    } else {
22        Err(TrxError::FileNotFound(path.to_path_buf()))
23    }
24}