pub struct Request<TReq, TResp>where
TReq: PayloadSerialize,
TResp: PayloadSerialize,{
pub payload: TReq,
pub content_type: Option<String>,
pub format_indicator: FormatIndicator,
pub custom_user_data: Vec<(String, String)>,
pub timestamp: Option<HybridLogicalClock>,
pub invoker_id: Option<String>,
pub topic_tokens: HashMap<String, String>,
/* private fields */
}
Expand description
Command Executor Request struct.
Used by the Executor
If dropped, executor will send an error response to the invoker
Fields§
§payload: TReq
Payload of the command request.
content_type: Option<String>
Content Type of the command request.
format_indicator: FormatIndicator
Format Indicator of the command request.
custom_user_data: Vec<(String, String)>
Custom user data set as custom MQTT User Properties on the request message.
timestamp: Option<HybridLogicalClock>
Timestamp of the command request.
invoker_id: Option<String>
If present, contains the client ID of the invoker of the command.
topic_tokens: HashMap<String, String>
Resolved static and dynamic topic tokens from the incoming request’s topic.
Implementations§
Source§impl<TReq, TResp> Request<TReq, TResp>where
TReq: PayloadSerialize,
TResp: PayloadSerialize,
impl<TReq, TResp> Request<TReq, TResp>where
TReq: PayloadSerialize,
TResp: PayloadSerialize,
Sourcepub async fn complete(
self,
response: Response<TResp>,
) -> Result<(), AIOProtocolError>
pub async fn complete( self, response: Response<TResp>, ) -> Result<(), AIOProtocolError>
Consumes the command request and reports the response to the executor. An attempt is made to send the response to the invoker.
Returns Ok(()) on success, otherwise returns AIOProtocolError
.
§Arguments
response
- TheResponse
to send.
§Errors
AIOProtocolError
of kind Timeout
if the command request
has expired.
AIOProtocolError
of kind ClientError
if the response
acknowledgement returns an error.
AIOProtocolError
of kind Cancellation
if the
executor is dropped.
AIOProtocolError
of kind InternalLogicError
if the response publish completion fails. This should not happen.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the command response is no longer expected.
Returns true if the response is no longer expected, otherwise returns false.