Expand description
The scalar and leaf types the whole specification is built from.
These are version-neutral: OCPI 2.1.1, 2.2.1 and 2.3.0 agree on what a CiString, a
DateTime, a number and a DisplayText are. Types that changed between versions —
Price, Role, Tariff — live in the per-version modules instead.
Nothing here needs an async runtime or an HTTP stack, so this layer compiles for
wasm32-unknown-unknown and can back browser tooling and edge workers.
§The three rules
- Parse permissively.
Deserializenever fails because a peer overran a length limit. - Validate explicitly.
Validate::validatereports every deviation, with a JSON Pointer to it. - Construct strictly.
newandFromStrrefuse to build a non-conformant value, so what this crate emits is conformant.
See validate for why.
Re-exports§
pub use cistring::CiString;pub use datetime::DateTime;pub use datetime::InvalidDateTime;pub use display_text::DisplayText;pub use extensions::Extensions;pub use ids::ContractId;pub use ids::CountryCode;pub use ids::CountryCodeExt;pub use ids::Currency;pub use ids::EvseId;pub use ids::EvseIdParts;pub use ids::InvalidPartyRef;pub use ids::PartyId;pub use ids::PartyRef;pub use local::InvalidLocalDate;pub use local::InvalidLocalTime;pub use local::LocalDate;pub use local::LocalTime;pub use number::InvalidNumber;pub use number::Number;pub use open_enum::UnknownVariant;pub use string::OcpiString;pub use url::InvalidUrl;pub use url::URL_MAX_LEN;pub use url::Url;pub use url::UrlPolicy;pub use url::UrlRefused;pub use validate::Validate;pub use validate::Validator;pub use validate::Violation;pub use validate::ViolationCode;pub use validate::Violations;
Modules§
- cistring
CiString— the OCPI case-insensitive, printable-ASCII string type.- datetime
DateTime— the OCPI timestamp type: RFC 3339, always UTC.- display_
text DisplayText— a string with the language it is written in.- extensions
Extensions— the map that keeps JSON fields this crate has never heard of.- ids
- The identifier types OCPI reuses across every module.
- local
- Local wall-clock times and dates: the
string(5)andstring(10)fields OCPI uses for opening hours and tariff restrictions. - number
Number— the OCPI decimal number type. Neverf64in a field, neverf64in arithmetic.- open_
enum - The two enum shapes OCPI 2.3.0 distinguishes, as declarative macros.
- string
OcpiString— the OCPI case-sensitive, printable-UTF-8 string type.- url
Url— the OCPIURLtype, and the policy that keeps a hub from becoming an SSRF proxy.- validate
- Explicit validation: parse permissively, validate deliberately, construct strictly.
Structs§
- Invalid
String - Why a string could not be accepted by a strict constructor.
Enums§
- String
Kind - Which of the two OCPI string types a rule applies to.
Constants§
- UNBOUNDED
- The length limit for a
stringwhose property table gives no maximum.