Skip to content

Commit a1ab981

Browse files
committed
Add impl Debug for BinaryReader and BinaryWriter
1 parent 16e8ad4 commit a1ab981

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

rust/src/binary_reader.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! A convenience class for reading binary data
1616
1717
use binaryninjacore_sys::*;
18+
use std::fmt::Debug;
1819

1920
use crate::binary_view::{BinaryView, BinaryViewBase};
2021
use crate::Endianness;
@@ -87,6 +88,16 @@ impl BinaryReader {
8788
}
8889
}
8990

91+
impl Debug for BinaryReader {
92+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
93+
f.debug_struct("BinaryReader")
94+
.field("offset", &self.offset())
95+
.field("virtual_base", &self.virtual_base())
96+
.field("endianness", &self.endianness())
97+
.finish()
98+
}
99+
}
100+
90101
impl Seek for BinaryReader {
91102
/// Seek to the specified position.
92103
fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> {

rust/src/binary_writer.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! A convenience class for writing binary data
1616
1717
use binaryninjacore_sys::*;
18+
use std::fmt::Debug;
1819

1920
use crate::binary_view::{BinaryView, BinaryViewBase};
2021
use crate::Endianness;
@@ -68,6 +69,15 @@ impl BinaryWriter {
6869
}
6970
}
7071

72+
impl Debug for BinaryWriter {
73+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74+
f.debug_struct("BinaryWriter")
75+
.field("offset", &self.offset())
76+
.field("endianness", &self.endianness())
77+
.finish()
78+
}
79+
}
80+
7181
impl Seek for BinaryWriter {
7282
/// Seek to the specified position.
7383
fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> {

0 commit comments

Comments
 (0)