audio_lab/signal/data/
mod.rs1pub use axis::XAxis;
2pub use complex_data::ComplexData;
3pub use real_data::RealData;
4
5mod axis;
6mod complex_data;
7mod real_data;
8
9#[derive(Debug, thiserror::Error)]
10pub enum DataError {
11 #[error("x data has not the same length as y data")]
12 NotMatching,
13 #[error("x data is not increasing")]
14 NotIncreasing,
15 #[error(
16 "uniform axis needs a finite start and a finite, positive step (start: {start}, step: {step})"
17 )]
18 InvalidUniformAxis { start: f64, step: f64 },
19 #[error("there are {labels} channel labels for {channels} channels")]
20 ChannelLabelMismatch { labels: usize, channels: usize },
21}
22
23#[cfg(feature = "serde")]
24fn check_channel_labels(labels: &[Option<String>], channels: usize) -> Result<(), DataError> {
25 if labels.len() == channels {
26 Ok(())
27 } else {
28 Err(DataError::ChannelLabelMismatch {
29 labels: labels.len(),
30 channels,
31 })
32 }
33}