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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Configuration for statistics retrieval operations.
//!
//! Implements `StatsConfig`.
/// Specifies the attributes of a statistics retrieval operation.
///
/// Pass to [`Environment::get_stats`][crate::environment::Environment::get_stats] or
/// [`Database::get_stats`][crate::database::Database::get_stats].
///
/// # Defaults
///
/// - `fast = false` — collect all statistics, including those that require an
/// expensive action such as a tree traversal or lock-table scan.
/// - `clear = false` — do not reset counters after reading them.
#[derive(Clone, Debug, Default)]
pub struct StatsConfig {
/// If `true`, return only values that do not require expensive actions
/// (e.g. skip B-tree traversal counts). Implements `StatsConfig.setFast(true)`.
pub fast: bool,
/// If `true`, reset all counters to zero after reading them.
/// Implements `StatsConfig.setClear(true)`.
pub clear: bool,
}
impl StatsConfig {
/// Creates a `StatsConfig` with all default settings.
pub fn new() -> Self {
Self::default()
}
/// Convenience constructor: `fast = false`, `clear = true`.
///
/// Implements `StatsConfig.CLEAR` constant.
pub fn clear() -> Self {
Self { fast: false, clear: true }
}
/// Builder: set `fast`.
pub fn with_fast(mut self, fast: bool) -> Self {
self.fast = fast;
self
}
/// Builder: set `clear`.
pub fn with_clear(mut self, clear: bool) -> Self {
self.clear = clear;
self
}
/// Sets `fast` and returns `&mut self` for chaining.
pub fn set_fast(&mut self, fast: bool) -> &mut Self {
self.fast = fast;
self
}
/// Sets `clear` and returns `&mut self` for chaining.
pub fn set_clear(&mut self, clear: bool) -> &mut Self {
self.clear = clear;
self
}
}