25 #include <type_traits>
28 #include "CancellationToken.h"
35 template <
typename Payload>
42 const Payload& GetPayload()
const {
return payload_; }
64 template <
typename Result,
typename Error,
typename Payload =
void>
90 typename P = Payload,
typename R = Result,
91 typename =
typename std::enable_if<!std::is_same<P, void>::value>::type,
93 typename std::enable_if<std::is_copy_constructible<R>::value>::type>
112 typename P = Payload,
typename R = Result,
113 typename =
typename std::enable_if<!std::is_same<P, void>::value>::type,
115 typename std::enable_if<std::is_move_constructible<R>::value>::type>
134 template <
typename P = Payload,
typename =
typename std::enable_if<
135 !std::is_same<P, void>::value>::type>
154 typename U,
typename P = Payload,
typename R = Result,
155 typename =
typename std::enable_if<std::is_same<P, void>::value>::type,
157 typename std::enable_if<std::is_copy_constructible<R>::value>::type>
176 typename U,
typename P = Payload,
typename R = Result,
177 typename =
typename std::enable_if<std::is_same<P, void>::value>::type,
179 typename std::enable_if<std::is_move_constructible<R>::value>::type>
195 result_(std::move(result)),
206 template <
typename P = Payload,
typename =
typename std::enable_if<
207 !std::is_same<P, void>::value>::type>
210 result_(std::move(result)),
219 : error_(error), success_(false) {}
226 template <
typename P = Payload,
typename =
typename std::enable_if<
227 !std::is_same<P, void>::value>::type>
271 bool success_{
false};
280 template <
typename T>
296 : cancel_token_(cancel_token), promise_(std::move(promise)) {}
305 return cancel_token_;
314 inline std::future<T>
GetFuture()
const {
return promise_->get_future(); }
Represents a request outcome.
Definition: ApiResponse.h:65
const ResultType & GetResult() const
Gets the result of the successfully executed request.
Definition: ApiResponse.h:245
ApiResponse(ApiResponse< R, Error, void > &&other)
Creates the ApiResponse instance from a similar response type without payload. The payload is default...
Definition: ApiResponse.h:116
ApiResponse(const ErrorType &error, P payload)
Creates the ApiResponse instance if the request is not successful.
Definition: ApiResponse.h:228
ResultType && MoveResult()
Moves the result of the successfully executed request.
Definition: ApiResponse.h:252
Payload PayloadType
The type of additional payload.
Definition: ApiResponse.h:74
ApiResponse(ResultType result)
Creates the ApiResponse instance.
Definition: ApiResponse.h:193
ApiResponse(const ApiResponse< Result, Error, void > &other, P payload)
Creates the ApiResponse instance from a similar response type without payload, and a separate payload...
Definition: ApiResponse.h:136
bool IsSuccessful() const
Checks the status of the request attempt.
Definition: ApiResponse.h:238
Result ResultType
The type of result.
Definition: ApiResponse.h:68
Error ErrorType
The type of error.
Definition: ApiResponse.h:71
ApiResponse(ResultType result, P payload)
Creates the ApiResponse instance with payload.
Definition: ApiResponse.h:208
ApiResponse(const ErrorType &error)
Creates the ApiResponse instance if the request is not successful.
Definition: ApiResponse.h:218
const ErrorType & GetError() const
Gets the error of the unsuccessful request attempt.
Definition: ApiResponse.h:259
ApiResponse(const ApiResponse< R, Error, void > &other)
Creates the ApiResponse instance from a similar response type without payload. The payload is default...
Definition: ApiResponse.h:94
ApiResponse(ApiResponse< R, Error, U > &&other)
Creates the ApiResponse instance from a similar request with a payload.
Definition: ApiResponse.h:180
ApiResponse(const ApiResponse< R, Error, U > &other)
Creates the ApiResponse instance from a similar request with a payload.
Definition: ApiResponse.h:158
A wrapper template that you can use to cancel a request or wait for it to finalize.
Definition: ApiResponse.h:281
const CancellationToken & GetCancellationToken() const
Gets the CancellationToken reference used to cancel the ongoing operation.
Definition: ApiResponse.h:304
CancellableFuture(const CancellationToken &cancel_token, PromisePtr promise)
Creates the CancellableFuture instance with CancellationToken and std::promise.
Definition: ApiResponse.h:295
std::shared_ptr< std::promise< T > > PromisePtr
The sharable promise type.
Definition: ApiResponse.h:286
std::future< T > GetFuture() const
Gets the future associated with the std::promise that you specified during initialization.
Definition: ApiResponse.h:314
Cancels service requests.
Definition: CancellationToken.h:33
Definition: ApiResponse.h:36
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24