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
//! Explain an OCPI object in human language.
//!
//! Where schema validation flags problems in a tariff, `explain` describes what a tariff says:
//! what it charges, for which dimension, and how the rate changes as a session progresses. The
//! explanation folds in how `ocpi-tariffs` interprets the spec, not just the raw field values.
//!
//! Use [`tariff::explain`](crate::tariff::explain) to explain a tariff.
//!
//! # What explaining is, and is not
//!
//! `explain` states what a tariff says. It finds no fault in the tariff and proposes no edit to it.
//! What it returns is prose, never a tariff. The warnings returned alongside the explanation come
//! from parsing the document rather than from explaining it.
//!
//! A tariff that makes no sense gets an explanation that makes no sense. An element whose
//! restrictions exclude every session is described like any other, under the bounds its author
//! wrote. Reporting that such a restriction is pointless belongs to [`lint`](crate::lint), and
//! repairing it belongs to [`tariff::fix`](crate::tariff::fix). Linting leaves the explanation
//! unchanged, so a caller who wants one covering only what a session can be charged fixes what
//! `lint` reports and explains the result.
//!
//! The explanation does make some decisions of its own. Each follows from how the pricing engine
//! reads a tariff rather than from a judgment about its author:
//!
//! - An element restricted to `reservation` is left out. It prices a kind of session the
//! explanation is not about.
//! - A tier an earlier tier already covers is left out. The earlier tier supplies the rate, so
//! the later one never does.
//! - A flat fee of zero gets no section when it is the only flat tier, because it charges nothing.
//! - The billing step stated for a dimension comes from the tiers a session can reach. A tier
//! whose own bounds exclude every session bills nothing, so its step is not one a session meets.
pub use Language;
use crate::;
/// Explain the given tariff in the given language and return the explanation as Markdown.
pub