didbot_policy_records/across.rs
1//! What one deployment keeps between policy builds.
2//!
3//! [`crate::merge::build`] is called once per poll tick, and
4//! [`LastGoodPolicies`] is only useful when the *same* instance is handed to
5//! every call: it is what lets a policy whose new revision will not compile
6//! keep enforcing the revision that did. A caller constructing one per build
7//! gets a store that is empty every time it is read.
8//!
9//! [`AcrossBuilds`] holds it, so a deployment keeps one field for the length
10//! of its run and a build takes one argument. A caller that really does
11//! build once — a browser simulating a set it was handed, a test asking what
12//! a fixed set of records compiles to — passes a default.
13
14use crate::last_good::LastGoodPolicies;
15
16/// The store a policy build reads that outlives it: the last revision of
17/// each operator policy that compiled.
18///
19/// Hold one per deployment, for the length of the run.
20#[derive(Default)]
21pub struct AcrossBuilds {
22 /// The last revision of each operator-sourced policy that compiled.
23 /// See [`LastGoodPolicies`].
24 pub last_good: LastGoodPolicies,
25}
26
27impl AcrossBuilds {
28 /// Nothing compiled yet.
29 #[must_use]
30 pub fn new() -> Self {
31 Self::default()
32 }
33}