Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Concepts.hpp
1#pragma once
2
3#include "rpc/Errors.hpp"
4#include "rpc/common/SpecBackend.hpp"
5#include "rpc/common/Types.hpp"
6
7#include <boost/json/value.hpp>
8#include <boost/json/value_from.hpp>
9#include <boost/json/value_to.hpp>
10#include <rpcspec/Errors.hpp>
11
12#include <concepts>
13#include <cstdint>
14#include <expected>
15#include <optional>
16#include <string>
17
18namespace rpc {
19
23template <typename T>
25 requires(T a, T::Input const& in, T::Output out, Context const& ctx) {
26 { a.process(in, ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
27 };
28
32template <typename T>
33concept SomeContextProcessWithoutInput = requires(T a, T::Output out, Context const& ctx) {
34 { a.process(ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
35};
36
44template <typename T>
45concept SomeHandlerWithTypedInput = requires(uint32_t version, boost::json::value jv) {
46 typename T::Input;
47 { T::parseInput(jv, version) } -> std::same_as<std::expected<typename T::Input, Status>>;
48 { T::spec(version) } -> std::same_as<SpecView>;
50
54template <typename T>
56
60template <typename T>
62 boost::json::has_value_from<typename T::Output>::value;
63
64} // namespace rpc
A process function that expects both some Input and a Context.
Definition Concepts.hpp:24
A process function that expects no Input but does take a Context.
Definition Concepts.hpp:33
Specifies what a Handler validated by the shared consteval spec must provide.
Definition Concepts.hpp:45
Specifies what a Handler without Input must provide.
Definition Concepts.hpp:55
Specifies what a Handler type must provide.
Definition Concepts.hpp:61
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:61
Context of an RPC call.
Definition Types.hpp:98