From 168a3fd34824adc9c6a606cd144219701f15cccf Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 17 Dec 2025 21:23:46 -0500 Subject: [Rust] Replace `log` with `tracing` - Added more documentation - Replaced global named logger for plugins, fixing the issue when the CU has multiple (e.g. statically linked demo) - Simplified some misc code This is a breaking change, but I believe there is no better time to make it, we cannot continue to use the `log` crate, it is too limited for our needs. --- rust/src/file_metadata.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'rust/src/file_metadata.rs') diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs index 20f0aff5..27ceb4af 100644 --- a/rust/src/file_metadata.rs +++ b/rust/src/file_metadata.rs @@ -16,15 +16,7 @@ use crate::binary_view::BinaryView; use crate::database::Database; use crate::rc::*; use crate::string::*; -use binaryninjacore_sys::{ - BNBeginUndoActions, BNCloseFile, BNCommitUndoActions, BNCreateDatabase, BNCreateFileMetadata, - BNFileMetadata, BNFileMetadataGetSessionId, BNForgetUndoActions, BNFreeFileMetadata, - BNGetCurrentOffset, BNGetCurrentView, BNGetExistingViews, BNGetFileMetadataDatabase, - BNGetFileViewOfType, BNGetFilename, BNGetProjectFile, BNIsAnalysisChanged, - BNIsBackedByDatabase, BNIsFileModified, BNMarkFileModified, BNMarkFileSaved, BNNavigate, - BNNewFileReference, BNOpenDatabaseForConfiguration, BNOpenExistingDatabase, BNRedo, - BNRevertUndoActions, BNSaveAutoSnapshot, BNSetFilename, BNUndo, -}; +use binaryninjacore_sys::*; use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress}; use std::ffi::c_void; use std::fmt::{Debug, Display, Formatter}; @@ -34,6 +26,8 @@ use crate::progress::ProgressCallback; use crate::project::file::ProjectFile; use std::ptr::{self, NonNull}; +new_id_type!(SessionId, usize); + #[derive(PartialEq, Eq, Hash)] pub struct FileMetadata { pub(crate) handle: *mut BNFileMetadata, @@ -64,8 +58,9 @@ impl FileMetadata { } } - pub fn session_id(&self) -> usize { - unsafe { BNFileMetadataGetSessionId(self.handle) } + pub fn session_id(&self) -> SessionId { + let raw = unsafe { BNFileMetadataGetSessionId(self.handle) }; + SessionId(raw) } pub fn filename(&self) -> String { -- cgit v1.3.1