autd3_core/sampling_config/
error.rs

1use std::{convert::Infallible, time::Duration};
2
3use thiserror::Error;
4
5use crate::defined::Freq;
6
7#[derive(Error, Debug, PartialEq, Copy, Clone)]
8/// An error produced by the sampling configuration.
9pub enum SamplingConfigError {
10    /// Invalid sampling division.
11    #[error("Sampling division must not be zero")]
12    DivisionInvalid,
13    /// Invalid sampling frequency.
14    #[error("Sampling frequency ({0:?}) must divide the ultrasound frequency")]
15    FreqInvalid(Freq<u32>),
16    /// Invalid sampling frequency.
17    #[error("Sampling frequency ({0:?}) must divide the ultrasound frequency")]
18    FreqInvalidF(Freq<f32>),
19    /// Invalid sampling period.
20    #[error("Sampling period ({0:?}) must be a multiple of the ultrasound period")]
21    PeriodInvalid(Duration),
22    /// Sampling frequency is out of range.
23    #[error("Sampling frequency ({0:?}) is out of range ([{1:?}, {2:?}])")]
24    FreqOutOfRange(Freq<u32>, Freq<u32>, Freq<u32>),
25    /// Sampling frequency is out of range.
26    #[error("Sampling frequency ({0:?}) is out of range ([{1:?}, {2:?}])")]
27    FreqOutOfRangeF(Freq<f32>, Freq<f32>, Freq<f32>),
28    /// Sampling period is out of range.
29    #[error("Sampling period ({0:?}) is out of range ([{1:?}, {2:?}])")]
30    PeriodOutOfRange(Duration, Duration, Duration),
31}
32
33// GRCOV_EXCL_START
34impl From<Infallible> for SamplingConfigError {
35    fn from(_: Infallible) -> Self {
36        unreachable!()
37    }
38}
39// GRCOV_EXCL_STOP