22#include "rpc/common/Checkers.hpp"
23#include "rpc/common/Concepts.hpp"
24#include "rpc/common/Types.hpp"
25#include "rpc/common/impl/Factories.hpp"
27#include <boost/json/array.hpp>
28#include <boost/json/value.hpp>
30#include <initializer_list>
50 FieldSpec(std::string
const& key, Processors&&... processors)
51 : processor_{impl::makeFieldProcessor<Processors...>(
53 std::forward<Processors>(processors)...
55 , checker_{impl::kEMPTY_FIELD_CHECKER}
67 FieldSpec(std::string
const& key, Checks&&... checks)
68 : processor_{impl::kEMPTY_FIELD_PROCESSOR}
69 , checker_{impl::makeFieldChecker<Checks...>(key, std::forward<Checks>(checks)...)}
80 process(boost::json::value& value)
const;
88 [[nodiscard]] check::Warnings
89 check(boost::json::value
const& value)
const;
92 impl::FieldSpecProcessor processor_;
93 impl::FieldChecker checker_;
108 RpcSpec(std::initializer_list<FieldSpec> fields) : fields_{fields}
119 : fields_{other.fields_}
121 for (
auto& f : additionalFields)
122 fields_.push_back(f);
132 process(boost::json::value& value)
const;
140 [[nodiscard]] boost::json::array
141 check(boost::json::value
const& value)
const;
144 std::vector<FieldSpec> fields_;
Specifies what a check used with rpc::FieldSpec must provide.
Definition Concepts.hpp:58
The requirements of a processor to be used with rpc::FieldSpec.
Definition Concepts.hpp:66
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37
RpcSpec const & RpcSpecConstRef
An alias for a const reference to RpcSpec.
Definition Specs.hpp:150
std::expected< void, Status > MaybeError
Return type used for Validators that can return error but don't have specific value to return.
Definition Types.hpp:55
FieldSpec(std::string const &key, Checks &&... checks)
Construct a field specification out of a set of checkers.
Definition Specs.hpp:67
MaybeError process(boost::json::value &value) const
Processes the passed JSON value using the stored processors.
Definition Specs.cpp:37
check::Warnings check(boost::json::value const &value) const
Checks the passed JSON value using the stored checkers.
Definition Specs.cpp:43
FieldSpec(std::string const &key, Processors &&... processors)
Construct a field specification out of a set of processors.
Definition Specs.hpp:50
Represents a Specification of an entire RPC command.
Definition Specs.hpp:102
MaybeError process(boost::json::value &value) const
Processes the passed JSON value using the stored field specs.
Definition Specs.cpp:49
RpcSpec(std::initializer_list< FieldSpec > fields)
Construct a full RPC request specification.
Definition Specs.hpp:108
RpcSpec(RpcSpec const &other, std::initializer_list< FieldSpec > additionalFields)
Construct a full RPC request specification from another spec and additional fields.
Definition Specs.hpp:118
boost::json::array check(boost::json::value const &value) const
Checks the passed JSON value using the stored field specs.
Definition Specs.cpp:60