blob: 08d73feb129e6a48b0423cef5a1ba51aca700b7f [file] [log] [blame]
extern crate libc;
use std::io;
pub use self::libc::termios as Termios;
pub mod attr;
pub mod size;
pub mod tty;
// Support functions for converting libc return values to io errors {
trait IsMinusOne {
fn is_minus_one(&self) -> bool;
}
macro_rules! impl_is_minus_one {
($($t:ident)*) => ($(impl IsMinusOne for $t {
fn is_minus_one(&self) -> bool {
*self == -1
}
})*)
}
impl_is_minus_one! { i8 i16 i32 i64 isize }
fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> {
if t.is_minus_one() {
Err(io::Error::last_os_error())
} else {
Ok(t)
}
}
// } End of support functions