Skip to content

Commit 82b8f57

Browse files
committed
[Rust] Add some additional impls for ergonomics
1 parent ce5f91d commit 82b8f57

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

rust/src/background_task.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! Background tasks provide plugins the ability to inform the core of long-running background tasks.
1616
1717
use binaryninjacore_sys::*;
18+
use std::fmt::Debug;
1819

1920
use std::result;
2021

@@ -89,6 +90,17 @@ impl BackgroundTask {
8990
}
9091
}
9192

93+
impl Debug for BackgroundTask {
94+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
95+
f.debug_struct("BackgroundTask")
96+
.field("progress_text", &self.progress_text())
97+
.field("can_cancel", &self.can_cancel())
98+
.field("is_cancelled", &self.is_cancelled())
99+
.field("is_finished", &self.is_finished())
100+
.finish()
101+
}
102+
}
103+
92104
unsafe impl RefCountable for BackgroundTask {
93105
unsafe fn inc_ref(handle: &Self) -> Ref<Self> {
94106
Ref::new(Self {

rust/src/project/file.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ impl Debug for ProjectFile {
119119
}
120120
}
121121

122+
unsafe impl Send for ProjectFile {}
123+
unsafe impl Sync for ProjectFile {}
124+
122125
impl ToOwned for ProjectFile {
123126
type Owned = Ref<Self>;
124127

rust/src/project/folder.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ impl ProjectFolder {
102102
}
103103
}
104104

105+
impl PartialEq for ProjectFolder {
106+
fn eq(&self, other: &Self) -> bool {
107+
self.id() == other.id()
108+
}
109+
}
110+
105111
impl Debug for ProjectFolder {
106112
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
107113
f.debug_struct("ProjectFolder")
@@ -112,6 +118,9 @@ impl Debug for ProjectFolder {
112118
}
113119
}
114120

121+
unsafe impl Send for ProjectFolder {}
122+
unsafe impl Sync for ProjectFolder {}
123+
115124
impl ToOwned for ProjectFolder {
116125
type Owned = Ref<Self>;
117126

0 commit comments

Comments
 (0)