mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Update NAPI-RS to v3
This commit is contained in:
@@ -278,7 +278,7 @@ impl From<Vertex> for libloot::Vertex {
|
||||
}
|
||||
|
||||
#[napi]
|
||||
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub enum EdgeType {
|
||||
Hardcoded,
|
||||
MasterFlag,
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ use napi_derive::napi;
|
||||
use crate::{database::Database, error::VerboseError, plugin::Plugin};
|
||||
|
||||
#[napi]
|
||||
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub enum GameType {
|
||||
Oblivion,
|
||||
Skyrim,
|
||||
|
||||
+5
-20
@@ -12,10 +12,7 @@ mod game;
|
||||
mod metadata;
|
||||
mod plugin;
|
||||
|
||||
use napi::{
|
||||
threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode},
|
||||
Either,
|
||||
};
|
||||
use napi::threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode};
|
||||
use napi_derive::napi;
|
||||
|
||||
pub use metadata::select_message_content;
|
||||
@@ -45,7 +42,7 @@ pub const LIBLOOT_VERSION_MINOR: u32 = libloot::LIBLOOT_VERSION_MINOR;
|
||||
pub const LIBLOOT_VERSION_PATCH: u32 = libloot::LIBLOOT_VERSION_PATCH;
|
||||
|
||||
#[napi]
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub enum LogLevel {
|
||||
Trace,
|
||||
Debug,
|
||||
@@ -84,22 +81,10 @@ pub fn set_log_level(level: LogLevel) {
|
||||
}
|
||||
|
||||
#[napi(ts_args_type = "callback: (logLevel: LogLevel, message: string) => void")]
|
||||
pub fn set_logging_callback(callback: napi::JsFunction) -> napi::Result<()> {
|
||||
let thread_safe_callback: ThreadsafeFunction<
|
||||
(libloot::LogLevel, String),
|
||||
ErrorStrategy::Fatal,
|
||||
> = callback.create_threadsafe_function(0, |ctx| {
|
||||
let (level, message): (libloot::LogLevel, String) = ctx.value;
|
||||
|
||||
Ok(vec![
|
||||
Either::A::<LogLevel, _>(level.into()),
|
||||
Either::B(message),
|
||||
])
|
||||
})?;
|
||||
|
||||
pub fn set_logging_callback(callback: ThreadsafeFunction<(LogLevel, String)>) -> napi::Result<()> {
|
||||
let rust_callback = move |level: libloot::LogLevel, message: &str| {
|
||||
thread_safe_callback.call(
|
||||
(level, message.to_owned()),
|
||||
callback.call(
|
||||
Ok((LogLevel::from(level), message.to_owned())),
|
||||
ThreadsafeFunctionCallMode::Blocking,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ pub fn select_message_content(
|
||||
}
|
||||
|
||||
#[napi]
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub enum MessageType {
|
||||
Say,
|
||||
Warn,
|
||||
@@ -384,7 +384,7 @@ impl From<PluginCleaningData> for libloot::metadata::PluginCleaningData {
|
||||
}
|
||||
|
||||
#[napi]
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub enum TagSuggestion {
|
||||
Addition,
|
||||
Removal,
|
||||
|
||||
Reference in New Issue
Block a user