tokio-fs-ext 0.2.0

Extend tokio fs to be compatible with native and wasm
Documentation
use std::{io, path::Path};

use futures::io::AsyncSeekExt;

use crate::fs::OpenOptions;

pub async fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> io::Result<()> {
    let mut file = OpenOptions::new()
        .create(true)
        .truncate(true)
        .write(true)
        .open(path)
        .await?;

    file.seek(io::SeekFrom::Start(0)).await?;

    file.write_with_buf(contents.as_ref())?;

    Ok(())
}