joydev/
result.rs

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