Skip to content
CryoCryo home

fd

import std::io::fd; · source

File descriptors

function read_fd(fd: i32, buffer: u8*, length: u64) -> Result<u64, IoError>;
function write_fd(fd: i32, bytes: Slice<u8>) -> Result<u64, IoError>;
function close_fd(fd: i32) -> void;

io::fd is the canonical home for the libc calls every fd-owning type needs, so wrappers import from here rather than re-declaring the same externs.

FunctionNotes
read_fd(fd, buffer, length)read(2), retrying on EINTR. Zero means EOF.
write_fd(fd, bytes)write(2), same retry semantics. Short writes are normal.
close_fd(fd)close(2). Swallows the result — nothing sensible can be done with a close failure.

These handle the "retry on Interrupted, map everything else through IoError::from_errno" dance, which is what collapses most Read and Write implementations to a single line.