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>
49 FieldSpec(std::string
const& key, Processors&&... processors)
50 : processor_{impl::makeFieldProcessor<Processors...>(key, std::forward<Processors>(processors)...)}
51 , checker_{impl::kEMPTY_FIELD_CHECKER}
63 FieldSpec(std::string
const& key, Checks&&... checks)
64 : processor_{impl::kEMPTY_FIELD_PROCESSOR}
65 , checker_{impl::makeFieldChecker<Checks...>(key, std::forward<Checks>(checks)...)}
76 process(boost::json::value& value)
const;
84 [[nodiscard]] check::Warnings
85 check(boost::json::value
const& value)
const;
88 impl::FieldSpecProcessor processor_;
89 impl::FieldChecker checker_;
104 RpcSpec(std::initializer_list<FieldSpec> fields) : fields_{fields}
114 RpcSpec(
RpcSpec const& other, std::initializer_list<FieldSpec> additionalFields) : fields_{other.fields_}
116 for (
auto& f : additionalFields)
117 fields_.push_back(f);
127 process(boost::json::value& value)
const;
135 [[nodiscard]] boost::json::array
136 check(boost::json::value
const& value)
const;
139 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:36
RpcSpec const & RpcSpecConstRef
An alias for a const reference to RpcSpec.
Definition Specs.hpp:145
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
Represents a Specification for one field of an RPC command.
Definition Specs.hpp:40
FieldSpec(std::string const &key, Checks &&... checks)
Construct a field specification out of a set of checkers.
Definition Specs.hpp:63
MaybeError process(boost::json::value &value) const
Processes the passed JSON value using the stored processors.
Definition Specs.cpp:37
FieldSpec(std::string const &key, Processors &&... processors)
Construct a field specification out of a set of processors.
Definition Specs.hpp:49
Represents a Specification of an entire RPC command.
Definition Specs.hpp:98
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:104
RpcSpec(RpcSpec const &other, std::initializer_list< FieldSpec > additionalFields)
Construct a full RPC request specification from another spec and additional fields.
Definition Specs.hpp:114