toasty_core/error/
driver_operation_failed.rs1use super::Error;
2
3#[derive(Debug)]
12pub(super) struct DriverOperationFailed {
13 pub(super) inner: Box<dyn std::error::Error + Send + Sync>,
14}
15
16impl std::error::Error for DriverOperationFailed {
17 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
18 Some(self.inner.as_ref())
19 }
20}
21
22impl core::fmt::Display for DriverOperationFailed {
23 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
24 core::fmt::Display::fmt(&self.inner, f)?;
26 let mut source = self.inner.source();
27 while let Some(err) = source {
28 write!(f, ": {}", err)?;
29 source = err.source();
30 }
31 Ok(())
32 }
33}
34
35impl Error {
36 pub fn driver_operation_failed(err: impl std::error::Error + Send + Sync + 'static) -> Error {
41 Error::from(super::ErrorKind::DriverOperationFailed(
42 DriverOperationFailed {
43 inner: Box::new(err),
44 },
45 ))
46 }
47
48 pub fn is_driver_operation_failed(&self) -> bool {
50 matches!(self.kind(), super::ErrorKind::DriverOperationFailed(_))
51 }
52}