mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-31 01:20:52 +08:00
19 lines
469 B
C++
19 lines
469 B
C++
#pragma once
|
|
#include <string_view>
|
|
#include "../codec.h"
|
|
|
|
namespace rest_rpc {
|
|
inline bool has_error(std::string_view result) {
|
|
msgpack_codec codec;
|
|
auto tp = codec.unpack<std::tuple<int>>(result.data(), result.size());
|
|
|
|
return std::get<0>(tp) != 0;
|
|
}
|
|
|
|
template<typename T>
|
|
inline T get_result(std::string_view result) {
|
|
msgpack_codec codec;
|
|
auto err_tp = codec.unpack<std::tuple<int, T>>(result.data(), result.size());
|
|
return std::get<1>(err_tp);
|
|
}
|
|
} |