summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-03-13 12:22:27 -0700
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-24 18:46:48 -0700
commitf325aa7b6026a1daef84931baeb1f50d7da10c10 (patch)
treeefff739a0c4efe1c842c664eb15f527080c4f198 /rust/src
parentf9d2e6f1d605d7d1a1a227b4fb1d367693bc0742 (diff)
[Rust] More appropriate impls for `PartialEq` and `Hash` for `FileMetadata`
Utilize the unique `session_id` of the `FileMetadata` on comparisons and when hashing.
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/file_metadata.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs
index ce320dc5..b58daa55 100644
--- a/rust/src/file_metadata.rs
+++ b/rust/src/file_metadata.rs
@@ -22,6 +22,7 @@ use binaryninjacore_sys::*;
use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress};
use std::ffi::c_void;
use std::fmt::{Debug, Display, Formatter};
+use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use crate::progress::{NoProgressCallback, ProgressCallback};
@@ -108,7 +109,6 @@ unsafe impl RefCountable for SaveSettings {
/// **Important**: Because [`FileMetadata`] holds a strong reference to the [`BinaryView`]s and those
/// views hold a strong reference to the file metadata, to end the cyclic reference a call to the
/// [`FileMetadata::close`] is required.
-#[derive(PartialEq, Eq, Hash)]
pub struct FileMetadata {
pub(crate) handle: *mut BNFileMetadata,
}
@@ -612,6 +612,20 @@ impl Display for FileMetadata {
}
}
+impl PartialEq for FileMetadata {
+ fn eq(&self, other: &Self) -> bool {
+ self.session_id() == other.session_id()
+ }
+}
+
+impl Eq for FileMetadata {}
+
+impl Hash for FileMetadata {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.session_id().hash(state);
+ }
+}
+
unsafe impl Send for FileMetadata {}
unsafe impl Sync for FileMetadata {}