Skip to main content

RoutingTable

Struct RoutingTable 

Source
pub struct RoutingTable { /* private fields */ }
Available on crate feature hub only.
Expand description

The hub’s map from party to platform.

A hub’s whole job is answering “who is NL/TNM, and can I reach them right now?”, and turning a “no” into the right one of the four 4xxx codes:

CodeMeaning
4001Unknown receiver: the OCPI-to-* address is unknown
4002Timeout on a forwarded request
4003Connection problem: the receiving party is not connected
4000Anything else

Spec: 2.3.0 §status_codes_4xxx_hub_errors

Implementations§

Source§

impl RoutingTable

Source

pub fn new() -> Self

An empty table.

Source

pub fn upsert(&self, platform: ConnectedPlatform)

Adds or replaces a platform.

Source

pub fn remove(&self, platform_id: &str) -> bool

Removes a platform, as an unregistration does.

Source

pub fn set_status(&self, platform_id: &str, status: ConnectionStatus) -> bool

Records a platform’s connection status, which the hubclientinfo module publishes.

Source

pub fn with_platform<T>( &self, party: &PartyRef, f: impl FnOnce(&ConnectedPlatform) -> T, ) -> Result<T, OcpiError>

Runs f over the platform hosting party.

§Errors

Returns 4001 Unknown receiver when no platform hosts the party, and 4003 Connection problem when the platform is known but not connected.

Source

pub fn knows(&self, party: &PartyRef) -> bool

Whether the hub knows party at all, connected or not.

Source

pub fn platform_of(&self, party: &PartyRef) -> Option<String>

The platform id hosting party.

Source

pub fn broadcast_targets( &self, sender: &PartyRef, sender_role: Role, module: &ModuleId, ) -> Vec<(String, PartyRef)>

The parties a Broadcast Push from sender should reach for module.

For simplicity, connected clients might push (POST, PUT, PATCH) information to all connected clients with an “opposite role” … When using Broadcast Push, the Hub broadcasts received information to all connected clients … using its own party-id and country-code in the ‘OCPI-from-’ headers.

A party is a recipient when it is connected, fills a role that receives from the sender’s role, implements the module’s Receiver interface, and is not the sender itself.

Spec: 2.3.0 §transport_and_format_message_routing_broadcast_push

Source

pub fn get_all_sources( &self, requester: &PartyRef, module: &ModuleId, ) -> Vec<(String, PartyRef)>

Every party that implements a module’s Sender interface, for a GET All.

A client (Receiver) can request a GET on the Sender interface of a module implemented by a Hub. The Hub can then combine objects from different connected parties.

Spec: 2.3.0 §transport_and_format_get_all_via_hubs

Source

pub fn platform_ids(&self) -> Vec<String>

Every platform the hub knows, connected or not.

Source

pub fn client_info(&self) -> Vec<(PartyRef, Role, ConnectionStatus)>

Every party the hub knows, with its role and connection status.

This is what the hubclientinfo module publishes.

Trait Implementations§

Source§

impl Debug for RoutingTable

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for RoutingTable

Source§

fn default() -> RoutingTable

Returns the “default value” for a type. 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