14 void RegisterSerializer() {
15 constexpr auto messageId = T::MessageId;
16 if (Handlers_.size() <= messageId) {
17 Handlers_.resize(messageId + 1);
19 auto serializeFunc = [](
TBlob&& blob) {
20 return ::NNet::NActors::SerializeFar<T>(std::move(blob));
22 Handlers_[messageId] = std::move(serializeFunc);
25 TBlob SerializeFar(uint32_t messageId,
TBlob blob) {
26 if (messageId >= Handlers_.size() || !Handlers_[messageId]) [[unlikely]] {
27 throw std::runtime_error(
28 std::string(
"No handler for message ID: ") + std::to_string(messageId)
31 return Handlers_[messageId](std::move(blob));
35#if __cpp_lib_move_only_function >= 202110L
36 std::vector<std::move_only_function<
TBlob(
TBlob&&)>> Handlers_;
38 std::vector<std::function<
TBlob(
TBlob&&)>> Handlers_;