3#include "rpc/common/Concepts.hpp"
4#include "rpc/common/Types.hpp"
5#include "rpc/common/impl/Processors.hpp"
7#include <boost/json/value.hpp>
33 : pimpl_{std::make_unique<Model<HandlerType, ProcessingStrategy>>(
34 std::forward<HandlerType>(handler)
49 pimpl_.swap(copy.pimpl_);
65 [[nodiscard]] ReturnType
68 return pimpl_->process(value, ctx);
73 virtual ~Concept() =
default;
76 process(boost::json::value
const& value,
Context const& ctx)
const = 0;
78 [[nodiscard]]
virtual std::unique_ptr<Concept>
82 template <
typename HandlerType,
typename ProcessorType>
83 struct Model : Concept {
85 ProcessorType processor;
87 Model(HandlerType&& handler) : handler{std::move(handler)}
91 [[nodiscard]] ReturnType
92 process(boost::json::value
const& value, Context
const& ctx)
const override
94 return processor(handler, value, ctx);
97 [[nodiscard]] std::unique_ptr<Concept>
98 clone()
const override
100 return std::make_unique<Model>(*
this);
105 std::unique_ptr<Concept> pimpl_;
A type-erased Handler that can contain any (NextGen) RPC handler class.
Definition AnyHandler.hpp:20
ReturnType process(boost::json::value const &value, Context const &ctx) const
Process incoming JSON by the stored handler.
Definition AnyHandler.hpp:66
AnyHandler(HandlerType &&handler)
Type-erases any handler class.
Definition AnyHandler.hpp:32
Specifies what a Handler type must provide.
Definition Concepts.hpp:84
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
Context of an RPC call.
Definition Types.hpp:99
The final return type out of RPC engine.
Definition Types.hpp:67
Definition Processors.hpp:12