respeaker 0.3.0

USB control library for Seeed ReSpeaker Mic Array v2.0 and XVF3800 (LEDs + DSP tuning), with reSpeaker Lite identification
Documentation
/// Supported ReSpeaker hardware models.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Model {
    /// Mic Array v2.0 (XVF-3000), USB `2886:0018`.
    MicArrayV2,
    /// reSpeaker XVF3800 USB 4-Mic Array, USB `2886:001a`.
    Xvf3800,
    /// reSpeaker Lite (XMOS XU316), USB `2886:0019`. Audio + DFU only —
    /// no USB control protocol, see [`crate::lite`].
    Lite,
}

impl Model {
    pub const fn product_id(self) -> u16 {
        match self {
            Self::MicArrayV2 => crate::PRODUCT_ID_V2,
            Self::Xvf3800 => crate::PRODUCT_ID_XVF3800,
            Self::Lite => crate::PRODUCT_ID_LITE,
        }
    }

    pub const fn label(self) -> &'static str {
        match self {
            Self::MicArrayV2 => "ReSpeaker Mic Array v2.0 (XVF-3000)",
            Self::Xvf3800 => "reSpeaker XVF3800",
            Self::Lite => "reSpeaker Lite (XU316)",
        }
    }

    /// Whether the model answers vendor control transfers (LEDs, DoA, DSP
    /// parameters). `false` for [`Self::Lite`], whose USB firmware is audio +
    /// DFU only.
    pub const fn has_usb_control(self) -> bool {
        match self {
            Self::MicArrayV2 | Self::Xvf3800 => true,
            Self::Lite => false,
        }
    }
}

impl std::fmt::Display for Model {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.label())
    }
}