22#include "rpc/common/Concepts.hpp"
23#include "rpc/common/Types.hpp"
24#include "rpc/common/impl/Processors.hpp"
26#include <boost/json/value.hpp>
52 : pimpl_{std::make_unique<Model<HandlerType, ProcessingStrategy>>(
53 std::forward<HandlerType>(handler)
68 pimpl_.swap(copy.pimpl_);
84 [[nodiscard]] ReturnType
87 return pimpl_->process(value, ctx);
92 virtual ~Concept() =
default;
95 process(boost::json::value
const& value,
Context const& ctx)
const = 0;
97 [[nodiscard]]
virtual std::unique_ptr<Concept>
101 template <
typename HandlerType,
typename ProcessorType>
102 struct Model : Concept {
104 ProcessorType processor;
106 Model(HandlerType&& handler) : handler{std::move(handler)}
110 [[nodiscard]] ReturnType
111 process(boost::json::value
const& value, Context
const& ctx)
const override
113 return processor(handler, value, ctx);
116 [[nodiscard]] std::unique_ptr<Concept>
117 clone()
const override
119 return std::make_unique<Model>(*
this);
124 std::unique_ptr<Concept> pimpl_;
A type-erased Handler that can contain any (NextGen) RPC handler class.
Definition AnyHandler.hpp:39
ReturnType process(boost::json::value const &value, Context const &ctx) const
Process incoming JSON by the stored handler.
Definition AnyHandler.hpp:85
AnyHandler(HandlerType &&handler)
Type-erases any handler class.
Definition AnyHandler.hpp:51
Specifies what a Handler type must provide.
Definition Concepts.hpp:103
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37
Context of an RPC call.
Definition Types.hpp:118
The final return type out of RPC engine.
Definition Types.hpp:86
Definition Processors.hpp:31