Skip to main content

pedant_graph/cache/
limits.rs

1//! How many admitted values one cache may retain, by category.
2
3/// The retention ceilings one cache is bounded by.
4///
5/// There is no default. An editor, a continuous-integration process, and a
6/// batch consumer have different retention budgets, and a library that chose
7/// one implicitly would spend a host's memory on its behalf. Zero disables
8/// retention for a category without disabling the computation behind it.
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub struct GraphCacheLimits {
11    max_source_projections: u32,
12    max_exact_graphs: u32,
13    max_selected_indexes_per_graph: u32,
14    max_derived_products_per_graph: u32,
15}
16
17impl GraphCacheLimits {
18    /// Ceilings for the four retention categories.
19    pub fn new(
20        max_source_projections: u32,
21        max_exact_graphs: u32,
22        max_selected_indexes_per_graph: u32,
23        max_derived_products_per_graph: u32,
24    ) -> Self {
25        Self {
26            max_source_projections,
27            max_exact_graphs,
28            max_selected_indexes_per_graph,
29            max_derived_products_per_graph,
30        }
31    }
32
33    /// How many source-unit projections may be retained.
34    pub fn max_source_projections(self) -> u32 {
35        self.max_source_projections
36    }
37
38    /// How many exact graphs may be retained.
39    pub fn max_exact_graphs(self) -> u32 {
40        self.max_exact_graphs
41    }
42
43    /// How many edge-selection index sets may be retained per cached graph.
44    pub fn max_selected_indexes_per_graph(self) -> u32 {
45        self.max_selected_indexes_per_graph
46    }
47
48    /// How many derived products may be retained per cached graph.
49    pub fn max_derived_products_per_graph(self) -> u32 {
50        self.max_derived_products_per_graph
51    }
52}