SignalData parsing pt.1 - tb squashed

This commit is contained in:
Misha Vicha
2025-10-01 14:24:25 +02:00
parent 2becccd064
commit cf57876e67

View File

@@ -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!()
}