SignalData parsing pt.1 - tb squashed
This commit is contained in:
41
src/main.rs
41
src/main.rs
@@ -50,3 +50,44 @@ 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)\"")
|
||||
}
|
||||
|
||||
/// Holds fully processed signal data already parsed from the .dat file, ready
|
||||
/// to be outputted in a practical way
|
||||
#[derive(Debug, Clone)]
|
||||
struct SignalData {
|
||||
name: String,
|
||||
values: Vec<f64>,
|
||||
unit: String
|
||||
}
|
||||
|
||||
impl SignalData {
|
||||
/// Creates a [`SignalData`](crate::SignalData) with a name and an empty
|
||||
/// `values` vector and `unit` string.
|
||||
///
|
||||
/// The `values` vector is initialized with no capacity, which causes this
|
||||
/// struct to be quite a bit slower. This method is thus not suggested, use
|
||||
/// [`SignalData::with_name_and_capacity`](crate::SignalData::with_name_and_capacity)
|
||||
/// when you know how much you want to allocate
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `name` - The name of the Signal
|
||||
pub fn with_name(name: String) -> SignalData {
|
||||
SignalData { name: name, values: vec![], unit: String::new() }
|
||||
}
|
||||
|
||||
/// Creates a [`SignalData`](crate::SignalData) with a name and a
|
||||
/// `values` vector of a certain capacity and an empty `unit` string.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `name` - The name of the Signal
|
||||
/// * `capacity` - The capacity with which the `values` vector will be
|
||||
/// initialized
|
||||
pub fn with_name_and_capacity(name: String, capacity: usize) -> SignalData {
|
||||
SignalData { name: name, values: Vec::with_capacity(capacity), unit: String::new() }
|
||||
}
|
||||
}
|
||||
|
||||
fn get_signal_data() -> SignalData {
|
||||
todo!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user