Skip to content

Commit 7f9285a

Browse files
committed
[Rust] Misc cleanup
1 parent edbdfe4 commit 7f9285a

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

rust/src/binary_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ pub trait BinaryViewExt: BinaryViewBase {
11631163
if settings_handle.is_null() {
11641164
Err(())
11651165
} else {
1166-
Ok(unsafe { Settings::from_raw(settings_handle) })
1166+
Ok(unsafe { Settings::ref_from_raw(settings_handle) })
11671167
}
11681168
}
11691169

rust/src/binary_view/reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ impl BinaryReader {
6868
unsafe { BNSetBinaryReaderVirtualBase(self.handle, virtual_base_addr) }
6969
}
7070

71-
/// Prefer using [crate::reader::BinaryReader::seek] over this.
71+
/// Prefer using [BinaryReader::seek] over this.
7272
pub fn seek_to_offset(&mut self, offset: u64) {
7373
unsafe { BNSeekBinaryReader(self.handle, offset) }
7474
}
7575

76-
/// Prefer using [crate::reader::BinaryReader::seek] over this.
76+
/// Prefer using [BinaryReader::seek] over this.
7777
pub fn seek_to_relative_offset(&mut self, offset: i64) {
7878
unsafe { BNSeekBinaryReaderRelative(self.handle, offset) }
7979
}

rust/src/custom_binary_view.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub trait BinaryViewTypeBase: AsRef<BinaryViewType> {
200200
if settings_handle.is_null() {
201201
None
202202
} else {
203-
unsafe { Some(Settings::from_raw(settings_handle)) }
203+
unsafe { Some(Settings::ref_from_raw(settings_handle)) }
204204
}
205205
}
206206

@@ -388,7 +388,7 @@ impl BinaryViewTypeBase for BinaryViewType {
388388
if settings_handle.is_null() {
389389
None
390390
} else {
391-
unsafe { Some(Settings::from_raw(settings_handle)) }
391+
unsafe { Some(Settings::ref_from_raw(settings_handle)) }
392392
}
393393
}
394394
}

rust/src/file_metadata.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ impl FileMetadata {
121121
/// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread
122122
/// and the thread executing this function, you can deadlock. You should also never call this function
123123
/// on multiple threads at a time. See the following issues:
124-
/// - https://github.com/Vector35/binaryninja-api/issues/6289
125-
/// - https://github.com/Vector35/binaryninja-api/issues/6325
124+
/// - <https://github.com/Vector35/binaryninja-api/issues/6289>
125+
/// - <https://github.com/Vector35/binaryninja-api/issues/6325>
126126
pub fn run_undoable_transaction<F: FnOnce() -> Result<T, E>, T, E>(
127127
&self,
128128
func: F,
@@ -146,8 +146,8 @@ impl FileMetadata {
146146
/// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread
147147
/// and the thread executing this function, you can deadlock. You should also never call this function
148148
/// on multiple threads at a time. See the following issues:
149-
/// - https://github.com/Vector35/binaryninja-api/issues/6289
150-
/// - https://github.com/Vector35/binaryninja-api/issues/6325
149+
/// - <https://github.com/Vector35/binaryninja-api/issues/6289>
150+
/// - <https://github.com/Vector35/binaryninja-api/issues/6325>
151151
pub fn begin_undo_actions(&self, anonymous_allowed: bool) -> String {
152152
unsafe { BnString::into_string(BNBeginUndoActions(self.handle, anonymous_allowed)) }
153153
}
@@ -157,8 +157,8 @@ impl FileMetadata {
157157
/// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread
158158
/// and the thread executing this function, you can deadlock. You should also never call this function
159159
/// on multiple threads at a time. See the following issues:
160-
/// - https://github.com/Vector35/binaryninja-api/issues/6289
161-
/// - https://github.com/Vector35/binaryninja-api/issues/6325
160+
/// - <https://github.com/Vector35/binaryninja-api/issues/6289>
161+
/// - <https://github.com/Vector35/binaryninja-api/issues/6325>
162162
pub fn commit_undo_actions(&self, id: &str) {
163163
let id = id.to_cstr();
164164
unsafe {
@@ -171,8 +171,8 @@ impl FileMetadata {
171171
/// NOTE: This is **NOT** thread safe, if you are holding any locks that might be held by both the main thread
172172
/// and the thread executing this function, you can deadlock. You should also never call this function
173173
/// on multiple threads at a time. See the following issues:
174-
/// - https://github.com/Vector35/binaryninja-api/issues/6289
175-
/// - https://github.com/Vector35/binaryninja-api/issues/6325
174+
/// - <https://github.com/Vector35/binaryninja-api/issues/6289>
175+
/// - <https://github.com/Vector35/binaryninja-api/issues/6325>
176176
pub fn revert_undo_actions(&self, id: &str) {
177177
let id = id.to_cstr();
178178
unsafe {

rust/src/settings.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Settings {
3535
}
3636

3737
impl Settings {
38-
pub(crate) unsafe fn from_raw(handle: *mut BNSettings) -> Ref<Self> {
38+
pub(crate) unsafe fn ref_from_raw(handle: *mut BNSettings) -> Ref<Self> {
3939
debug_assert!(!handle.is_null());
4040
Ref::new(Self { handle })
4141
}
@@ -46,11 +46,7 @@ impl Settings {
4646

4747
pub fn new_with_id(instance_id: &str) -> Ref<Self> {
4848
let instance_id = instance_id.to_cstr();
49-
unsafe {
50-
let handle = BNCreateSettings(instance_id.as_ptr());
51-
debug_assert!(!handle.is_null());
52-
Ref::new(Self { handle })
53-
}
49+
unsafe { Self::ref_from_raw(BNCreateSettings(instance_id.as_ptr())) }
5450
}
5551

5652
pub fn set_resource_id(&self, resource_id: &str) {
@@ -84,8 +80,6 @@ impl Settings {
8480
unsafe { Array::new(result as *mut *mut c_char, count, ()) }
8581
}
8682

87-
// TODO Update the settings API to take an optional BinaryView or Function. Separate functions or...?
88-
8983
pub fn get_bool(&self, key: &str) -> bool {
9084
self.get_bool_with_opts(key, &mut QueryOptions::default())
9185
}

0 commit comments

Comments
 (0)