pub fn read_file<T: AsPath + ?Sized>(path: &T) -> FsIOResult<Vec<u8>>
Expand description
Reads the requested file and returns its content.
§Arguments
path
- The file path
§Example
use crate::fsio::file;
use std::path::Path;
use std::str;
fn main() {
let file_path = "./target/__test/file_test/read_file/file.txt";
let mut result = file::write_file(file_path, "some content".as_bytes());
assert!(result.is_ok());
result = file::append_file(file_path, "\nmore content".as_bytes());
assert!(result.is_ok());
let data = file::read_file(file_path).unwrap();
assert_eq!(str::from_utf8(&data).unwrap(), "some content\nmore content");
}