pub trait CredentialsHandler:
Send
+ Sync
+ 'static {
// Required methods
fn get(
&self,
context: RequestContext,
) -> impl Future<Output = Handled<Credentials>> + Send;
fn post(
&self,
credentials: Credentials,
context: RequestContext,
) -> impl Future<Output = Handled<Credentials>> + Send;
fn put(
&self,
credentials: Credentials,
context: RequestContext,
) -> impl Future<Output = Handled<Credentials>> + Send;
fn delete(
&self,
context: RequestContext,
) -> impl Future<Output = Handled<()>> + Send;
}server only.Expand description
The credentials module, which every implementation must serve.
The four methods are the registration lifecycle. The two 405 rules are the ones most often missed, and the router does not enforce them for you because only the implementation knows whether a peer is registered:
POST … MUST return a HTTP status code 405: method not allowed if the client has already been registered before.
PUT … MUST return a HTTP status code 405: method not allowed if the client has not been registered yet.
Return OcpiError::MethodNotAllowed for those;
PeerState has the predicates.
Spec: 2.3.0 §credentials_credentials_endpoint
Required Methods§
Sourcefn get(
&self,
context: RequestContext,
) -> impl Future<Output = Handled<Credentials>> + Send
fn get( &self, context: RequestContext, ) -> impl Future<Output = Handled<Credentials>> + Send
GET {credentials} — this party’s own credentials object.
Sourcefn post(
&self,
credentials: Credentials,
context: RequestContext,
) -> impl Future<Output = Handled<Credentials>> + Send
fn post( &self, credentials: Credentials, context: RequestContext, ) -> impl Future<Output = Handled<Credentials>> + Send
POST {credentials} — register.
The implementation must fetch the client’s versions and version details with the token in
credentials before answering, and answer 3001 if that fails:
When the initializing party requests data from the other party during the open POST call to its credentials endpoint. If one of the GETs can not be processed, the party should return this error in the POST response.
Sourcefn put(
&self,
credentials: Credentials,
context: RequestContext,
) -> impl Future<Output = Handled<Credentials>> + Send
fn put( &self, credentials: Credentials, context: RequestContext, ) -> impl Future<Output = Handled<Credentials>> + Send
PUT {credentials} — update, rotate the token, or switch version.
The server must fetch the client’s endpoints again, even if the version has not changed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl CredentialsHandler for MockPeer
testkit only.