11#ifndef MODDEF_ERROR_HPP
12#define MODDEF_ERROR_HPP
18#include "moddef/err.h"
47inline md_err_t
to_c(
Error e)
noexcept {
return static_cast<md_err_t
>(e); }
53using Result = std::expected<T, Error>;
58 if (e != MD_OK)
return std::unexpected(
from_c(e));
63 if (e != MD_OK)
return std::unexpected(
from_c(e));
Blocking register-level transport.
Definition transport.hpp:28
Error
Strongly typed mirror of md_err_t (same underlying values, so casts are free in both directions).
Definition error.hpp:25
std::expected< T, Error > Result
The canonical result type across the API; Result<void> for actions.
Definition error.hpp:53
Result< void > check(md_err_t e)
Definition error.hpp:62
md_err_t to_c(Error e) noexcept
Definition error.hpp:47
Result< T > ok_or(md_err_t e, T value)
Definition error.hpp:57
std::string_view to_string(Error e) noexcept
Definition error.hpp:49
Error from_c(md_err_t e) noexcept
Definition error.hpp:46