Skip to main content

Forwardable

Struct Forwardable 

Source
pub struct Forwardable {
    pub method: Method,
    pub module: ModuleId,
    pub interface: InterfaceRole,
    pub path: String,
    pub query: Option<String>,
    pub routing: RoutingHeaders,
    pub ids: RequestIds,
    pub body: Option<Vec<u8>>,
    pub version: VersionNumber,
}
Available on crate feature hub only.
Expand description

What the hub was asked to relay.

Fields§

§method: Method

The HTTP method of the incoming request.

§module: ModuleId

The module it addresses.

§interface: InterfaceRole

Which interface of that module.

§path: String

The path below the module endpoint, e.g. NL/TNM/LOC1.

§query: Option<String>

The query string, without the leading ?.

§routing: RoutingHeaders

The routing headers as they arrived.

§ids: RequestIds

The IDs as they arrived. The hub renews the request ID and keeps the correlation ID.

§body: Option<Vec<u8>>

The request body, if any.

§version: VersionNumber

The OCPI version the body is written in — the version of the endpoint it arrived on.

A hub is the one place where the two ends of a conversation need not agree on it, so the forwarder translates between this and whatever the receiving platform speaks. See Forwarder::relay.

Implementations§

Source§

impl Forwardable

Source

pub fn scenario(&self, hub: &PartyRef) -> Result<RoutingScenario, OcpiError>

The scenario this request is, from its headers and method.

To send a Broadcast Push, the client uses the party-id and country-code of the Hub in the ‘OCPI-to-’ headers.

When … the requesting party does not know the destination of a request, the ‘OCPI-to-’ headers can be omitted.

To request a GET All from a Hub, the client uses the party-id and country-code of the Hub in the ‘OCPI-to-’ headers, and calls the GET method on the Sender interface.

§Why this can fail

Addressing the hub itself is the one ambiguous case: it means a Broadcast Push for a write and a GET All for a GET on a Sender interface, and the two remaining combinations are not scenarios at all.

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.

A GET on a Receiver interface addressed to the hub is therefore refused rather than quietly broadcast — the sender is told to omit the OCPI-to- headers instead — and so is a write addressed to the hub on a Sender interface, which is neither a push to the connected parties nor a read to merge.

§Errors

Returns OcpiError::NotRoutable, a 2001, for those two combinations.

Spec: 2.3.0 §transport_and_format_message_routing

Source

pub fn url_at(&self, base: &Url) -> Url

The URL this request becomes at base, the receiving platform’s endpoint for the module.

Trait Implementations§

Source§

impl Debug for Forwardable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more