summaryrefslogtreecommitdiff
path: root/rust/src/binary_view.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-07 23:23:44 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit067148afd1a8f9153bb5bfe6b5361b83e9f89ab6 (patch)
tree0745e9bb5f0ab51f83f76f79dfa9fbc97563cb02 /rust/src/binary_view.rs
parent3992860ca7d636661d7b2671d5fe7cf028987be1 (diff)
[Rust] Improve `FileAccessor`
- Add unit tests - Expose read/write functionality - Add some much needed documentation when passing to memory map
Diffstat (limited to 'rust/src/binary_view.rs')
-rw-r--r--rust/src/binary_view.rs13
1 files changed, 8 insertions, 5 deletions
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<Ref<Self>> {
- let handle = unsafe { BNCreateBinaryDataViewFromFile(meta.handle, &mut file.api_object) };
+ pub fn from_accessor<A: Accessor>(
+ meta: &FileMetadata,
+ file: &mut FileAccessor<A>,
+ ) -> Result<Ref<Self>> {
+ 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<A: Accessor>(&self, file: &mut FileAccessor<A>) -> bool {
+ unsafe { BNSaveToFile(self.handle, &mut file.raw) }
}
}