tokio_fs_ext/fs/wasm/
read.rs

1use std::{io, path::Path};
2
3use super::OpenOptions;
4
5pub async fn read(path: impl AsRef<Path>) -> io::Result<Vec<u8>> {
6    let mut file = OpenOptions::new().read(true).open(path).await?;
7
8    let file_size = file.size()?;
9
10    let mut buf = vec![0; file_size as usize];
11
12    file.read_to_buf(&mut buf)?;
13
14    Ok(buf)
15}