From a826c589dfc10c542deba7ca3343a462e02d6bde Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 19:10:56 -0400 Subject: [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 --- rust/src/worker_thread.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rust/src/worker_thread.rs') 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(name: S, f: F) { +pub fn execute_on_worker_thread(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(name: S, } } -pub fn execute_on_worker_thread_priority(name: S, f: F) { +pub fn execute_on_worker_thread_priority(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( } } -pub fn execute_on_worker_thread_interactive(name: S, f: F) { +pub fn execute_on_worker_thread_interactive(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, -- cgit v1.3.1