owon_spe/operations/
iee4882.rs

1use crate::{Error, Operation};
2use std::borrow::Cow;
3
4pub(crate) struct Idn {}
5#[derive(Clone, Debug, Eq, PartialEq)]
6pub struct IdnOutput {
7    pub model: String,
8    pub serial: String,
9    pub fw: String,
10}
11
12impl Operation for Idn {
13    type Out = IdnOutput;
14
15    fn command(&self) -> Cow<'_, str> {
16        Cow::Borrowed("*IDN?")
17    }
18
19    fn parse_line(&self, line: &str) -> Result<Self::Out, Error> {
20        let mut parts = line.split(',');
21        let _vendor = parts.next().ok_or(Error::UnexpectedData)?;
22        let mut parts = parts.map(|d| d.to_owned());
23        Ok(IdnOutput {
24            model: parts.next().ok_or(Error::UnexpectedData)?,
25            serial: parts.next().ok_or(Error::UnexpectedData)?,
26            fw: parts.next().ok_or(Error::UnexpectedData)?,
27        })
28    }
29}