Improved naming of Header constructor
`from_record` is now called `with_record` as the library standard suggests
This commit is contained in:
@@ -410,7 +410,7 @@ impl Header {
|
|||||||
///
|
///
|
||||||
/// Initializes the signal_specs vector with the correct capacity provided
|
/// Initializes the signal_specs vector with the correct capacity provided
|
||||||
/// by the record.
|
/// by the record.
|
||||||
fn from_record(record: Record) -> Header {
|
fn with_record(record: Record) -> Header {
|
||||||
let capacity = record.signal_count;
|
let capacity = record.signal_count;
|
||||||
Header { record: Some(record), signal_specs: Vec::with_capacity(capacity) }
|
Header { record: Some(record), signal_specs: Vec::with_capacity(capacity) }
|
||||||
}
|
}
|
||||||
@@ -448,7 +448,7 @@ pub fn parse_header(header_data: &str) -> Result<Header, &str> {
|
|||||||
match possible_record {
|
match possible_record {
|
||||||
Ok(rec) => {
|
Ok(rec) => {
|
||||||
specs_max = rec.signal_count;
|
specs_max = rec.signal_count;
|
||||||
header = Header::from_record(rec);
|
header = Header::with_record(rec);
|
||||||
found_record = true;
|
found_record = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/main.rs
19
src/main.rs
@@ -1,6 +1,8 @@
|
|||||||
use std::{env::{self}, io::Error, path::Path};
|
use std::{env::{self}, io::Error, path::Path};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use crate::headparse::Header;
|
||||||
|
|
||||||
pub mod headparse; // The HEAder parsing
|
pub mod headparse; // The HEAder parsing
|
||||||
|
|
||||||
/// Use for handling possible formats of the WFDB data
|
/// Use for handling possible formats of the WFDB data
|
||||||
@@ -28,14 +30,17 @@ fn main() -> Result<(), Error>{
|
|||||||
println!("File provided is not a .hea file");
|
println!("File provided is not a .hea file");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
let hea_file_result = fs::read_to_string(filepath);
|
let hea_file_result = fs::read_to_string(filepath);
|
||||||
match hea_file_result {
|
match hea_file_result {
|
||||||
Ok(file_data) => {
|
Ok(file_data) => {
|
||||||
let header = headparse::parse_header(file_data.as_str());
|
let header = headparse::parse_header(file_data.as_str());
|
||||||
dbg!(header);
|
|
||||||
|
dbg!(header);
|
||||||
|
}
|
||||||
|
Err(e) => return Err(e)
|
||||||
}
|
}
|
||||||
Err(e) => return Err(e)
|
|
||||||
}
|
}
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -44,4 +49,4 @@ fn main() -> Result<(), Error>{
|
|||||||
fn help() {
|
fn help() {
|
||||||
println!("Conversion of WFDB files to a more human readable format. By default to a CSV.");
|
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)\"")
|
println!("\nUse in the format \"wfdb_corrosion (.hea filename)\"")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user