pub struct OcpiRequest {
pub method: Method,
pub url: Url,
pub module: ModuleId,
pub routing: Option<RoutingHeaders>,
pub ids: RequestIds,
pub body: Option<Vec<u8>>,
}client only.Expand description
One outgoing OCPI request, before it is sent.
Fields§
§method: MethodThe HTTP method.
url: UrlThe absolute URL to call.
module: ModuleIdThe module the request addresses, which decides whether routing headers apply.
routing: Option<RoutingHeaders>The routing headers, when the module is a functional one.
ids: RequestIdsThe request and correlation IDs.
body: Option<Vec<u8>>The JSON body, already serialised.
Implementations§
Source§impl OcpiRequest
impl OcpiRequest
Sourcepub fn new(method: Method, url: Url, module: ModuleId) -> Self
pub fn new(method: Method, url: Url, module: ModuleId) -> Self
A request with freshly generated IDs and no body.
Sourcepub fn routed(self, routing: RoutingHeaders) -> Self
pub fn routed(self, routing: RoutingHeaders) -> Self
Attaches routing headers, which are dropped for a configuration module.
routing headers SHALL NOT be used with these modules
Sourcepub fn with_ids(self, ids: RequestIds) -> Self
pub fn with_ids(self, ids: RequestIds) -> Self
Attaches the request and correlation IDs.
Sourcepub fn with_body<T: Serialize>(self, body: &T) -> Result<Self, OcpiError>
pub fn with_body<T: Serialize>(self, body: &T) -> Result<Self, OcpiError>
Serialises body as the request body.
§Errors
Returns OcpiError::Decode if the value cannot be serialised.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the specification permits retrying this request automatically.
OCPI messages SHOULD NOT be queued. When a client does a POST, PUT or PATCH request and that request fails or times out, the client should not queue the message and retry the same message again later.
Only GET is retryable.