1use core::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub struct CFError {
6 operation: &'static str,
7}
8
9impl CFError {
10 #[must_use]
12 pub const fn new(operation: &'static str) -> Self {
13 Self { operation }
14 }
15
16 #[must_use]
18 pub const fn operation(&self) -> &'static str {
19 self.operation
20 }
21}
22
23impl fmt::Display for CFError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 write!(
26 f,
27 "{} returned a null Core Foundation/Core Graphics pointer",
28 self.operation
29 )
30 }
31}
32
33impl std::error::Error for CFError {}