joydev_rs/result.rs
1use crate::Error;
2use nix::errno::{Errno, ErrnoSentinel};
3use std::result;
4
5/// Joydev Result type
6pub type Result<T> = result::Result<T, Error>;
7
8pub(crate) fn convert_ioctl_result<S: ErrnoSentinel + PartialEq<S>>(value: S) -> Result<S> {
9 if value == S::sentinel() {
10 Err(Error::Sys(Errno::last()))
11 } else {
12 Ok(value)
13 }
14}