diff options
| -rw-r--r-- | rust/src/interaction/report.rs | 28 | ||||
| -rw-r--r-- | rust/tests/interaction.rs | 8 |
2 files changed, 24 insertions, 12 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, ) diff --git a/rust/tests/interaction.rs b/rust/tests/interaction.rs index 5e9606b0..5b59a436 100644 --- a/rust/tests/interaction.rs +++ b/rust/tests/interaction.rs @@ -161,14 +161,14 @@ fn test_show_report_collection() { register_interaction_handler(MyInteractionHandler {}); let collection = ReportCollection::new(); - collection.add_text(&view, "title_report_0", "contents"); - collection.add_markdown(&view, "title_report_1", "# contents", "markdown_plain_text"); + collection.add_text(Some(&view), "title_report_0", "contents"); + collection.add_markdown(None, "title_report_1", "# contents", "markdown_plain_text"); collection.add_html( - &view, + None, "title_report_2", "<html>contents</html>", "html_plain_text", ); - collection.add_graph(&view, "title_report_3", &FlowGraph::new()); + collection.add_graph(None, "title_report_3", &FlowGraph::new()); collection.show("show_report_collection_title"); } |
