summaryrefslogtreecommitdiff
path: root/crates/tor-rpcbase/src/dispatch.rs
Commit message (Collapse)AuthorAgeFilesLines
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* rpc: Cross-reference up from tor-rpcbase re where DispatchTable livesIan Jackson2023-06-161-0/+2
|
* RPC: Functionality to downcast dyn Object to a dyn Trait.Nick Mathewson2023-06-121-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: make decl_object! responsible for writing impl Object {} blocks.Nick Mathewson2023-06-071-4/+0
|
* rpc: Remove downgrade_owned for nowNick Mathewson2023-05-241-7/+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/+11
| | | | | | | | | | | 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: Add "register" methods to RequestContext.Nick Mathewson2023-05-041-0/+7
|
* rpc: New syntax for method declarationNick Mathewson2023-04-191-9/+46
| | | | | Now you just declare your function `my_func` with the right types, and invoke `rpc_invoke_fn!{ my_func(ObjType, MethodType); }`
* rpcbase: Use with_fn.Nick Mathewson2023-04-191-7/+10
|
* rpc: Minor tweaks to get a sink to compile.Nick Mathewson2023-04-191-4/+5
|
* rpc: Use Method types to determine type of method outputs, updates.Nick Mathewson2023-04-191-64/+103
| | | | This lets us do much less in our rpc_invoke_fn functions.
* rpc: Split Method into DynMethod and MethodNick Mathewson2023-04-191-13/+20
| | | | | Now `Method` has an Output and Update associated type, and `decl_method` can do a little more.
* rpc: simplify API by always providing a sink.Nick Mathewson2023-04-161-19/+12
| | | | | Previously we have two places where we had to do "make a `Drain` sink if updates aren't wanted"; now there's only one.
* rpc: Wire updates into rpc invoke functions again.Nick Mathewson2023-04-161-12/+43
| | | | | | | | Now that the sink is not part of the context, RPC functions that are able to send an update have to declare an `impl Sink` as their fourth argument. This syntax is not final. Part of #824.
* rpc: Move update sink out of context.Nick Mathewson2023-04-161-38/+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 to method everywhere.Nick Mathewson2023-04-121-31/+31
|
* tor-rpcbase: Rename and rephrase "command" to "method"Nick Mathewson2023-04-121-29/+29
|
* rpc: Use empty structs in test code.Nick Mathewson2023-04-121-12/+12
|
* Rename tor-rpccmd to tor-rpcbase.Nick Mathewson2023-04-121-0/+396