mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-29 08:34:47 +08:00
simplify
This commit is contained in:
@@ -39,8 +39,13 @@ struct rpc_codec {
|
||||
std::forward<Args>(args)...);
|
||||
} else {
|
||||
msgpack::sbuffer buffer(2 * 1024);
|
||||
msgpack::pack(buffer,
|
||||
std::forward_as_tuple(std::forward<Args>(args)...));
|
||||
if constexpr (sizeof...(Args) > 1) {
|
||||
msgpack::pack(buffer,
|
||||
std::forward_as_tuple(std::forward<Args>(args)...));
|
||||
} else {
|
||||
msgpack::pack(buffer, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
return std::string(buffer.data(), buffer.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,14 +226,8 @@ private:
|
||||
}
|
||||
result.ec = (rpc_errc)socket_->body_[0];
|
||||
if constexpr (!std::is_void_v<R>) {
|
||||
if constexpr (util::is_basic_v<R>) {
|
||||
result.value = rpc_codec::unpack<R>(std::string_view(
|
||||
socket_->body_.data() + 1, resp_header.body_len - 1));
|
||||
} else {
|
||||
auto tp = rpc_codec::unpack<std::tuple<R>>(std::string_view(
|
||||
socket_->body_.data() + 1, resp_header.body_len - 1));
|
||||
result.value = std::move(std::get<0>(tp));
|
||||
}
|
||||
result.value = rpc_codec::unpack<R>(std::string_view(
|
||||
socket_->body_.data() + 1, resp_header.body_len - 1));
|
||||
}
|
||||
|
||||
if (resp_header.msg_type == 1) { // pubsub
|
||||
|
||||
@@ -563,7 +563,12 @@ template <typename... Args>
|
||||
std::string serialize(rest_adl_tag, Args &&...args) {
|
||||
in_user_pack = true;
|
||||
msgpack::sbuffer buffer(2 * 1024);
|
||||
msgpack::pack(buffer, std::forward_as_tuple(std::forward<Args>(args)...));
|
||||
if constexpr (sizeof...(Args) > 1) {
|
||||
msgpack::pack(buffer, std::forward_as_tuple(std::forward<Args>(args)...));
|
||||
} else {
|
||||
msgpack::pack(buffer, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
return std::string(buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user