pub fn parse(tariff_json: &str) -> Result<TariffVersion<'_>, ParseError>Expand description
Parse the JSON and try guess the Version based on fields defined in the OCPI v2.1.11 and v2.2.12 tariff spec.
The parser is forgiving and will not complain if the tariff JSON is missing required fields.
The parser will also not complain if unexpected fields are present in the JSON.
The Version guess is based on fields that exist.
§Example
let tariff = tariff::parse(TARIFF_JSON)?;
match tariff {
guess::Version::Certain(tariff) => {
println!("The tariff version is `{}`", tariff.version());
},
guess::Version::Uncertain(_tariff) => {
eprintln!("Unable to guess the version of given tariff JSON.");
}
}