autd3_core/modulation/
error.rs

1use std::convert::Infallible;
2
3use derive_more::Display;
4use thiserror::Error;
5
6use crate::sampling_config::SamplingConfigError;
7
8#[derive(Error, Debug, Display, PartialEq, Clone)]
9#[display("{}", msg)]
10/// An error occurred during modulation calculation.
11pub struct ModulationError {
12    msg: String,
13}
14
15impl ModulationError {
16    /// Creates a new [`ModulationError`].
17    #[must_use]
18    pub fn new(msg: impl ToString) -> Self {
19        Self {
20            msg: msg.to_string(),
21        }
22    }
23}
24
25// GRCOV_EXCL_START
26impl From<Infallible> for ModulationError {
27    fn from(_: Infallible) -> Self {
28        unreachable!()
29    }
30}
31
32impl From<SamplingConfigError> for ModulationError {
33    fn from(e: SamplingConfigError) -> Self {
34        Self::new(e)
35    }
36}
37// GRCOV_EXCL_STOP