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/Checkers.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
11#include <cstdint>
12#include <optional>
13#include <string>
14
15namespace rpc {
16
17struct RpcSpec;
18
22template <typename T>
23concept SomeRequirement = requires(T a, boost::json::value lval) {
24 { a.verify(lval, std::string{}) } -> std::same_as<MaybeError>;
25};
26
30template <typename T>
31concept SomeModifier = requires(T a, boost::json::value lval) {
32 { a.modify(lval, std::string{}) } -> std::same_as<MaybeError>;
33};
34
38template <typename T>
39concept SomeCheck = requires(T a, boost::json::value lval) {
40 { a.check(lval, std::string{}) } -> std::same_as<std::optional<check::Warning>>;
41};
42
46template <typename T>
48
52template <typename T>
54 requires(T a, typename T::Input const& in, typename T::Output out, Context const& ctx) {
55 { a.process(in, ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
56 };
57
61template <typename T>
62concept SomeContextProcessWithoutInput = requires(T a, typename T::Output out, Context const& ctx) {
63 { a.process(ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
64};
65
69template <typename T>
70concept SomeHandlerWithInput = requires(T a, uint32_t version) {
71 { a.spec(version) } -> std::same_as<RpcSpec const&>;
72} and SomeContextProcessWithInput<T> and boost::json::has_value_to<typename T::Input>::value;
73
77template <typename T>
79
83template <typename T>
85 boost::json::has_value_from<typename T::Output>::value;
86
87} // namespace rpc
Specifies what a check used with rpc::FieldSpec must provide.
Definition Concepts.hpp:39
A process function that expects both some Input and a Context.
Definition Concepts.hpp:53
A process function that expects no Input but does take a Context.
Definition Concepts.hpp:62
Specifies what a Handler with Input must provide.
Definition Concepts.hpp:70
Specifies what a Handler without Input must provide.
Definition Concepts.hpp:78
Specifies what a Handler type must provide.
Definition Concepts.hpp:84
Specifies what a modifier used with rpc::FieldSpec must provide.
Definition Concepts.hpp:31
The requirements of a processor to be used with rpc::FieldSpec.
Definition Concepts.hpp:47
Specifies what a requirement used with rpc::FieldSpec must provide.
Definition Concepts.hpp:23
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:62
Context of an RPC call.
Definition Types.hpp:99
Represents a Specification of an entire RPC command.
Definition Specs.hpp:82