use qubit_function::{
ArcConsumer,
Consumer,
};
use crate::{
model::{
ProgressEvent,
ProgressMetricSnapshot,
},
reporter::ProgressReporter,
};
pub struct MetricSnapshotProgressReporter<C = ArcConsumer<ProgressMetricSnapshot>> {
consumer: C,
}
impl<C> MetricSnapshotProgressReporter<C> {
#[inline]
pub const fn new(consumer: C) -> Self {
Self { consumer }
}
#[inline]
pub const fn consumer(&self) -> &C {
&self.consumer
}
}
impl<C> ProgressReporter for MetricSnapshotProgressReporter<C>
where
C: Consumer<ProgressMetricSnapshot> + Send + Sync,
{
#[inline]
fn report(&self, event: &ProgressEvent) {
for snapshot in event.metric_snapshots() {
self.consumer.accept(&snapshot);
}
}
}