8 releases

Uses old Rust 2015

0.2.0 Dec 4, 2017
0.1.6 Nov 20, 2017
0.1.5 Jan 27, 2016
0.1.4 Nov 5, 2015
0.1.0 May 27, 2015

#473 in Unix APIs

Download history 12371/week @ 2024-07-20 10183/week @ 2024-07-27 10415/week @ 2024-08-03 11968/week @ 2024-08-10 12518/week @ 2024-08-17 18205/week @ 2024-08-24 24866/week @ 2024-08-31 32523/week @ 2024-09-07 38388/week @ 2024-09-14 41243/week @ 2024-09-21 31868/week @ 2024-09-28 10417/week @ 2024-10-05 11317/week @ 2024-10-12 12462/week @ 2024-10-19 12806/week @ 2024-10-26 13498/week @ 2024-11-02

51,624 downloads per month
Used in 211 crates (5 directly)

MIT license

20KB
412 lines

IOCTL

The ioctl-rs crate provides raw definitions as well as safe bindings for system ioctl calls on Unix operating systems. The ioctl constants, e.g., TIOCEXCL, are exported as constants that are usable with the unsafe ioctl() function. Wrapper functions are provided for some ioctls that handle input and output parameters and convert return values to io::Result. The wrapper functions are named after the ioctl that they implement. For example, TIOCEXCL is implemented in a wrapper function named tiocexcl().

Usage

Add ioctl-rs as a dependency in Cargo.toml:

[dependencies]
ioctl-rs = "0.2"

Import the ioctl_rs crate. You may also need std::os::unix::io::RawFd for file descriptors and std::io::Result to propagate errors.

extern crate ioctl_rs as ioctl;

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

fn setup_serial_port(fd: RawFd) -> io::Result<()> {
    // put file descriptor in exclusive mode
    try!(ioctl::tiocexcl(fd));

    // clear all the modem pins
    ioctl::tiocmset(fd, 0)
}

Contributing

This repository includes a C++ program called ioctl_list, which generates Rust definitions for ioctl constants. To contribute ioctl definitions for a new platform or to add new ioctl definitions, please follow the instructions in the ioctl_list README.

Contributors

License

Copyright © 2015 David Cuddeback

Distributed under the MIT License.

Dependencies

~44KB