tokio_fs_ext/fs/wasm/copy.rs
1use std::{io, path::Path};
2
3use super::{read, write};
4
5pub async fn copy(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<u64, io::Error> {
6 if from.as_ref() == to.as_ref() {
7 return Ok(0);
8 }
9 let contents = read(from).await?;
10 write(to, &contents).await?;
11 Ok(contents.len() as u64)
12}