sysctl/
ctl_error.rs
1use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum SysctlError {
6 #[error("no such sysctl: {0}")]
7 NotFound(String),
8
9 #[error("no matching type for value")]
10 #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "visionos")))]
11 UnknownType,
12
13 #[error("Error extracting value")]
14 ExtractionError,
15
16 #[error("Error parsing value")]
17 ParseError,
18
19 #[error("Support for type not implemented")]
20 MissingImplementation,
21
22 #[error("IO Error: {0}")]
23 IoError(#[from] std::io::Error),
24
25 #[error("Error parsing UTF-8 data: {0}")]
26 Utf8Error(#[from] std::str::Utf8Error),
27
28 #[error("Value is not readable")]
29 NoReadAccess,
30
31 #[error("Value is not writeable")]
32 NoWriteAccess,
33
34 #[error("Not supported by this platform")]
35 NotSupported,
36
37 #[error(
38 "sysctl returned a short read: read {read} bytes, while a size of {reported} was reported"
39 )]
40 ShortRead { read: usize, reported: usize },
41
42 #[error("Error reading C String: String was not NUL-terminated.")]
43 InvalidCStr(#[from] std::ffi::FromBytesWithNulError),
44
45 #[error("Error Rust string contains nul bytes")]
46 InvalidCString(#[from] std::ffi::NulError),
47}