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
// Copyright 2023 Martin Pool

//! Communication from the library to a monitor: a test, a UI, etc.

pub mod collect;
pub mod task;

use std::fmt::Debug;

use self::task::Task;
use crate::counters::Counter;

pub trait Monitor: Send + Sync + 'static {
    /// Notify that a counter increased by a given amount.
    fn count(&self, counter: Counter, increment: usize);

    /// Set the absolute value of a counter.
    fn set_counter(&self, counter: Counter, value: usize);

    /// Notify that a problem occurred.
    fn problem(&self, problem: Problem);

    fn start_task(&self, name: String) -> Task;
}

#[derive(Debug)]
pub enum Problem {
    /// Some generic error.
    Error(crate::Error),
}