#include #include #include namespace kapi::devices { namespace { struct driver_match_category_t final : kstd::error_category { [[nodiscard]] auto name() const noexcept -> std::string_view override { return "driver_match"; } [[nodiscard]] auto message(int value) const noexcept -> std::string_view override { switch (static_cast(value)) { case driver_match_errc::no_match: return "driver does not match this device"; case driver_match_errc::no_device_signature: return "missing device signature"; case driver_match_errc::invalid_device_signature: return "device signature is invalid"; default: return "unknown driver matching error"; } } [[nodiscard]] auto default_error_condition(int value) const noexcept -> kstd::error_condition override { switch (static_cast(value)) { case driver_match_errc::no_match: case driver_match_errc::no_device_signature: return make_error_condition(kstd::errc::not_supported); break; case driver_match_errc::invalid_device_signature: return make_error_condition(kstd::errc::invalid_argument); default: return kstd::error_category::default_error_condition(value); } } } constexpr driver_match_category_instance{}; } // namespace auto driver_match_category() noexcept -> kstd::error_category const & { return driver_match_category_instance; } } // namespace kapi::devices