@@ -53,13 +53,13 @@ pub trait InteractionHandler: Sync + Send + 'static {
5353 task : & InteractionHandlerTask ,
5454 ) -> bool ;
5555
56- fn show_plain_text_report ( & mut self , view : & BinaryView , title : & str , contents : & str ) ;
56+ fn show_plain_text_report ( & mut self , view : Option < & BinaryView > , title : & str , contents : & str ) ;
5757
58- fn show_graph_report ( & mut self , view : & BinaryView , title : & str , graph : & FlowGraph ) ;
58+ fn show_graph_report ( & mut self , view : Option < & BinaryView > , title : & str , graph : & FlowGraph ) ;
5959
6060 fn show_markdown_report (
6161 & mut self ,
62- view : & BinaryView ,
62+ view : Option < & BinaryView > ,
6363 title : & str ,
6464 _contents : & str ,
6565 plain_text : & str ,
@@ -69,7 +69,7 @@ pub trait InteractionHandler: Sync + Send + 'static {
6969
7070 fn show_html_report (
7171 & mut self ,
72- view : & BinaryView ,
72+ view : Option < & BinaryView > ,
7373 title : & str ,
7474 _contents : & str ,
7575 plain_text : & str ,
@@ -80,24 +80,28 @@ pub trait InteractionHandler: Sync + Send + 'static {
8080 fn show_report_collection ( & mut self , _title : & str , reports : & ReportCollection ) {
8181 for report in reports {
8282 match & report {
83- Report :: PlainText ( rpt) => {
84- self . show_plain_text_report ( & report. view ( ) , & report. title ( ) , & rpt. contents ( ) )
85- }
83+ Report :: PlainText ( rpt) => self . show_plain_text_report (
84+ report. view ( ) . as_deref ( ) ,
85+ & report. title ( ) ,
86+ & rpt. contents ( ) ,
87+ ) ,
8688 Report :: Markdown ( rm) => self . show_markdown_report (
87- & report. view ( ) ,
89+ report. view ( ) . as_deref ( ) ,
8890 & report. title ( ) ,
8991 & rm. contents ( ) ,
9092 & rm. plaintext ( ) ,
9193 ) ,
9294 Report :: Html ( rh) => self . show_html_report (
93- & report. view ( ) ,
95+ report. view ( ) . as_deref ( ) ,
9496 & report. title ( ) ,
9597 & rh. contents ( ) ,
9698 & rh. plaintext ( ) ,
9799 ) ,
98- Report :: FlowGraph ( rfg) => {
99- self . show_graph_report ( & report. view ( ) , & report. title ( ) , & rfg. flow_graph ( ) )
100- }
100+ Report :: FlowGraph ( rfg) => self . show_graph_report (
101+ report. view ( ) . as_deref ( ) ,
102+ & report. title ( ) ,
103+ & rfg. flow_graph ( ) ,
104+ ) ,
101105 }
102106 }
103107 }
@@ -292,7 +296,11 @@ unsafe extern "C" fn cb_show_plain_text_report<R: InteractionHandler>(
292296 let ctxt = ctxt as * mut R ;
293297 let title = raw_to_string ( title) . unwrap ( ) ;
294298 let contents = raw_to_string ( contents) . unwrap ( ) ;
295- ( * ctxt) . show_plain_text_report ( & BinaryView :: from_raw ( view) , & title, & contents)
299+ let view = match !view. is_null ( ) {
300+ true => Some ( BinaryView :: from_raw ( view) ) ,
301+ false => None ,
302+ } ;
303+ ( * ctxt) . show_plain_text_report ( view. as_ref ( ) , & title, & contents)
296304}
297305
298306unsafe extern "C" fn cb_show_markdown_report < R : InteractionHandler > (
@@ -306,7 +314,11 @@ unsafe extern "C" fn cb_show_markdown_report<R: InteractionHandler>(
306314 let title = raw_to_string ( title) . unwrap ( ) ;
307315 let contents = raw_to_string ( contents) . unwrap ( ) ;
308316 let plaintext = raw_to_string ( plaintext) . unwrap ( ) ;
309- ( * ctxt) . show_markdown_report ( & BinaryView :: from_raw ( view) , & title, & contents, & plaintext)
317+ let view = match !view. is_null ( ) {
318+ true => Some ( BinaryView :: from_raw ( view) ) ,
319+ false => None ,
320+ } ;
321+ ( * ctxt) . show_markdown_report ( view. as_ref ( ) , & title, & contents, & plaintext)
310322}
311323
312324unsafe extern "C" fn cb_show_html_report < R : InteractionHandler > (
@@ -320,7 +332,11 @@ unsafe extern "C" fn cb_show_html_report<R: InteractionHandler>(
320332 let title = raw_to_string ( title) . unwrap ( ) ;
321333 let contents = raw_to_string ( contents) . unwrap ( ) ;
322334 let plaintext = raw_to_string ( plaintext) . unwrap ( ) ;
323- ( * ctxt) . show_html_report ( & BinaryView :: from_raw ( view) , & title, & contents, & plaintext)
335+ let view = match !view. is_null ( ) {
336+ true => Some ( BinaryView :: from_raw ( view) ) ,
337+ false => None ,
338+ } ;
339+ ( * ctxt) . show_html_report ( view. as_ref ( ) , & title, & contents, & plaintext)
324340}
325341
326342unsafe extern "C" fn cb_show_graph_report < R : InteractionHandler > (
@@ -331,11 +347,11 @@ unsafe extern "C" fn cb_show_graph_report<R: InteractionHandler>(
331347) {
332348 let ctxt = ctxt as * mut R ;
333349 let title = raw_to_string ( title) . unwrap ( ) ;
334- ( * ctxt ) . show_graph_report (
335- & BinaryView :: from_raw ( view) ,
336- & title ,
337- & FlowGraph :: from_raw ( graph ) ,
338- )
350+ let view = match !view . is_null ( ) {
351+ true => Some ( BinaryView :: from_raw ( view) ) ,
352+ false => None ,
353+ } ;
354+ ( * ctxt ) . show_graph_report ( view . as_ref ( ) , & title , & FlowGraph :: from_raw ( graph ) )
339355}
340356
341357unsafe extern "C" fn cb_show_report_collection < R : InteractionHandler > (
0 commit comments