quickjs-jit-stdlib 0.14.0

LLRT's standard modules for quickjs-jit, vendored into one crate
Documentation
// Vendored from LLRT d9fd873e793c (modules/llrt_fs/src/rename.rs); module paths and
// feature names adapted by scripts/import-stdlib.py.
use crate::utils::result::ResultExt;
use rquickjs::{Ctx, Result};

pub(crate) fn rename_error(from: &str, to: &str) -> String {
    [
        "Can't rename file/folder from \"",
        from,
        "\" to \"",
        to,
        "\"",
    ]
    .concat()
}

pub async fn rename(ctx: Ctx<'_>, old_path: String, new_path: String) -> Result<()> {
    tokio::fs::rename(&old_path, &new_path)
        .await
        .or_throw_msg(&ctx, &rename_error(&old_path, &new_path))?;
    Ok(())
}

pub fn rename_sync(ctx: Ctx<'_>, old_path: String, new_path: String) -> Result<()> {
    std::fs::rename(&old_path, &new_path)
        .or_throw_msg(&ctx, &rename_error(&old_path, &new_path))?;
    Ok(())
}