Termios Rust Bindings

Documentation

The termios crate provides safe bindings for the Rust programming language to the terminal I/O interface implemented by Unix operating systems. The safe bindings are a small wrapper around the raw C functions, which converts integer return values to std::io::Result to indicate success or failure.

Dependencies

In order to use the termios crate, you must have a native libc library that implements the termios API. This should be available on any Unix operating system.

Usage

Add termios as a dependency in Cargo.toml:

toml [dependencies] termios = "0.1.0"

Import the termios crate and any symbols needed from termios. You may also need std::os::unix::io::RawFd for file descriptors and std::io::Result to propagate errors.

```rust extern crate termios;

use std::io; use std::os::unix::io::RawFd;

use termios::*;

fn setupfd(fd: RawFd) -> io::Result<()> { let mut termios = try!(Termios::fromfd(fd));

termios.ciflag = IGNPAR | IGNBRK; termios.coflag = 0; termios.ccflag = CS8 | CREAD | CLOCAL; termios.clflag = 0;

try!(cfsetspeed(&mut termios, B9600)); try!(tcsetattr(fd, TCSANOW, &termios)); try!(tcflush(fd, TCIOFLUSH));

Ok(()) } ```

Contributors

License

Copyright © 2015 David Cuddeback

Distributed under the MIT License.