From 067148afd1a8f9153bb5bfe6b5361b83e9f89ab6 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 7 May 2025 23:23:44 -0400 Subject: [Rust] Improve `FileAccessor` - Add unit tests - Expose read/write functionality - Add some much needed documentation when passing to memory map --- rust/src/binary_view.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'rust/src/binary_view.rs') diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs index 04a60a0d..55b0d4db 100644 --- a/rust/src/binary_view.rs +++ b/rust/src/binary_view.rs @@ -32,7 +32,7 @@ use crate::confidence::Conf; use crate::data_buffer::DataBuffer; use crate::debuginfo::DebugInfo; use crate::external_library::{ExternalLibrary, ExternalLocation}; -use crate::file_accessor::FileAccessor; +use crate::file_accessor::{Accessor, FileAccessor}; use crate::file_metadata::FileMetadata; use crate::flowgraph::FlowGraph; use crate::function::{Function, NativeBlock}; @@ -1832,8 +1832,11 @@ impl BinaryView { unsafe { Ok(Ref::new(Self { handle })) } } - pub fn from_accessor(meta: &FileMetadata, file: &mut FileAccessor) -> Result> { - let handle = unsafe { BNCreateBinaryDataViewFromFile(meta.handle, &mut file.api_object) }; + pub fn from_accessor( + meta: &FileMetadata, + file: &mut FileAccessor, + ) -> Result> { + let handle = unsafe { BNCreateBinaryDataViewFromFile(meta.handle, &mut file.raw) }; if handle.is_null() { return Err(()); @@ -1875,8 +1878,8 @@ impl BinaryView { /// /// To avoid the above issue use [`crate::main_thread::execute_on_main_thread_and_wait`] to verify there /// are no queued up main thread actions. - pub fn save_to_accessor(&self, file: &mut FileAccessor) -> bool { - unsafe { BNSaveToFile(self.handle, &mut file.api_object) } + pub fn save_to_accessor(&self, file: &mut FileAccessor) -> bool { + unsafe { BNSaveToFile(self.handle, &mut file.raw) } } } -- cgit v1.3.1