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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! Keeping two copies of the EVSE world in step — the delta engine, and its mirror image.
//!
//! # The problem every EMP solves badly
//!
//! An EMP needs a local copy of every charging point it can route a driver to. Pulling all of them
//! takes minutes and hundreds of megabytes, so nobody does it often. The spec's answer is the
//! `LastCall` delta: ask for the changes since a given instant, and Hubject tags every record
//! `insert`, `update` or `delete`.
//!
//! That sounds simple and is not, because of four rules that are easy to get wrong and expensive
//! to get wrong quietly:
//!
//! 1. **`LastCall` is exclusive with the filters.** A delta scoped to a country silently omits
//! charge points that *moved out* of it, and the stale records live forever.
//! 2. **A delete is a tombstone, not an update.** A `delete` record carries an `EvseID` and little
//! else; applying it as an upsert leaves a corrupted record behind.
//! 3. **The watermark advances on success, not on request.** Advance it before the crawl finishes
//! and a failed page's changes are lost — permanently, because the next delta starts after them.
//! 4. **Deltas expire.** Hubject has no documented retention for delta history. After a long
//! outage a delta cannot be trusted and the copy must be rebuilt.
//!
//! [`Planner`] encodes all four. [`apply`] applies a delta to an [`EvseRepository`]. The property
//! test in `tests/properties.rs` proves the thing that matters:
//!
//! > applying any sequence of deltas leaves the same state as a full pull.
//!
//! # And the same problem, from the CPO side
//!
//! A CPO has the mirror image: it must keep Hubject's copy of *its* fleet in step, and its tool is
//! [`ActionType`](crate::types::ActionType) — where `fullLoad` replaces everything. Sending a
//! partial list with `fullLoad` removes the rest of the operator's fleet from the roaming network.
//! [`PushPlanner`] computes the minimal `insert`/`update`/`delete` set from a snapshot, so the
//! destructive action is never the one you reach for by default.
pub use ;
pub use ;
pub use ;
pub use ;
use crateDeltaType;
use cratePullEvseDataRecord;
/// Applies one page of a delta pull to `repository`.
///
/// Records without a [`DeltaType`] are treated as inserts-or-updates: that is what a *full* pull
/// returns, so the same function applies a full pull and a delta.
///
/// # `deltaType` is stripped before storing
///
/// `deltaType` describes *this pull* — "here is what changed since your last call" — not the
/// charging point. Storing it would leave every record in the EMP's copy tagged with whatever
/// happened to it the last time it appeared in a delta, so a copy built from deltas would never
/// equal one built from a full pull, and any re-publication of the record would carry a
/// meaningless tag. `lastUpdate` is kept: that *is* a fact about the charging point.
///
/// The convergence property in `tests/properties.rs` is what pins this down.
///
/// # Errors
///
/// Returns whatever the repository returns. The outcome counts what was done, so a caller can log
/// "412 inserted, 88 updated, 3 deleted" rather than "ok".