summaryrefslogtreecommitdiff
path: root/rust/src/custom_binary_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/custom_binary_view.rs')
-rw-r--r--rust/src/custom_binary_view.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/rust/src/custom_binary_view.rs b/rust/src/custom_binary_view.rs
index de841a26..adcde09d 100644
--- a/rust/src/custom_binary_view.rs
+++ b/rust/src/custom_binary_view.rs
@@ -42,7 +42,7 @@ use crate::Endianness;
/// implementation of the `CustomBinaryViewType` must return.
pub fn register_view_type<S, T, F>(name: S, long_name: S, constructor: F) -> &'static T
where
- S: BnStrCompatible,
+ S: AsCStr,
T: CustomBinaryViewType,
F: FnOnce(BinaryViewType) -> T,
{
@@ -149,10 +149,10 @@ where
})
}
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
let name_ptr = name.as_ref().as_ptr() as *mut _;
- let long_name = long_name.into_bytes_with_nul();
+ let long_name = long_name.to_cstr();
let long_name_ptr = long_name.as_ref().as_ptr() as *mut _;
let ctxt = Box::leak(Box::new(MaybeUninit::zeroed()));
@@ -360,8 +360,8 @@ impl BinaryViewType {
}
/// Looks up a BinaryViewType by its short name
- pub fn by_name<N: BnStrCompatible>(name: N) -> Result<Self> {
- let bytes = name.into_bytes_with_nul();
+ pub fn by_name<N: AsCStr>(name: N) -> Result<Self> {
+ let bytes = name.to_cstr();
let handle = unsafe { BNGetBinaryViewTypeByName(bytes.as_ref().as_ptr() as *const _) };
match handle.is_null() {
false => Ok(unsafe { BinaryViewType::from_raw(handle) }),