cfile/
lib.rs

1//! Rust bindings to C *FILE stream
2//!
3//! # Examples
4//!
5//! ```
6//! use std::io::prelude::*;
7//! use std::io::{BufReader, SeekFrom};
8//!
9//! use cfile;
10//!
11//! // open a tempfile
12//! let mut f = cfile::tmpfile().unwrap();
13//!
14//! // write something to the stream
15//! assert_eq!(f.write(b"test").unwrap(), 4);
16//!
17//! // force to flush the stream
18//! f.flush().unwrap();
19//!
20//! // seek to the beginning of stream
21//! assert_eq!(f.seek(SeekFrom::Start(0)).unwrap(), 0);
22//!
23//! let mut r = BufReader::new(f);
24//! let mut s = String::new();
25//!
26//! // read back the text
27//! assert_eq!(r.read_line(&mut s).unwrap(), 4);
28//! assert_eq!(s, "test");
29//! ```
30#[macro_use]
31extern crate cfg_if;
32
33#[doc(hidden)]
34pub extern crate foreign_types;
35
36mod cfile;
37mod iter;
38mod stream;
39
40cfg_if! {
41    if #[cfg(any(target_os = "linux", feature = "doc"))] {
42        mod lock;
43        pub mod unlocked;
44
45        pub use crate::lock::FileLock;
46    }
47}
48
49pub use crate::cfile::{fdopen, open, stderr, stdin, stdout, tmpfile, CFile, CFileRef};
50pub use crate::iter::{Bytes, Lines};
51pub use crate::stream::{AsStream, IntoStream, Stream};