mirror of
https://github.com/Drop-OSS/droplet.git
synced 2025-11-18 02:31:28 +10:00
async utils that might fix my problem
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@drop/droplet",
|
"name": "@drop/droplet",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"napi": {
|
"napi": {
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{BufRead, BufReader},
|
io::{BufRead, BufReader},
|
||||||
path::Path,
|
path::Path, thread,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
use gxhash::gxhash128;
|
use gxhash::gxhash128;
|
||||||
use napi::{Error, JsFunction, JsNumber};
|
use napi::{
|
||||||
|
threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode},
|
||||||
|
Error, JsFunction,
|
||||||
|
};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@ -26,6 +29,19 @@ struct Chunk {
|
|||||||
checksum: String,
|
checksum: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[napi]
|
||||||
|
pub fn call_alt_thread_func(callback: JsFunction) -> Result<(), Error> {
|
||||||
|
let tsfn: ThreadsafeFunction<u32, ErrorStrategy::CalleeHandled> = callback
|
||||||
|
.create_threadsafe_function(0, |ctx| {
|
||||||
|
ctx.env.create_uint32(ctx.value + 1).map(|v| vec![v])
|
||||||
|
})?;
|
||||||
|
let tsfn = tsfn.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
tsfn.call(Ok(0), ThreadsafeFunctionCallMode::Blocking);
|
||||||
|
});
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn generate_manifest(
|
pub fn generate_manifest(
|
||||||
dir: String,
|
dir: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user