#[non_exhaustive]pub struct ServerConfig {
pub quirks: Quirks,
pub max_page_limit: u64,
pub receiver_path_prefix: Option<String>,
}server only.Expand description
How the server behaves.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.quirks: QuirksThe interoperability profile for incoming requests, chiefly whether an unencoded
Authorization token is accepted.
max_page_limit: u64The largest page a list endpoint will return, which is what X-Limit advertises.
X-Limit: The maximum number of objects that the server can return.
receiver_path_prefix: Option<String>A path segment inserted before every Receiver interface, e.g. receiver.
§Why this exists
The Locations Sender and Receiver interfaces have structurally identical URLs:
Sender: {locations}/{location_id}/{evse_uid}/{connector_id}
Receiver: {locations}/{country_code}/{party_id}/{location_id}Three path segments either way, so no router can tell them apart. The specification does
not have this problem because the two are different endpoints with independently chosen
URLs — in practice /ocpi/cpo/2.3.0/locations and /ocpi/emsp/2.3.0/locations — and
“The exact URL can be found by fetching the endpoint information from the API info
endpoint”.
A platform that is both CPO and eMSP therefore has two choices, and this field picks between them:
Some("receiver")(the default) — one router, one/versions, and the Receiver interfaces published one segment deeper. The generated version details say so.None— the conventional split, with oneOcpiRouterper role nested under its own base URL; set it withone_router_per_role. Mounting both interfaces of an ambiguously-shaped module on one router with no prefix is a configuration error and panics at start-up with an explanation.
Charging Profiles ({session_id} on both sides) and Payments
(terminals/{terminal_id} on both sides) have the same problem as Locations.
Spec: 2.3.0 §transport_and_format_interface_endpoints
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn with_quirks(self, quirks: Quirks) -> Self
pub fn with_quirks(self, quirks: Quirks) -> Self
Sets the interoperability profile for incoming requests.
Sourcepub const fn with_max_page_limit(self, limit: u64) -> Self
pub const fn with_max_page_limit(self, limit: u64) -> Self
Sets the largest page a list endpoint will return, which is what X-Limit advertises and
what the Page extractor clamps an incoming limit to.
Sourcepub fn with_receiver_path_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_receiver_path_prefix(self, prefix: impl Into<String>) -> Self
Publishes the Receiver interfaces under prefix instead of the default receiver.
Sourcepub fn one_router_per_role(self) -> Self
pub fn one_router_per_role(self) -> Self
Publishes the Receiver interfaces at their bare paths, for a deployment that runs one router per role.
This is the conventional OCPI split — /ocpi/cpo/2.3.0/locations and
/ocpi/emsp/2.3.0/locations are different endpoints with independently chosen URLs — and
it is the right choice when each role has its own base URL. It is not a choice a
platform serving both roles from one router can make: see
receiver_path_prefix for why, and expect a panic at
start-up if you try.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more