Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
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
18
namespace
rpc
{
19
23
template
<
typename
T>
24
concept
SomeContextProcessWithInput
=
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
32
template
<
typename
T>
33
concept
SomeContextProcessWithoutInput
=
requires
(T a, T::Output out,
Context
const
& ctx) {
34
{ a.process(ctx) } -> std::same_as<
HandlerReturnType
<
decltype
(out)>>;
35
};
36
44
template
<
typename
T>
45
concept
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>;
49
} and
SomeContextProcessWithInput<T>
;
50
54
template
<
typename
T>
55
concept
SomeHandlerWithoutInput
=
SomeContextProcessWithoutInput<T>
;
56
60
template
<
typename
T>
61
concept
SomeHandler
= (
SomeHandlerWithTypedInput<T>
or
SomeHandlerWithoutInput<T>
) and
62
boost::json::has_value_from<typename T::Output>::value;
63
64
}
// namespace rpc
Errors.hpp
rpc::SomeContextProcessWithInput
A process function that expects both some Input and a Context.
Definition
Concepts.hpp:24
rpc::SomeContextProcessWithoutInput
A process function that expects no Input but does take a Context.
Definition
Concepts.hpp:33
rpc::SomeHandlerWithTypedInput
Specifies what a Handler validated by the shared consteval spec must provide.
Definition
Concepts.hpp:45
rpc::SomeHandlerWithoutInput
Specifies what a Handler without Input must provide.
Definition
Concepts.hpp:55
rpc::SomeHandler
Specifies what a Handler type must provide.
Definition
Concepts.hpp:61
rpc
This namespace contains all the RPC logic and handlers.
Definition
AMMHelpers.cpp:17
rpc::HandlerReturnType
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition
Types.hpp:61
rpc::Context
Context of an RPC call.
Definition
Types.hpp:98
src
rpc
common
Concepts.hpp
Generated by
1.17.0