diff options
| author | Mason Reed <mason@vector35.com> | 2025-07-06 17:01:01 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-07-06 17:01:01 -0400 |
| commit | c953977c69ee829609debc0447fc09f3ff2b395b (patch) | |
| tree | b520593f7929e740cd492f3bef7f80dbe06c5cbd /rust/src/interaction/report.rs | |
| parent | ecb8f071ca5f6e414e127e85ab660a4af052bebf (diff) | |
[Rust] Make `ReportCollection::add_*` optionally take a view
To allow for creating reports outside the context of a view
Diffstat (limited to 'rust/src/interaction/report.rs')
| -rw-r--r-- | rust/src/interaction/report.rs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/rust/src/interaction/report.rs b/rust/src/interaction/report.rs index c362e041..7ce74f08 100644 --- a/rust/src/interaction/report.rs +++ b/rust/src/interaction/report.rs @@ -77,27 +77,33 @@ impl ReportCollection { } } - pub fn add_text(&self, view: &BinaryView, title: &str, contents: &str) { + pub fn add_text(&self, view: Option<&BinaryView>, title: &str, contents: &str) { let title = title.to_cstr(); let contents = contents.to_cstr(); unsafe { BNAddPlainTextReportToCollection( self.handle.as_ptr(), - view.handle, + view.map(|v| v.handle).unwrap_or(std::ptr::null_mut()), title.as_ptr(), contents.as_ptr(), ) } } - pub fn add_markdown(&self, view: &BinaryView, title: &str, contents: &str, plaintext: &str) { + pub fn add_markdown( + &self, + view: Option<&BinaryView>, + title: &str, + contents: &str, + plaintext: &str, + ) { let title = title.to_cstr(); let contents = contents.to_cstr(); let plaintext = plaintext.to_cstr(); unsafe { BNAddMarkdownReportToCollection( self.handle.as_ptr(), - view.handle, + view.map(|v| v.handle).unwrap_or(std::ptr::null_mut()), title.as_ptr(), contents.as_ptr(), plaintext.as_ptr(), @@ -105,14 +111,20 @@ impl ReportCollection { } } - pub fn add_html(&self, view: &BinaryView, title: &str, contents: &str, plaintext: &str) { + pub fn add_html( + &self, + view: Option<&BinaryView>, + title: &str, + contents: &str, + plaintext: &str, + ) { let title = title.to_cstr(); let contents = contents.to_cstr(); let plaintext = plaintext.to_cstr(); unsafe { BNAddHTMLReportToCollection( self.handle.as_ptr(), - view.handle, + view.map(|v| v.handle).unwrap_or(std::ptr::null_mut()), title.as_ptr(), contents.as_ptr(), plaintext.as_ptr(), @@ -120,12 +132,12 @@ impl ReportCollection { } } - pub fn add_graph(&self, view: &BinaryView, title: &str, graph: &FlowGraph) { + pub fn add_graph(&self, view: Option<&BinaryView>, title: &str, graph: &FlowGraph) { let title = title.to_cstr(); unsafe { BNAddGraphReportToCollection( self.handle.as_ptr(), - view.handle, + view.map(|v| v.handle).unwrap_or(std::ptr::null_mut()), title.as_ptr(), graph.handle, ) |
