|
| 1 | +#![unstable(feature = "motor_ext", issue = "none")] |
| 2 | + |
| 3 | +use crate::sealed::Sealed; |
| 4 | +use crate::sys_common::AsInner; |
| 5 | + |
| 6 | +#[unstable(feature = "motor_ext", issue = "none")] |
| 7 | +pub fn map_motor_error(err: moto_rt::ErrorCode) -> crate::io::Error { |
| 8 | + use moto_rt::error::*; |
| 9 | + |
| 10 | + use crate::io::ErrorKind; |
| 11 | + |
| 12 | + let kind: ErrorKind = match err { |
| 13 | + E_ALREADY_IN_USE => ErrorKind::AlreadyExists, |
| 14 | + E_INVALID_FILENAME => ErrorKind::InvalidFilename, |
| 15 | + E_NOT_FOUND => ErrorKind::NotFound, |
| 16 | + E_TIMED_OUT => ErrorKind::TimedOut, |
| 17 | + E_NOT_IMPLEMENTED => ErrorKind::Unsupported, |
| 18 | + E_FILE_TOO_LARGE => ErrorKind::FileTooLarge, |
| 19 | + E_UNEXPECTED_EOF => ErrorKind::UnexpectedEof, |
| 20 | + E_INVALID_ARGUMENT => ErrorKind::InvalidInput, |
| 21 | + E_NOT_READY => ErrorKind::WouldBlock, |
| 22 | + E_NOT_CONNECTED => ErrorKind::NotConnected, |
| 23 | + _ => ErrorKind::Other, |
| 24 | + }; |
| 25 | + |
| 26 | + crate::io::Error::from(kind) |
| 27 | +} |
| 28 | + |
| 29 | +#[unstable(feature = "motor_ext", issue = "none")] |
| 30 | +pub trait ChildExt: Sealed { |
| 31 | + /// Extracts the main thread raw handle, without taking ownership |
| 32 | + #[unstable(feature = "motor_ext", issue = "none")] |
| 33 | + fn sys_handle(&self) -> u64; |
| 34 | +} |
| 35 | + |
| 36 | +#[unstable(feature = "motor_ext", issue = "none")] |
| 37 | +impl ChildExt for crate::process::Child { |
| 38 | + fn sys_handle(&self) -> u64 { |
| 39 | + self.as_inner().handle() |
| 40 | + } |
| 41 | +} |
0 commit comments