tokio-fs-ext 0.1.3

Extend tokio fs to be compatible with native and wasm
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::{io, path::Path};

use crate::fs::{read, write};

pub async fn copy(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<u64, io::Error> {
    if from.as_ref() == to.as_ref() {
        return Ok(0);
    }
    let contents = read(from).await?;
    write(to, &contents).await?;
    Ok(contents.len() as u64)
}