## Summary **What is the goal of this PR?** Replace SFINAE std::enable_if_t with a C++20 `requires` clause for clearer constraint expression and better compiler diagnostics on mismatch. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_
69 lines
1.3 KiB
C++
69 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
#include <variant>
|
|
|
|
struct WifiResult {
|
|
bool connected = false;
|
|
std::string ssid;
|
|
std::string ip;
|
|
};
|
|
|
|
struct KeyboardResult {
|
|
std::string text;
|
|
};
|
|
|
|
struct MenuResult {
|
|
int action = -1;
|
|
uint8_t orientation = 0;
|
|
uint8_t pageTurnOption = 0;
|
|
};
|
|
|
|
struct ChapterResult {
|
|
int spineIndex = 0;
|
|
};
|
|
|
|
struct PercentResult {
|
|
int percent = 0;
|
|
};
|
|
|
|
struct PageResult {
|
|
uint32_t page = 0;
|
|
};
|
|
|
|
struct SyncResult {
|
|
int spineIndex = 0;
|
|
int page = 0;
|
|
};
|
|
|
|
enum class NetworkMode;
|
|
|
|
struct NetworkModeResult {
|
|
NetworkMode mode;
|
|
};
|
|
|
|
struct FootnoteResult {
|
|
std::string href;
|
|
};
|
|
|
|
using ResultVariant = std::variant<std::monostate, WifiResult, KeyboardResult, MenuResult, ChapterResult, PercentResult,
|
|
PageResult, SyncResult, NetworkModeResult, FootnoteResult>;
|
|
|
|
struct ActivityResult {
|
|
bool isCancelled = false;
|
|
ResultVariant data;
|
|
|
|
explicit ActivityResult() = default;
|
|
|
|
template <typename ResultType>
|
|
requires std::is_constructible_v<ResultVariant, ResultType&&>
|
|
// cppcheck-suppress noExplicitConstructor
|
|
ActivityResult(ResultType&& result) : data{std::forward<ResultType>(result)} {}
|
|
};
|
|
|
|
using ActivityResultHandler = std::function<void(const ActivityResult&)>;
|