[−][src]Crate cfile
Examples
use std::io::prelude::*; use std::io::{BufReader, SeekFrom}; use cfile; // open a tempfile let mut f = cfile::tmpfile().unwrap(); // write something to the stream assert_eq!(f.write(b"test").unwrap(), 4); // force to flush the stream f.flush().unwrap(); // seek to the beginning of stream assert_eq!(f.seek(SeekFrom::Start(0)).unwrap(), 0); let mut r = BufReader::new(f); let mut s = String::new(); // read back the text assert_eq!(r.read_line(&mut s).unwrap(), 4); assert_eq!(s, "test");
Modules
unlocked | Each of these functions has the same behavior as its counterpart without the "_unlocked" suffix, except that they do not use locking (they do not set locks themselves, and do not test for the presence of locks set by others) and hence are thread-unsafe. |
Structs
Bytes | An iterator over the bytes of a *FILE stream. |
CFile | A reference to an open stream on the filesystem. |
FileLock | A locked reference to the |
Lines | An iterator over the lines of a *FILE stream. |
Constants
STDERR_FILENO | |
STDIN_FILENO | |
STDOUT_FILENO |
Traits
IntoStream | A trait to express the ability to consume an object and acquire ownership of its stream. |
Stream | C *FILE stream |
ToStream | A trait for converting a raw fd to a C *FILE stream. |
Functions
fdopen | associates a stream with the existing file descriptor. |
open | |
stderr | open stderr as a write only stream |
stdin | open stdin as a read only stream |
stdout | open stdout as a write only stream |
tmpfile | open a temporary file as a read/write stream |