Skip to content

RPC: Even more cleanup on invocable functions.

Nick Mathewson requested to merge nickm/arti:rpc_method_syntax_redux into main

The trick here is to provide an Invoker trait, with blanket implementations for appropriate fn(_,_,_,_?) -> _. With this trick, we no longer need to have a decl_rpc_invoke_fn.

This lets us discard HasConstTypeId entirely, lets us statically declare invokers for individual instantiations of generic functions, and makes a few other things simpler and easier (IMO) to understand.

Significantly, the syntax for installing a method handler dynamically is now simple enough that it no longer makes sense for us to have a installable_rpc_invoke_fn macro. Writing your own installer function looks like this:

    impl<T, U> GenericObj<T, U>
    where
        T: Send + Sync + 'static + Clone + ToString,
        U: Send + Sync + 'static + Clone + ToString,
    {
        fn install_rpc_functions(table: &mut DispatchTable) {
            table.insert(invoker_ent!(getname_generic::<T, U>));
            table.insert(invoker_ent!(getkids_generic::<T, U>));
        }
    }

Based on !1149 (closed). Closes #838 (closed).

Merge request reports