Crates.io | ioctl-rs |
lib.rs | ioctl-rs |
version | 0.2.0 |
source | src |
created_at | 2015-05-27 03:40:30.042826 |
updated_at | 2017-12-04 02:03:21.213142 |
description | Rust bindings for system ioctls. |
homepage | https://github.com/dcuddeback/ioctl-rs |
repository | https://github.com/dcuddeback/ioctl-rs |
max_upload_size | |
id | 2230 |
size | 21,055 |
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()
.
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)
}
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.
Copyright © 2015 David Cuddeback
Distributed under the MIT License.