summaryrefslogtreecommitdiff
path: root/crates/tor-rpcbase/src/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'rename_singleton_id' into 'main'Jim Newsome2024-09-251-1/+1
|\ | | | | | | | | | | | | rpc: Rename SingletonId to SingleIdResponse Closes #1585 See merge request tpo/core/arti!2448
| * rpc: Rename SingletonId to SingleIdResponseNick Mathewson2024-09-241-1/+1
| | | | | | | | | | | | | | | | | | | | Calling it "singleton" might have suggested that it was using the [singleton pattern](https://en.wikipedia.org/wiki/Singleton_pattern), which it isn't. (Renaming done with rust-analyzer and double-checked with `git grep`.) Closes #1585.
* | rpc: Expose a delegation table in arti:x_list_all_rpc_methodsNick Mathewson2024-09-241-0/+5
|/ | | | Closes #1624.
* rpcbase: Implement RPC method delegation support.Nick Mathewson2024-08-141-4/+4
| | | | | | | | (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.
* Add a missing incantation to fix doc(cfg=...).Nick Mathewson2024-08-131-0/+1
| | | | Without this, we get a warning when we run `cargo doc`.
* rpcbase: Feature to list the RPC methods and what they apply to.Nick Mathewson2024-08-121-0/+4
|
* rpc: Remove special conversion for SendUpdateError.Nick Mathewson2024-07-251-0/+6
|
* rpc: Remove RpcError data field and use ReportNick Mathewson2024-07-251-3/+11
| | | | | | | | | | | | Per discussion, this field isn't really specified in a way that lets us fill it sensibly at the moment. So for now, we're going to just omit it. Additionally, we said that we'd Report on our errors; this branch changes the implementation of RpcError to do that. Question: Will the blanket implementation for Into<RpcError> make it harder to re-add a Data field later on if we want to do so?
* rpc: Refactor errors part 1: a new RpcMethod trait.Nick Mathewson2024-07-251-2/+2
| | | | | 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-1/+1
| | | | | | | 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.)
* rpc: remove TODO about adding an extension traitNick Mathewson2024-07-251-4/+0
| | | | | These functions are called rarely enough that it is probably okay for the ergonomics to be a bit verbose.
* rpcbase: remove "Nil" TODO.Nick Mathewson2024-07-251-3/+0
| | | | This change would take some serde magic that is probably not worth it.
* rpcbase: tests for crate-level invoke functions.Nick Mathewson2024-07-151-0/+40
|
* rpc: Add RPC method invocation based on Context, not dispatch table.Nick Mathewson2024-06-101-0/+53
| | | | | | | | 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-1/+1
| | | | | | | | 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: Expose dispatch table from ContextNick Mathewson2024-05-161-0/+3
| | | | | We need to do this so that we can actually invoke RPC functions from one another.
* rpc: Move typetag onto subtrait of DynMethodNick Mathewson2024-05-161-2/+2
| | | | | | This will allow us to create dispatchable methods that are only invoked from inside the arti code, and are not themselves serializable.
* RPC: Enforce method name format.Nick Mathewson2024-05-141-1/+4
| | | | | | | | | | | | We need to do this carefully, since we want our system to be extensible with new namespaces. First, when we are constructing an RpcMgr, we _warn_ about any method names that are misformed. Second, we add a test in the `arti` crate to fail if any method names are invalid. This will only catch method names in crates that `arti` depends on.
* tor-rpcbase: Add facility to downcast to Arc<dyn Trait>.Nick Mathewson2024-05-091-1/+1
| | | | | Previously we could only downcast to &dyn Trait, which is not adequate.
* rpc: Add helper type for methods that return a single id.Nick Mathewson2024-05-091-0/+8
|
* Merge branch 'new_ci_cfg_strategy' into 'main'Nick Mathewson2024-05-071-2/+2
|\ | | | | | | | | | | | | add_warning/CI: New strategy to avoid "unexpected-cfgs" warning Closes #1395 See merge request tpo/core/arti!2129
| * Re-run maint/add_warning.Nick Mathewson2024-05-061-2/+2
| | | | | | | | This commit is automatically generated.
* | Add a const instance of rpc::Nil.Nick Mathewson2024-05-061-0/+2
|/
* rpc: Revise backend for dispatchable-object macro.Nick Mathewson2024-04-221-4/+2
| | | | | | | | | 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, and will let us simplify some other syntax moving forward.
* Refactor: remove existence of HasConstTypeId_ as a traitNick Mathewson2024-04-081-1/+0
| | | | | | | | | We don't actually need this to be a trait; we just need methods and objects to have a `CONST_TYPE_ID_` if they want to participate in the inventory-based method registry. Removing this trait makes it much simpler to declare methods and objects.
* Port many of the macros in tor-rpcbase to use derive-deftly.Nick Mathewson2024-04-041-2/+9
| | | | | | This simplifies our implementation logic in a few places, and simplifies our invocation syntax greatly. There are a few infelicities, noted in `TODO RPC` comments.
* deny clippy::unchecked_duration_subtractiontrinity-1686a2024-02-291-0/+1
|
* Run add_warnings on all files.Nick Mathewson2023-08-041-2/+2
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* Run add_warning to remove `missing_panics_doc` deny.Nick Mathewson2023-07-061-1/+0
| | | | Closes #950.
* lints: Run maint/add_warning to actually apply new lintsIan Jackson2023-06-211-0/+2
|
* RPC: Functionality to downcast dyn Object to a dyn Trait.Nick Mathewson2023-06-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a rather tricky piece of functionality. It works as follows. We introduce a `CastTable` type. Each `CastTable` tells us how to downcast `dyn Object` for objects of a single concrete type. The `Object` type now has a `get_casttable` method that returns an empty `CastTable` by default. `CastTable` is, internally, a map from the `TypeId` of the target dyn Trait reference type to a function `fn(&dyn Object) -> &dyn Trait`. These functions are stored as `Box<dyn Any + ...>`. (They are Boxed because they may refer to generic functions, which you can't get a static reference to, and they're Any because the functions have different types.) The `decl_object!` macro now implements `get_casttable` as appropriate. (The syntax is a bit janky, but that's what we get for not using derive_adhoc.) For non-generic types, `get_casttable` uses a Lazy<CastTable>`. to initialize a CastTable exactly once. For generic types, it use a `Lazy<RwLock<HashMap<..>>` to build one CastTable per instantiation of the generic type. This could probably be optimized a bit more, the yaks could be shaved in a more scintillating hairstyle, and the syntax for generic `decl_object` could definitely be improved.
* rpc: Remove downgrade_owned for nowNick Mathewson2023-05-241-8/+0
| | | | | | | Rationale: Our weak-vs-strong design is a bit confused at the moment due to concerns about deduplication and capability semantics. It's not clear that a general "change strong to weak" method is compatible with what we want to provide.
* rpc: Implement functionality to remove objects from a sessionNick Mathewson2023-05-241-0/+25
| | | | | | | | | | | I've made doing some design choices here: * Reserving "rpc" as a prefix for post-authentication functionality that is not arti-specific. * Declaring these to be methods on the session rather than methods on the objects themselves. There's a problem with defining an API to drop a weak reference; see comment in code.
* rpc: fix documentation for methods in Context.Nick Mathewson2023-05-241-6/+4
|
* RPC: Add "register" methods to RequestContext.Nick Mathewson2023-05-041-0/+23
|
* rpc: Simplify and clarify SendUpdateError.Nick Mathewson2023-04-191-7/+13
|
* Arti: Add ability to remember the list of methods names.Nick Mathewson2023-04-191-2/+3
| | | | | | | | | | | | Right now, this lets us say whether the method was unrecognized or whether the parameter type was incorrect. We'll use this to enforce correct method names later on. (I have to add another `inventory` here, since the `typetag` maintainer does not want to expose this functionality: see https://github.com/dtolnay/typetag/issues/57#issuecomment-1506106290 )
* rpcbase: Use with_fn.Nick Mathewson2023-04-191-1/+3
|
* rpc: Split Method into DynMethod and MethodNick Mathewson2023-04-191-1/+1
| | | | | Now `Method` has an Output and Update associated type, and `decl_method` can do a little more.
* rpc: Move update sink out of context.Nick Mathewson2023-04-161-8/+13
| | | | | Now the update sink is its own boxed object. It is not yet passed to the invoke functions that want it.
* tor-rpcbase: Rename cmd.rs to method.rs.Nick Mathewson2023-04-121-2/+2
|
* tor-rpcbase: Rename and rephrase "command" to "method"Nick Mathewson2023-04-121-4/+4
|
* Rename tor-rpccmd to tor-rpcbase.Nick Mathewson2023-04-121-0/+113