1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#![feature( debug_closure_helpers, const_trait_impl, generic_assert, deref_patterns, generic_const_exprs, impl_trait_in_bindings, import_trait_associated_functions )] #![allow(incomplete_features)] pub mod colors; mod keyboard; pub mod term; #[cfg(target_family = "unix")] pub fn read(fd: std::os::fd::BorrowedFd) -> Option<Vec<u8>> { let mut x = [0; 1 << 16]; let n = nix::unistd::read(fd, &mut x).ok()?; Some(x[..n].to_vec()) } #[cfg(target_family = "unix")] pub fn write(fd: std::os::fd::BorrowedFd, x: &[u8]) -> anyhow::Result<()> { let n = nix::unistd::write(fd, x)?; anyhow::ensure!(n == x.len()); Ok(()) }