autd3_emulator/
error.rs

1use autd3::driver::{common::ULTRASOUND_PERIOD, error::AUTDDriverError};
2use autd3_core::sampling_config::SamplingConfigError;
3use thiserror::Error;
4
5/// An interface for error handling in autd3-emulator.
6#[derive(Error, Debug)]
7pub enum EmulatorError {
8    /// Error when the tick is not a multiple of the ultrasound period.
9    #[error("Tick must be multiple of {:?}", ULTRASOUND_PERIOD)]
10    InvalidTick,
11    /// Error when the duration is not a multiple of the ultrasound period.
12    #[error("Duration must be multiple of {:?}", ULTRASOUND_PERIOD)]
13    InvalidDuration,
14    /// Error when the time step is not a divisor of the ultrasound period.
15    #[error("Time step must divide {:?}", ULTRASOUND_PERIOD)]
16    InvalidTimeStep,
17    /// Error when requesting data outside the recorded range.
18    #[error("Not recorded")]
19    NotRecorded,
20    #[allow(missing_docs)]
21    #[error("{0}")]
22    SamplingConfig(#[from] SamplingConfigError),
23    #[allow(missing_docs)]
24    #[error("{0}")]
25    Driver(#[from] AUTDDriverError),
26    #[allow(missing_docs)]
27    #[cfg(feature = "gpu")]
28    #[error("{0}")]
29    RequestDeviceError(#[from] wgpu::RequestDeviceError),
30    #[allow(missing_docs)]
31    #[cfg(feature = "gpu")]
32    #[error("{0}")]
33    RecvError(#[from] flume::RecvError),
34    #[allow(missing_docs)]
35    #[cfg(feature = "gpu")]
36    #[error("{0}")]
37    BufferAsyncError(#[from] wgpu::BufferAsyncError),
38    #[allow(missing_docs)]
39    #[error("{0}")]
40    #[cfg(feature = "gpu")]
41    RequestAdapterError(#[from] wgpu::RequestAdapterError),
42    #[allow(missing_docs)]
43    #[error("{0}")]
44    #[cfg(feature = "gpu")]
45    PollError(#[from] wgpu::PollError),
46}