Skip to content

Commit da3fe9b

Browse files
committed
[Rust] Impl Display for FileMetadata
1 parent a39e29a commit da3fe9b

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

rust/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
.load("/bin/cat")
3030
.expect("Couldn't open `/bin/cat`");
3131

32-
println!("Filename: `{}`", bv.file().filename());
32+
println!("File: `{}`", bv.file());
3333
println!("File size: `{:#x}`", bv.len());
3434
println!("Function count: {}", bv.functions().len());
3535

rust/examples/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
.load("/bin/cat")
1313
.expect("Couldn't open `/bin/cat`");
1414

15-
println!("Filename: `{}`", bv.file().filename());
15+
println!("File: `{}`", bv.file());
1616
println!("File size: `{:#x}`", bv.len());
1717
println!("Function count: {}", bv.functions().len());
1818

rust/src/file_metadata.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use binaryninjacore_sys::{
2727
};
2828
use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress};
2929
use std::ffi::c_void;
30-
use std::fmt::Debug;
30+
use std::fmt::{Debug, Display, Formatter};
3131
use std::path::Path;
3232

3333
use crate::progress::ProgressCallback;
@@ -375,7 +375,7 @@ impl FileMetadata {
375375
}
376376

377377
impl Debug for FileMetadata {
378-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
378+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
379379
f.debug_struct("FileMetadata")
380380
.field("filename", &self.filename())
381381
.field("session_id", &self.session_id())
@@ -388,6 +388,12 @@ impl Debug for FileMetadata {
388388
}
389389
}
390390

391+
impl Display for FileMetadata {
392+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
393+
f.write_str(&self.filename())
394+
}
395+
}
396+
391397
unsafe impl Send for FileMetadata {}
392398
unsafe impl Sync for FileMetadata {}
393399

0 commit comments

Comments
 (0)