diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-12 12:06:22 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | d5bac712c9fa269aaeb016648116d3147edf3855 (patch) | |
| tree | 3fe6030d2576883b1762578bcd92ea8b450bf50a /rust | |
| parent | 3b14d1605cf9ea638a0d058911a8c1e233a9f70d (diff) | |
[Rust] Misc cleanup
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/src/binary_view.rs | 2 | ||||
| -rw-r--r-- | rust/src/binary_view/reader.rs | 4 | ||||
| -rw-r--r-- | rust/src/custom_binary_view.rs | 4 | ||||
| -rw-r--r-- | rust/src/file_metadata.rs | 16 | ||||
| -rw-r--r-- | rust/src/settings.rs | 10 |
5 files changed, 15 insertions, 21 deletions
diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs index 1aa97891..4379e7f5 100644 --- a/rust/src/binary_view.rs +++ b/rust/src/binary_view.rs @@ -1163,7 +1163,7 @@ pub trait BinaryViewExt: BinaryViewBase { if settings_handle.is_null() { Err(()) } else { - Ok(unsafe { Settings::from_raw(settings_handle) }) + Ok(unsafe { Settings::ref_from_raw(settings_handle) }) } } diff --git a/rust/src/binary_view/reader.rs b/rust/src/binary_view/reader.rs index 7b49f28d..685914e2 100644 --- a/rust/src/binary_view/reader.rs +++ b/rust/src/binary_view/reader.rs @@ -68,12 +68,12 @@ impl BinaryReader { unsafe { BNSetBinaryReaderVirtualBase(self.handle, virtual_base_addr) } } - /// Prefer using [crate::reader::BinaryReader::seek] over this. + /// Prefer using [BinaryReader::seek] over this. pub fn seek_to_offset(&mut self, offset: u64) { unsafe { BNSeekBinaryReader(self.handle, offset) } } - /// Prefer using [crate::reader::BinaryReader::seek] over this. + /// Prefer using [BinaryReader::seek] over this. pub fn seek_to_relative_offset(&mut self, offset: i64) { unsafe { BNSeekBinaryReaderRelative(self.handle, offset) } } diff --git a/rust/src/custom_binary_view.rs b/rust/src/custom_binary_view.rs index f809f251..a0b1df21 100644 --- a/rust/src/custom_binary_view.rs +++ b/rust/src/custom_binary_view.rs @@ -200,7 +200,7 @@ pub trait BinaryViewTypeBase: AsRef<BinaryViewType> { if settings_handle.is_null() { None } else { - unsafe { Some(Settings::from_raw(settings_handle)) } + unsafe { Some(Settings::ref_from_raw(settings_handle)) } } } @@ -388,7 +388,7 @@ impl BinaryViewTypeBase for BinaryViewType { if settings_handle.is_null() { None } else { - unsafe { Some(Settings::from_raw(settings_handle)) } + unsafe { Some(Settings::ref_from_raw(settings_handle)) } } } } diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs index 56c8a9e9..ed859775 100644 --- a/rust/src/file_metadata.rs +++ b/rust/src/file_metadata.rs @@ -121,8 +121,8 @@ impl FileMetadata { /// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread /// and the thread executing this function, you can deadlock. You should also never call this function /// on multiple threads at a time. See the following issues: - /// - https://github.com/Vector35/binaryninja-api/issues/6289 - /// - https://github.com/Vector35/binaryninja-api/issues/6325 + /// - <https://github.com/Vector35/binaryninja-api/issues/6289> + /// - <https://github.com/Vector35/binaryninja-api/issues/6325> pub fn run_undoable_transaction<F: FnOnce() -> Result<T, E>, T, E>( &self, func: F, @@ -146,8 +146,8 @@ impl FileMetadata { /// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread /// and the thread executing this function, you can deadlock. You should also never call this function /// on multiple threads at a time. See the following issues: - /// - https://github.com/Vector35/binaryninja-api/issues/6289 - /// - https://github.com/Vector35/binaryninja-api/issues/6325 + /// - <https://github.com/Vector35/binaryninja-api/issues/6289> + /// - <https://github.com/Vector35/binaryninja-api/issues/6325> pub fn begin_undo_actions(&self, anonymous_allowed: bool) -> String { unsafe { BnString::into_string(BNBeginUndoActions(self.handle, anonymous_allowed)) } } @@ -157,8 +157,8 @@ impl FileMetadata { /// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread /// and the thread executing this function, you can deadlock. You should also never call this function /// on multiple threads at a time. See the following issues: - /// - https://github.com/Vector35/binaryninja-api/issues/6289 - /// - https://github.com/Vector35/binaryninja-api/issues/6325 + /// - <https://github.com/Vector35/binaryninja-api/issues/6289> + /// - <https://github.com/Vector35/binaryninja-api/issues/6325> pub fn commit_undo_actions(&self, id: &str) { let id = id.to_cstr(); unsafe { @@ -171,8 +171,8 @@ impl FileMetadata { /// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread /// and the thread executing this function, you can deadlock. You should also never call this function /// on multiple threads at a time. See the following issues: - /// - https://github.com/Vector35/binaryninja-api/issues/6289 - /// - https://github.com/Vector35/binaryninja-api/issues/6325 + /// - <https://github.com/Vector35/binaryninja-api/issues/6289> + /// - <https://github.com/Vector35/binaryninja-api/issues/6325> pub fn revert_undo_actions(&self, id: &str) { let id = id.to_cstr(); unsafe { diff --git a/rust/src/settings.rs b/rust/src/settings.rs index 0047f570..3882ce4d 100644 --- a/rust/src/settings.rs +++ b/rust/src/settings.rs @@ -35,7 +35,7 @@ pub struct Settings { } impl Settings { - pub(crate) unsafe fn from_raw(handle: *mut BNSettings) -> Ref<Self> { + pub(crate) unsafe fn ref_from_raw(handle: *mut BNSettings) -> Ref<Self> { debug_assert!(!handle.is_null()); Ref::new(Self { handle }) } @@ -46,11 +46,7 @@ impl Settings { pub fn new_with_id(instance_id: &str) -> Ref<Self> { let instance_id = instance_id.to_cstr(); - unsafe { - let handle = BNCreateSettings(instance_id.as_ptr()); - debug_assert!(!handle.is_null()); - Ref::new(Self { handle }) - } + unsafe { Self::ref_from_raw(BNCreateSettings(instance_id.as_ptr())) } } pub fn set_resource_id(&self, resource_id: &str) { @@ -84,8 +80,6 @@ impl Settings { unsafe { Array::new(result as *mut *mut c_char, count, ()) } } - // TODO Update the settings API to take an optional BinaryView or Function. Separate functions or...? - pub fn get_bool(&self, key: &str) -> bool { self.get_bool_with_opts(key, &mut QueryOptions::default()) } |
