autd3_core/modulation/
error.rs1use core::convert::Infallible;
2
3use alloc::string::{String, ToString};
4use thiserror::Error;
5
6use crate::firmware::SamplingConfigError;
7
8#[derive(Error, Debug, PartialEq, Clone)]
9#[error("{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