diff options
| author | Mason Reed <mason@vector35.com> | 2025-12-09 13:57:08 -0500 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-12-10 17:35:19 -0500 |
| commit | ae02e4cfe187752766a1137b2ce87a5642e89c44 (patch) | |
| tree | e254709666d59bbe0df56f8df9c7b6226a99a257 /rust | |
| parent | 393d6dda437d848f51efacceb8618b937d9f08f3 (diff) | |
[Rust] Impl `Display` for `FileMetadata`
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/README.md | 2 | ||||
| -rw-r--r-- | rust/examples/simple.rs | 2 | ||||
| -rw-r--r-- | rust/src/file_metadata.rs | 10 |
3 files changed, 10 insertions, 4 deletions
diff --git a/rust/README.md b/rust/README.md index a18d46cd..60c4847c 100644 --- a/rust/README.md +++ b/rust/README.md @@ -29,7 +29,7 @@ fn main() { .load("/bin/cat") .expect("Couldn't open `/bin/cat`"); - println!("Filename: `{}`", bv.file().filename()); + println!("File: `{}`", bv.file()); println!("File size: `{:#x}`", bv.len()); println!("Function count: {}", bv.functions().len()); diff --git a/rust/examples/simple.rs b/rust/examples/simple.rs index f01d5267..66dbdfc0 100644 --- a/rust/examples/simple.rs +++ b/rust/examples/simple.rs @@ -12,7 +12,7 @@ fn main() { .load("/bin/cat") .expect("Couldn't open `/bin/cat`"); - println!("Filename: `{}`", bv.file().filename()); + println!("File: `{}`", bv.file()); println!("File size: `{:#x}`", bv.len()); println!("Function count: {}", bv.functions().len()); diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs index 86e28a3e..dc9d36ff 100644 --- a/rust/src/file_metadata.rs +++ b/rust/src/file_metadata.rs @@ -27,7 +27,7 @@ use binaryninjacore_sys::{ }; use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress}; use std::ffi::c_void; -use std::fmt::Debug; +use std::fmt::{Debug, Display, Formatter}; use std::path::Path; use crate::progress::ProgressCallback; @@ -375,7 +375,7 @@ impl FileMetadata { } impl Debug for FileMetadata { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("FileMetadata") .field("filename", &self.filename()) .field("session_id", &self.session_id()) @@ -388,6 +388,12 @@ impl Debug for FileMetadata { } } +impl Display for FileMetadata { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.filename()) + } +} + unsafe impl Send for FileMetadata {} unsafe impl Sync for FileMetadata {} |
