dope_core/error.rs
1use std::io;
2
3fn feature_errno(errno: Option<i32>) -> bool {
4 matches!(
5 errno,
6 Some(libc::ENOPROTOOPT)
7 | Some(libc::EOPNOTSUPP)
8 | Some(libc::EINVAL)
9 | Some(libc::EPERM)
10 | Some(libc::EACCES)
11 )
12}
13
14pub fn feature_error(err: io::Error, label: &'static str) -> io::Error {
15 if feature_errno(err.raw_os_error()) {
16 io::Error::new(io::ErrorKind::Unsupported, label)
17 } else {
18 err
19 }
20}