summaryrefslogtreecommitdiff
path: root/crates/tor-rpcbase/src/dispatch.rs
Commit message (Collapse)AuthorAgeFilesLines
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-2/+2
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* tor-rpcbase: Remove unnecessary parentheses from around type.Gabriela Moldovan2025-07-071-2/+2
| | | | This fixes a nightly clippy warning.
* rpc: Move support for weak references behind an experimental featureNick Mathewson2025-01-271-4/+0
| | | | | We haven't decided how these should work (see #868), so having them present by default is a bad idea.
* rpc: Simplify method-dispatch-bypass logic a bitNick Mathewson2024-10-231-1/+13
| | | | | | | | | | | | | | | This commit removes the separate function for asking whether to bypass the dispatch code. Instead, it gives the "invoke with bypass" function an error to return when no dispatch is warranted, and moves the whole responsibility for method dispatch or non-dispatch back into tor-rpcbase. I had to add an ObjectId argument to `invoke_rpc_method` to make this work, but that's probably a good thing. Additionally, this commit tweaks the derive-deftly macro to prevent you from asking for dispatch bypass on special methods, where it isn't implemented (and doesn't really make sense).
* Remove Rpc* variants from tor_error::ErrorKindNick Mathewson2024-10-171-13/+17
| | | | | | | | | | | | | These are not regular ErrorKinds, since they can never occur in an error that's meant to be returned from a Rust API like `arti-client`. Instead, they only exist for errors returned from RpcError. (I can't find the place where we discussed this previously, but the rationale is that if an ErrorKind never makes sense in response to something that the user does from Rust, we should never have that be an ErrorKind. The fact that the removed kinds do not actually appear outside the RPC system suggests that this is reasonable.)
* rpc: Expose a delegation table in arti:x_list_all_rpc_methodsNick Mathewson2024-09-241-0/+8
| | | | Closes #1624.
* rpc: add mandatory delegate-type attribute to Object templateNick Mathewson2024-09-241-1/+4
| | | | | | | When specifying a delegation, the template user must also say what type they're delegating to. We're going to use this to document and expose delegations.
* Fix typosDimitris Apostolou2024-09-031-2/+2
|
* rpcbase: Implement RPC method delegation support.Nick Mathewson2024-08-141-27/+85
| | | | | | | | (Couldn't use Deref here, since we needed to get an Arc.) Only one delegation target per object is permitted for now. This will help with #1523.
* rpcbase: Feature to list the RPC methods and what they apply to.Nick Mathewson2024-08-121-0/+3
|
* rpcbase: Facility for looking up RPC method informationNick Mathewson2024-08-121-3/+12
| | | | | We'll need this to refer to the names of RPC methods as visible to the caller, and to cross-reference them with their related types.
* rpcbase: Expose Invocable type names directly.Nick Mathewson2024-08-121-6/+11
| | | | | | Previously, we exposed them only via `describe_invocable`, which would have required the caller to parse a string in order to find these.
* rpc: Refactor errors part 1: a new RpcMethod trait.Nick Mathewson2024-07-251-15/+8
| | | | | It is no longer necessary to say, for every RPC method, that its error type is RpcError.
* rpcbase: remove now-unused invoke methodsNick Mathewson2024-07-251-70/+33
| | | | | | | These methods were defined on DispatchTable, and then replaced by top-level functions in the crate. (The reason for using top-level functions instead is so that we get the locking on the dispatch table correct.)
* rpcbase: Remove a TODO RPC about duplicationNick Mathewson2024-07-251-1/+0
| | | | | The duplication is only a few lines. I've looked into a couple of ways for removing it, but they make the code flow even less clear.
* rpc: Remove TODO about moving @special to a different macro.Nick Mathewson2024-07-251-4/+0
|
* rpcbase: tests for crate-level invoke functions.Nick Mathewson2024-07-151-20/+33
|
* rpc: Test some lower level dispatch internals.Nick Mathewson2024-07-151-3/+80
|
* rpc: Missing rpc_invoker is a Bug.Nick Mathewson2024-06-101-1/+6
| | | | | Every method is either "special" or not; therefore, it is always a Bug if we look for an rpc_invoker and don't find one.
* Add more explanation of InvokerEnt fields.Nick Mathewson2024-06-101-0/+8
|
* rpc: Add RPC method invocation based on Context, not dispatch table.Nick Mathewson2024-06-101-1/+5
| | | | | | | | Doing it this way will allow us to invoke methods without holding the read lock on the table, implicitly or via the future. I am not yet removing the methods on DispatchTable, since the tests need them; I've added TODOs to revisit and remove later.
* rpc: Pass around our rpc::Context in an Arc.Nick Mathewson2024-06-101-25/+25
| | | | | | | | Formerly we used a Box. That was okay at first, but now that we want RPC methods to be able to invoke other RPC methods, we don't want the Invocable methods to have to consume the Context. This requires that Context become Sync.
* rpc: refactor DispatchTable invoker lookup into new functionsNick Mathewson2024-06-101-15/+36
|
* rpc: Implement Clone and HasKind on InvokeError.Nick Mathewson2024-06-101-1/+11
|
* Add a few "TODO RPC" notesNick Mathewson2024-05-161-0/+5
|
* RPC: Expose dispatch table from ContextNick Mathewson2024-05-161-0/+4
| | | | | We need to do this so that we can actually invoke RPC functions from one another.
* RPC: Fill in documentation about invoke_specialNick Mathewson2024-05-161-4/+22
|
* Tests for invoke_specialNick Mathewson2024-05-161-0/+42
|
* RPC: Fix types for DispatchTable::invoke_specialNick Mathewson2024-05-161-11/+14
| | | | | Now that Method::Error exists, we can downcast Any to the actual function's return type.
* RPC: Require an Error type in methods.Nick Mathewson2024-05-161-0/+3
| | | | | | | | This is needed so that we can cast special methods' return types properly. I wish I could make this optional, but Rust doesn't allow defaulting an associated type.
* Rpc: Allow invoker_ents to be marked as @specialNick Mathewson2024-05-161-7/+21
| | | | A @special invoker does not get an RPC entry.
* Relax Serialize requirement on method outputs.Nick Mathewson2024-05-161-8/+8
| | | | | Now Methods can return anything; and only if their outputs are Serialize will they implement RpcInvocable.
* Split Invocable into RpcInvocable.Nick Mathewson2024-05-161-50/+77
| | | | | RpcInvocable will only be implemented on types whose output can be serialized.
* RPC: Add an "invoke special" mechanismNick Mathewson2024-05-161-1/+62
| | | | This is part of work on #1403.
* rpc::invoker_ent_list: allow trailing comma.Nick Mathewson2024-05-091-1/+1
|
* Merge branch 'void' into 'main'Nick Mathewson2024-05-071-7/+10
|\ | | | | | | | | tor-rpcbase: Use Void to eliminate a panic, as statically unreachable See merge request tpo/core/arti!2124
| * tor-rpcbase: Use Void to eliminate a panic, as statically unreachableIan Jackson2024-05-021-7/+10
| |
* | Lightly simplify the syntax for installing multiple InvokerEntsNick Mathewson2024-05-061-0/+38
|/
* tor-rpcbase: Add a missing `#[doc(hidden)]`Ian Jackson2024-04-291-0/+1
| | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2103#note_3024372 I overlooked this.
* tor-rpcbase: invoker_ent!: simplify argument parsingIan Jackson2024-04-251-12/+15
| | | | | | Previously, one of the macros was documented to accept `(function_expr)`, but in fact it would only accept an identifier. Now we *do* accept any expression.
* tor-rpcbase: invoker_ent!: abolish flags argumentIan Jackson2024-04-251-19/+9
| | | | | | | | IMO if we want flags again in the future, we should probably pick a syntax that doesn't involve such awkward patterns. Perhaps `$expr $( , $( $flag )* )?`. But I think we probably won't need that feature.
* tor-rpcbase: invoker_ent: Infer the correct fn type for castIan Jackson2024-04-251-7/+69
| | | | | This renders the Update flag redundant. Indeed, in this commit we mow ignore the flags.
* tor-rpcbase: invoker_ent!: remove buggy unuseable armIan Jackson2024-04-251-3/+0
| | | | | | | | | This arm puts parens around its argument. But the other arm insists on $func:ident, and also would capture any reasonable input. This was probably something to do with the (func_expr) syntax. We don't need to *fix* this macrology, because in a moment the whole macro can be made to take $func:expr.
* rpc: add a comment from diziet to explain why we need same_declNick Mathewson2024-04-221-0/+6
|
* rpc: reformat macro slightly.Nick Mathewson2024-04-221-2/+5
|
* Rename Invoker trait to Invocable.Nick Mathewson2024-04-221-15/+15
|
* Fix rustdoc links.Nick Mathewson2024-04-221-2/+2
|
* Adjust an allow.Nick Mathewson2024-04-221-1/+1
|
* rpc:Sketch out the syntax of our remaining tricky macrosNick Mathewson2024-04-221-2/+8
|