move marshaller to IPC component

This commit is contained in:
Сергей Маринкевич
2025-12-04 14:11:15 +07:00
parent 31d0496a93
commit e7aa646a80
5 changed files with 34 additions and 26 deletions
@@ -4,9 +4,13 @@
#include <ipc/IpcCodec.h>
#include <rpc/RpcValue.h>
class ProxyMarshaller {
// Маршаллер, который знает, как превратить типизированный RPC-вызов
// в IpcMessage и обратно. Живёт в IPC-слое и опирается на IpcChannel
// и IpcCodec, но снаружи предъявляет только callTyped<T>(...).
class IpcMarshaller {
public:
explicit ProxyMarshaller(IpcChannel& ch) : channel(ch) {}
explicit IpcMarshaller(IpcChannel& ch)
: channel(ch) {}
// Базовый type-erased вызов: принимает вектор RpcValue и возвращает RpcValue.
RpcValue call(const std::string& method, const RpcArgs& args) {
@@ -21,7 +25,7 @@ public:
return IpcCodec::decodeResponse(resp);
}
// Удобный шаблонный хелпер для сгенерированных прокси.
// Типизированный хелпер: контрактом является только наличие этого метода.
template<typename Ret, typename... Args>
Ret callTyped(const std::string& method, const Args&... args) {
RpcArgs packed;
@@ -38,3 +42,4 @@ private:
};