You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I'm trying to use JSONRPC and I don't understand why it doesn't have a tuple unpacking template. I end up having to write all the rpc methods by hand, but I want to use std::tuple or glz::tuple and loop through all the rpc methods for client::get_request_map when sending a request. Among other things, I tried to find documentation on glz::tuple, because I thought that this was provided there, but I couldn’t get to it. Either this is an incredibly awkward interface or it's incredibly poorly documented. The example contains almost nothing.
Here's what I did to achieve this:
usingmethods_t = std::tuple<
methods::first_method,
methods::second_method
>;
template <typename Tuple, typename Indices =
std::make_index_sequence<std::tuple_size<Tuple>::value>>
structrpc_client_t;
template <typename... Methods, size_t... I>
structrpc_client_t<std::tuple<Methods...>, std::index_sequence<I...>> {
using type = rpc::client<std::tuple_element_t<I, std::tuple<Methods...>>...>;
};
I would like to know how this can be done more simply, if it is provided in principle, and how to correctly go through all the rpc methods to send a request?
The text was updated successfully, but these errors were encountered:
receiver1
changed the title
JsonRPC question
JSONRPC: Is it really that inconvenient?
Feb 19, 2025
I would probably be able to give you a more precise answer if I understood a bit more concretely what you're trying to do. You could try fleshing out an example.
But, take a look at how Glaze uses glz::for_each, which takes a lambda that provides a compile time known index I that you can use to access each member of a tuple. This would probably make your life much easier.
Feel free to submit pull requests if you discover ways to make this code easier to work with. Thanks for the feedback!
Hey! I'm trying to use JSONRPC and I don't understand why it doesn't have a tuple unpacking template. I end up having to write all the rpc methods by hand, but I want to use
std::tuple
orglz::tuple
and loop through all the rpc methods forclient::get_request_map
when sending a request. Among other things, I tried to find documentation onglz::tuple
, because I thought that this was provided there, but I couldn’t get to it. Either this is an incredibly awkward interface or it's incredibly poorly documented. The example contains almost nothing.Here's what I did to achieve this:
I would like to know how this can be done more simply, if it is provided in principle, and how to correctly go through all the rpc methods to send a request?
The text was updated successfully, but these errors were encountered: