pub struct CallbackUrls { /* private fields */ }server only.Expand description
Builds the response_urls that reach the callbacks this crate’s router mounts.
The asynchronous halves of the Commands and Charging Profiles modules are the one place where OCPI hands the URL shape to the implementation:
No structure defined. This is open to the eMSP to define, the URL is provided to the Receiver by the Sender.
That freedom is easy to get wrong in a way that only shows up minutes later, when a Charge
Point answers into a 404. So the Sender-side mounts on OcpiRouter use fixed shapes, and
this type builds exactly those — pass the same base_url the router is published under and
the two cannot drift apart.
use ocpi_kit::server::CallbackUrls;
use ocpi_kit::types::Url;
let urls = CallbackUrls::new(Url::new("https://msp.example.com/ocpi/emsp/2.3.0").unwrap());
assert_eq!(
urls.command_result("RESERVE_NOW", "1234").as_str(),
"https://msp.example.com/ocpi/emsp/2.3.0/commands/RESERVE_NOW/1234",
);
assert_eq!(
urls.clear_profile_result("5678").as_str(),
"https://msp.example.com/ocpi/emsp/2.3.0/chargingprofiles/result/clear/5678",
);Implementations§
Source§impl CallbackUrls
impl CallbackUrls
Sourcepub const fn new(base_url: Url) -> Self
pub const fn new(base_url: Url) -> Self
Callback URLs under base_url, which must be the URL this party’s router is published at.
Sourcepub fn command_result(&self, command: &str, unique_id: &str) -> Url
pub fn command_result(&self, command: &str, unique_id: &str) -> Url
{base}/commands/{command}/{unique_id} — where a CommandResult is expected.
Put this in the response_url of a
Command; it reaches
CommandsSender::command_result with unique_id.
Sourcepub fn active_charging_profile_result(&self, unique_id: &str) -> Url
pub fn active_charging_profile_result(&self, unique_id: &str) -> Url
{base}/chargingprofiles/result/active/{unique_id} — for an ActiveChargingProfileResult.
Sourcepub fn charging_profile_result(&self, unique_id: &str) -> Url
pub fn charging_profile_result(&self, unique_id: &str) -> Url
{base}/chargingprofiles/result/set/{unique_id} — for a ChargingProfileResult.
Sourcepub fn clear_profile_result(&self, unique_id: &str) -> Url
pub fn clear_profile_result(&self, unique_id: &str) -> Url
{base}/chargingprofiles/result/clear/{unique_id} — for a ClearProfileResult.
Trait Implementations§
Source§impl Clone for CallbackUrls
impl Clone for CallbackUrls
Source§fn clone(&self) -> CallbackUrls
fn clone(&self) -> CallbackUrls
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 CallbackUrls
impl Debug for CallbackUrls
impl Eq for CallbackUrls
Source§impl PartialEq for CallbackUrls
impl PartialEq for CallbackUrls
impl StructuralPartialEq for CallbackUrls
Auto Trait Implementations§
impl Freeze for CallbackUrls
impl RefUnwindSafe for CallbackUrls
impl Send for CallbackUrls
impl Sync for CallbackUrls
impl Unpin for CallbackUrls
impl UnsafeUnpin for CallbackUrls
impl UnwindSafe for CallbackUrls
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.