tekhsi_rs 0.1.1

High-performance client for Tektronix TekHSI enabled oscilloscopes
Documentation
use smol_str::SmolStr;

use crate::data::Waveform;
use crate::errors::{AcquisitionError, DecodeError};
use crate::tekscope::WaveformHeader;

/// Result of fetching and decoding a single symbol.
///
/// ```rust
/// use tekhsi_rs::data::ChannelData;
/// use tekhsi_rs::errors::AcquisitionError;
/// use smol_str::SmolStr;
///
/// let data = ChannelData::AcquisitionError {
///     symbol: SmolStr::new("ch1"),
///     error: AcquisitionError::ChannelOff,
/// };
/// assert_eq!(data.symbol(), "ch1");
/// ```
#[derive(Debug)]
pub enum ChannelData {
    Waveform {
        acq_id: u64,
        symbol: SmolStr,
        header: WaveformHeader,
        waveform: Waveform,
    },
    DecodeError {
        symbol: SmolStr,
        header: WaveformHeader,
        error: DecodeError,
    },
    AcquisitionError {
        symbol: SmolStr,
        error: AcquisitionError,
    },
}

impl ChannelData {
    /// Returns the symbol name associated with this channel result.
    pub fn symbol(&self) -> &SmolStr {
        match self {
            ChannelData::Waveform { symbol, .. } => symbol,
            ChannelData::DecodeError { symbol, .. } => symbol,
            ChannelData::AcquisitionError { symbol, .. } => symbol,
        }
    }
}