47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
use std::{env::{self}, io::Error, path::Path};
|
|
use std::fs;
|
|
|
|
pub mod headparse; // The HEAder parsing
|
|
|
|
/// Use for handling possible formats of the WFDB data
|
|
#[derive(Debug, Clone, Copy)]
|
|
enum SignalFormat {
|
|
Format16 = 16,
|
|
Format212 = 212,
|
|
Unimpl = 0
|
|
}
|
|
|
|
fn main() -> Result<(), Error>{
|
|
let args: Vec<String> = env::args().collect();
|
|
|
|
if args.len() <= 1 || args.contains(&"help".to_string()) {
|
|
help();
|
|
return Ok(());
|
|
}
|
|
|
|
let filepath = Path::new(&args[1]);
|
|
if !filepath.is_file() {
|
|
println!("Path argument provided is not a valid file");
|
|
return Ok(());
|
|
}
|
|
if filepath.extension().unwrap() != "hea" {
|
|
println!("File provided is not a .hea file");
|
|
return Ok(());
|
|
}
|
|
|
|
let hea_file_result = fs::read_to_string(filepath);
|
|
match hea_file_result {
|
|
Ok(file_data) => {
|
|
let header = headparse::parse_header(file_data.as_str());
|
|
dbg!(header);
|
|
}
|
|
Err(e) => return Err(e)
|
|
}
|
|
println!("Hello, world!");
|
|
Ok(())
|
|
}
|
|
|
|
fn help() {
|
|
println!("Conversion of WFDB files to a more human readable format. By default to a CSV.");
|
|
println!("\nUse in the format \"wfdb_corrosion (.hea filename)\"")
|
|
} |