pub struct Selected { /* private fields */ }client only.Expand description
Step 2: the peer’s endpoints for the chosen version are known, and can be checked before anything is sent.
Implementations§
Source§impl Selected
impl Selected
Sourcepub const fn version(&self) -> &VersionNumber
pub const fn version(&self) -> &VersionNumber
The version that was selected.
Sourcepub const fn details(&self) -> &VersionDetails
pub const fn details(&self) -> &VersionDetails
The endpoints the peer advertised for it.
Sourcepub fn require(
&self,
required: &[(ModuleId, InterfaceRole)],
) -> Result<(), OcpiError>
pub fn require( &self, required: &[(ModuleId, InterfaceRole)], ) -> Result<(), OcpiError>
Checks that the peer implements everything this party needs.
In case the Sender (starting the credentials exchange process) cannot find the endpoints it expects, it is expected NOT to send the POST request with credentials to the Receiver. Log a message/notify the administrator.
§Errors
Returns OcpiError::Remote with 3003 No matching endpoints naming what is missing.
Call this before Selected::register; nothing has been sent to the peer yet, so
stopping here is exactly what the specification asks for.
Sourcepub async fn register(
self,
transport: &Transport,
credentials: &Credentials,
) -> Result<Peer, OcpiError>
pub async fn register( self, transport: &Transport, credentials: &Credentials, ) -> Result<Peer, OcpiError>
POST {credentials} with CREDENTIALS_TOKEN_B, receiving CREDENTIALS_TOKEN_C.
Consumes self, so CREDENTIALS_TOKEN_A is gone afterwards: “it MAY no longer be
used.”
credentials must carry CREDENTIALS_TOKEN_B — the token the peer will use to call
this party — and the versions URL of this party. The token in the response is
CREDENTIALS_TOKEN_C, which is what the returned Peer authenticates with.
§Errors
Returns OcpiError::MethodNotAllowed when the peer says this party is already
registered — “This method MUST return a HTTP status code 405: method not allowed if the
client has already been registered before” — and OcpiError::Remote with 3001 when
the peer could not call back.
Sourcepub async fn update(
self,
transport: &Transport,
current_token: &CredentialsToken,
credentials: &Credentials,
) -> Result<Peer, OcpiError>
pub async fn update( self, transport: &Transport, current_token: &CredentialsToken, credentials: &Credentials, ) -> Result<Peer, OcpiError>
PUT {credentials}, for a peer this party is already registered with.
A
PUTwill switch to the version that contains this credentials endpoint if it’s different from the current version. The server must fetch the client’s endpoints again, even if the version has not changed.
§Errors
Returns OcpiError::MethodNotAllowed when the peer says this party is not registered
— the mirror image of Selected::register.