The purpose of this crate is to make it a bit more ergonomic for portable
applications that need to work with the platform level RawFd
and
RawHandle
types.
Rather than conditionally using RawFd
and RawHandle
, the FileDescriptor
type can be used to manage ownership, duplicate, read and write.
FileDescriptor
This is a bit of a contrived example, but demonstrates how to avoid
the conditional code that would otherwise be required to deal with
calling as_raw_fd
and as_raw_handle
:
use ;
use Fallible;
use Write;
Pipe
The Pipe
type makes it more convenient to create a pipe and manage
the lifetime of both the read and write ends of that pipe.
use Pipe;
use ;
use Error;
let mut pipe = new?;
pipe.write.write?;
drop;
let mut s = String new;
pipe.read.read_to_string?;
assert_eq!;
# Ok::