summaryrefslogtreecommitdiff
path: root/rust/src/worker_thread.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-04 19:10:56 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commita826c589dfc10c542deba7ca3343a462e02d6bde (patch)
treef116254bef39f787268bbecc5eac19da310db9ce /rust/src/worker_thread.rs
parent28b3c4044af06fdc32c9c85bf8381b5058306427 (diff)
[Rust] Simplify `BnStrCompatible` trait
Followup to https://github.com/Vector35/binaryninja-api/pull/5897/ This simplifies usage of the trait in user code, should just be able to `to_cstr` to get the cstr repr and then call `as_ptr`. Co-authored-by: Michael Krasnitski <michael.krasnitski@gmail.com>
Diffstat (limited to 'rust/src/worker_thread.rs')
-rw-r--r--rust/src/worker_thread.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/rust/src/worker_thread.rs b/rust/src/worker_thread.rs
index 349456e5..aed872de 100644
--- a/rust/src/worker_thread.rs
+++ b/rust/src/worker_thread.rs
@@ -1,4 +1,4 @@
-use crate::string::BnStrCompatible;
+use crate::string::AsCStr;
use binaryninjacore_sys::*;
use std::ffi::{c_char, c_void};
@@ -17,10 +17,10 @@ impl WorkerThreadActionExecutor {
}
}
-pub fn execute_on_worker_thread<F: Fn() + 'static, S: BnStrCompatible>(name: S, f: F) {
+pub fn execute_on_worker_thread<F: Fn() + 'static, S: AsCStr>(name: S, f: F) {
let boxed_executor = Box::new(WorkerThreadActionExecutor { func: Box::new(f) });
let raw_executor = Box::into_raw(boxed_executor);
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
unsafe {
BNWorkerEnqueueNamed(
raw_executor as *mut c_void,
@@ -30,10 +30,10 @@ pub fn execute_on_worker_thread<F: Fn() + 'static, S: BnStrCompatible>(name: S,
}
}
-pub fn execute_on_worker_thread_priority<F: Fn() + 'static, S: BnStrCompatible>(name: S, f: F) {
+pub fn execute_on_worker_thread_priority<F: Fn() + 'static, S: AsCStr>(name: S, f: F) {
let boxed_executor = Box::new(WorkerThreadActionExecutor { func: Box::new(f) });
let raw_executor = Box::into_raw(boxed_executor);
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
unsafe {
BNWorkerPriorityEnqueueNamed(
raw_executor as *mut c_void,
@@ -43,10 +43,10 @@ pub fn execute_on_worker_thread_priority<F: Fn() + 'static, S: BnStrCompatible>(
}
}
-pub fn execute_on_worker_thread_interactive<F: Fn() + 'static, S: BnStrCompatible>(name: S, f: F) {
+pub fn execute_on_worker_thread_interactive<F: Fn() + 'static, S: AsCStr>(name: S, f: F) {
let boxed_executor = Box::new(WorkerThreadActionExecutor { func: Box::new(f) });
let raw_executor = Box::into_raw(boxed_executor);
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
unsafe {
BNWorkerInteractiveEnqueueNamed(
raw_executor as *mut c_void,