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