autd3_core/modulation/
error.rs1use 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)]
10pub struct ModulationError {
12 msg: String,
13}
14
15impl ModulationError {
16 #[must_use]
18 pub fn new(msg: impl ToString) -> Self {
19 Self {
20 msg: msg.to_string(),
21 }
22 }
23}
24
25impl 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