#[non_exhaustive]pub enum RoutingScenario {
Direct,
BroadcastPush {
hub: PartyRef,
},
OpenRoutingRequest,
GetAllViaHub {
hub: PartyRef,
},
}transport only.Expand description
One of the five routing arrangements the specification tabulates.
Each variant knows how to fill the headers for both the request and the response, in both directions across a hub. This is the whole of §transport_and_format_message_routing’s “Overview of required/optional routing headers for different scenarios” in one type.
use ocpi_kit::transport::RoutingScenario;
use ocpi_kit::types::PartyRef;
let cpo = PartyRef::new("NL", "TNM").unwrap();
let msp = PartyRef::new("DE", "ABC").unwrap();
let hub = PartyRef::new("NL", "HUB").unwrap();
// A broadcast push addresses the hub, not the eventual receivers.
let scenario = RoutingScenario::BroadcastPush { hub: hub.clone() };
let request = scenario.request_headers(&cpo, None);
assert_eq!(request.to, Some(hub));
assert_eq!(request.from, cpo);Spec: 2.3.0 §transport_and_format_message_routing
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Direct
Requesting platform to receiving platform, directly or through a hub that just relays.
| TO | FROM | |
|---|---|---|
| request | receiving party | requesting party |
| response | requesting party | receiving party |
BroadcastPush
A push to every connected party with the opposite role, fanned out by the hub.
| TO | FROM | |
|---|---|---|
| requester → hub | hub | requesting party |
| hub → requester | requesting party | hub |
| hub → receiver | receiving party | hub |
| receiver → hub | hub | receiving party |
GET SHALL NOT be used in combination with Broadcast Push.
OpenRoutingRequest
The requester does not know the destination; the hub decides from the content.
| TO | FROM | |
|---|---|---|
| requester → hub | omitted | requesting party |
| hub → receiver | receiving party | requesting party |
| receiver → hub | requesting party | receiving party |
| hub → requester | requesting party | receiving party |
Open Routing Requests are possible for GET (Not GET ALL), POST, PUT, PATCH and DELETE.
GetAllViaHub
A GET on a Sender interface implemented by the hub, merging several parties’ objects.
| TO | FROM | |
|---|---|---|
| requester → hub | hub | requesting party |
| hub → requester | requesting party | hub |
Implementations§
Source§impl RoutingScenario
impl RoutingScenario
Sourcepub fn request_headers(
&self,
requester: &PartyRef,
receiver: Option<&PartyRef>,
) -> RoutingHeaders
pub fn request_headers( &self, requester: &PartyRef, receiver: Option<&PartyRef>, ) -> RoutingHeaders
The headers of the request the requesting party sends.
receiver is the destination party; it is ignored by the scenarios that address the hub
or omit the to headers entirely, and may be None there.
Sourcepub fn response_headers(
&self,
requester: &PartyRef,
receiver: Option<&PartyRef>,
) -> RoutingHeaders
pub fn response_headers( &self, requester: &PartyRef, receiver: Option<&PartyRef>, ) -> RoutingHeaders
The headers of the response the requesting party will receive.
receiver is the party that actually answered, which the hub knows even when the
requester did not.
Sourcepub fn forwarded_request_headers(
&self,
requester: &PartyRef,
receiver: &PartyRef,
) -> Option<RoutingHeaders>
pub fn forwarded_request_headers( &self, requester: &PartyRef, receiver: &PartyRef, ) -> Option<RoutingHeaders>
The headers the hub puts on the request it forwards to the receiving party.
Returns None for GetAllViaHub, where the hub answers from its
own merged view and forwards nothing verbatim.
Sourcepub const fn allows_get(&self) -> bool
pub const fn allows_get(&self) -> bool
Whether a GET may use this scenario.
GET SHALL NOT be used in combination with Broadcast Push. If the requesting party wants to GET information of which it does not know the receiving party, an Open Routing Request MUST be used.
Sourcepub const fn allows_write(&self) -> bool
pub const fn allows_write(&self) -> bool
Whether a write (POST, PUT, PATCH, DELETE) may use this scenario.
A GET All is by definition a read.
Trait Implementations§
Source§impl Clone for RoutingScenario
impl Clone for RoutingScenario
Source§fn clone(&self) -> RoutingScenario
fn clone(&self) -> RoutingScenario
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RoutingScenario
impl Debug for RoutingScenario
impl Eq for RoutingScenario
Source§impl PartialEq for RoutingScenario
impl PartialEq for RoutingScenario
impl StructuralPartialEq for RoutingScenario
Auto Trait Implementations§
impl Freeze for RoutingScenario
impl RefUnwindSafe for RoutingScenario
impl Send for RoutingScenario
impl Sync for RoutingScenario
impl Unpin for RoutingScenario
impl UnsafeUnpin for RoutingScenario
impl UnwindSafe for RoutingScenario
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.