[][src]Function fungus::sys::readbytes

pub fn readbytes<T: AsRef<Path>>(path: T) -> Result<Vec<u8>>

Returns the contents of the path as a Vec<u8>.

Examples

use fungus::prelude::*;

let tmpdir = PathBuf::from("tests/temp").abs().unwrap().mash("file_doc_readbytes");
assert!(sys::remove_all(&tmpdir).is_ok());
let tmpfile = tmpdir.mash("file1");
assert!(sys::mkdir(&tmpdir).is_ok());
assert!(sys::write(&tmpfile, "this is a test").is_ok());
assert_eq!(str::from_utf8(&sys::readbytes(&tmpfile).unwrap()).unwrap(), "this is a test");
assert!(sys::remove_all(&tmpdir).is_ok());