summaryrefslogtreecommitdiff
path: root/rust/src/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/command.rs')
-rw-r--r--rust/src/command.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/rust/src/command.rs b/rust/src/command.rs
index 48a91164..0297d6cf 100644
--- a/rust/src/command.rs
+++ b/rust/src/command.rs
@@ -42,7 +42,7 @@ use std::os::raw::c_void;
use crate::binary_view::BinaryView;
use crate::function::Function;
-use crate::string::BnStrCompatible;
+use crate::string::AsCStr;
/// The trait required for generic commands. See [register_command] for example usage.
pub trait Command: 'static + Sync {
@@ -95,7 +95,7 @@ where
/// ```
pub fn register_command<S, C>(name: S, desc: S, command: C)
where
- S: BnStrCompatible,
+ S: AsCStr,
C: Command,
{
extern "C" fn cb_action<C>(ctxt: *mut c_void, view: *mut BNBinaryView)
@@ -126,8 +126,8 @@ where
})
}
- let name = name.into_bytes_with_nul();
- let desc = desc.into_bytes_with_nul();
+ let name = name.to_cstr();
+ let desc = desc.to_cstr();
let name_ptr = name.as_ref().as_ptr() as *mut _;
let desc_ptr = desc.as_ref().as_ptr() as *mut _;
@@ -196,7 +196,7 @@ where
/// ```
pub fn register_command_for_address<S, C>(name: S, desc: S, command: C)
where
- S: BnStrCompatible,
+ S: AsCStr,
C: AddressCommand,
{
extern "C" fn cb_action<C>(ctxt: *mut c_void, view: *mut BNBinaryView, addr: u64)
@@ -227,8 +227,8 @@ where
})
}
- let name = name.into_bytes_with_nul();
- let desc = desc.into_bytes_with_nul();
+ let name = name.to_cstr();
+ let desc = desc.to_cstr();
let name_ptr = name.as_ref().as_ptr() as *mut _;
let desc_ptr = desc.as_ref().as_ptr() as *mut _;
@@ -298,7 +298,7 @@ where
/// ```
pub fn register_command_for_range<S, C>(name: S, desc: S, command: C)
where
- S: BnStrCompatible,
+ S: AsCStr,
C: RangeCommand,
{
extern "C" fn cb_action<C>(ctxt: *mut c_void, view: *mut BNBinaryView, addr: u64, len: u64)
@@ -334,8 +334,8 @@ where
})
}
- let name = name.into_bytes_with_nul();
- let desc = desc.into_bytes_with_nul();
+ let name = name.to_cstr();
+ let desc = desc.to_cstr();
let name_ptr = name.as_ref().as_ptr() as *mut _;
let desc_ptr = desc.as_ref().as_ptr() as *mut _;
@@ -405,7 +405,7 @@ where
/// ```
pub fn register_command_for_function<S, C>(name: S, desc: S, command: C)
where
- S: BnStrCompatible,
+ S: AsCStr,
C: FunctionCommand,
{
extern "C" fn cb_action<C>(ctxt: *mut c_void, view: *mut BNBinaryView, func: *mut BNFunction)
@@ -446,8 +446,8 @@ where
})
}
- let name = name.into_bytes_with_nul();
- let desc = desc.into_bytes_with_nul();
+ let name = name.to_cstr();
+ let desc = desc.to_cstr();
let name_ptr = name.as_ref().as_ptr() as *mut _;
let desc_ptr = desc.as_ref().as_ptr() as *mut _;