1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::{ErrorReport, Event, ParallelReporter, Reporter, Size};
#[derive(Debug)]
pub struct ErrorOnlyReporter<ReportError: Fn(ErrorReport)> {
report_error: ReportError,
}
impl<ReportError: Fn(ErrorReport)> ErrorOnlyReporter<ReportError> {
pub fn new(report_error: ReportError) -> Self {
ErrorOnlyReporter { report_error }
}
}
impl<Data, ReportError> Reporter<Data> for ErrorOnlyReporter<ReportError>
where
Data: Size,
ReportError: Fn(ErrorReport),
{
fn report(&self, event: Event<Data>) {
let ErrorOnlyReporter { report_error } = self;
if let Event::EncounterError(error_report) = event {
report_error(error_report);
}
}
}
impl<Data, ReportError> ParallelReporter<Data> for ErrorOnlyReporter<ReportError>
where
Data: Size,
ReportError: Fn(ErrorReport),
{
type DestructionError = ();
fn destroy(self) -> Result<(), Self::DestructionError> {
Ok(())
}
}