Skip to main content

Module types

Module types 

Source
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

  1. Parse permissively. Deserialize never fails because a peer overran a length limit.
  2. Validate explicitly. Validate::validate reports every deviation, with a JSON Pointer to it.
  3. Construct strictly. new and FromStr refuse 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) and string(10) fields OCPI uses for opening hours and tariff restrictions.
number
Number — the OCPI decimal number type. Never f64 in a field, never f64 in 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 OCPI URL type, and the policy that keeps a hub from becoming an SSRF proxy.
validate
Explicit validation: parse permissively, validate deliberately, construct strictly.

Structs§

InvalidString
Why a string could not be accepted by a strict constructor.

Enums§

StringKind
Which of the two OCPI string types a rule applies to.

Constants§

UNBOUNDED
The length limit for a string whose property table gives no maximum.

Type Aliases§

CiText
A CiString with no length limit in the specification.
OcpiText
A string with no length limit in the specification.