3#include "rpc/common/Checkers.hpp"
4#include "rpc/common/Concepts.hpp"
5#include "rpc/common/Types.hpp"
6#include "rpc/common/impl/Factories.hpp"
8#include <boost/json/array.hpp>
9#include <boost/json/value.hpp>
11#include <initializer_list>
31 FieldSpec(std::string
const& key, Processors&&... processors)
33 impl::makeFieldProcessor<Processors...>(key, std::forward<Processors>(processors)...)
35 , checker_{impl::kEMPTY_FIELD_CHECKER}
47 FieldSpec(std::string
const& key, Checks&&... checks)
48 : processor_{impl::kEMPTY_FIELD_PROCESSOR}
49 , checker_{impl::makeFieldChecker<Checks...>(key, std::forward<Checks>(checks)...)}
60 process(boost::json::value& value)
const;
68 [[nodiscard]] check::Warnings
69 check(boost::json::value
const& value)
const;
72 impl::FieldSpecProcessor processor_;
73 impl::FieldChecker checker_;
88 RpcSpec(std::initializer_list<FieldSpec> fields) : fields_{fields}
98 RpcSpec(
RpcSpec const& other, std::initializer_list<FieldSpec> additionalFields)
99 : fields_{other.fields_}
101 for (
auto& f : additionalFields)
102 fields_.push_back(f);
112 process(boost::json::value& value)
const;
120 [[nodiscard]] boost::json::array
121 check(boost::json::value
const& value)
const;
124 std::vector<FieldSpec> fields_;
Specifies what a check used with rpc::FieldSpec must provide.
Definition Concepts.hpp:39
The requirements of a processor to be used with rpc::FieldSpec.
Definition Concepts.hpp:47
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
RpcSpec const & RpcSpecConstRef
An alias for a const reference to RpcSpec.
Definition Specs.hpp:130
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:36
FieldSpec(std::string const &key, Checks &&... checks)
Construct a field specification out of a set of checkers.
Definition Specs.hpp:47
MaybeError process(boost::json::value &value) const
Processes the passed JSON value using the stored processors.
Definition Specs.cpp:18
check::Warnings check(boost::json::value const &value) const
Checks the passed JSON value using the stored checkers.
Definition Specs.cpp:24
FieldSpec(std::string const &key, Processors &&... processors)
Construct a field specification out of a set of processors.
Definition Specs.hpp:31
Represents a Specification of an entire RPC command.
Definition Specs.hpp:82
MaybeError process(boost::json::value &value) const
Processes the passed JSON value using the stored field specs.
Definition Specs.cpp:30
RpcSpec(std::initializer_list< FieldSpec > fields)
Construct a full RPC request specification.
Definition Specs.hpp:88
RpcSpec(RpcSpec const &other, std::initializer_list< FieldSpec > additionalFields)
Construct a full RPC request specification from another spec and additional fields.
Definition Specs.hpp:98
boost::json::array check(boost::json::value const &value) const
Checks the passed JSON value using the stored field specs.
Definition Specs.cpp:41