cfile

Crates.iocfile
lib.rscfile
version0.5.1
sourcesrc
created_at2016-04-29 11:30:13.123569
updated_at2019-11-07 08:00:46.73993
descriptionRust bindings to C *FILE stream
homepage
repositoryhttps://github.com/flier/rust-cfile
max_upload_size
id4903
size42,805
Flier Lu (flier)

documentation

https://docs.rs/crate/cfile/

README

rust-cfile crates.io docs travis Build status dependency status

Rust bindings to C *FILE stream

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");
Commit count: 54

cargo fmt