summaryrefslogtreecommitdiff
path: root/crates/tor-rpcbase/src/obj.rs
Commit message (Collapse)AuthorAgeFilesLines
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* rpc: Suppress a clippy warning by making PossumCage usedIan Jackson2025-09-301-2/+11
| | | | | | | | | | | | | Fixes warning: struct `PossumCage` is never constructed warning: associated function `make_cast_table` is never used with cargo +stable clippy --locked --offline -p tor-rpcbase --all-targets Most of our builds happen with --all-features so we don't notice. In that case I think something to do with method printing:(`describe-methods`) is using things enough for the compiler not to complain.
* tor-rpcbase: Removed dependency on `once_cell`hashcatHitman2025-06-141-5/+5
| | | | | | - Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`. Signed-off-by: hashcatHitman <[email protected]>
* rpc: Expose a delegation table in arti:x_list_all_rpc_methodsNick Mathewson2024-09-241-0/+12
| | | | Closes #1624.
* rpc: add mandatory delegate-type attribute to Object templateNick Mathewson2024-09-241-2/+8
| | | | | | | 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.
* rpcbase: Implement RPC method delegation support.Nick Mathewson2024-08-141-1/+49
| | | | | | | | (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: Use newer "tgens" deftly syntaxNick Mathewson2024-07-251-3/+1
|
* rpcbase: remove a TODO about expose_outside_of_sessionNick Mathewson2024-07-251-4/+0
| | | | (There is no longer such a thing as a "pseudomethod.")
* rpc: Test a previously unchecked cast function.Nick Mathewson2024-07-151-0/+3
|
* rpc: Add a test for failed downcast.Nick Mathewson2024-07-151-0/+9
|
* Change deftly syntax to post 0.12.1 versionIan Jackson2024-06-171-1/+1
| | | | | | | | | | | * Change `pub` to `export` * Change the `=` in define to `:` * Change `pub_template_semver_check` to `template_export_semver_check` Right now, 0.12.1 supports both syntaxes. I have verified this branch also compiles with https://gitlab.torproject.org/Diziet/rust-derive-deftly/-/merge_requests/402 ee171ffaf56d7dcb7d75584054921153fe19b222
* Update to derive-deftly 0.12.1Ian Jackson2024-06-171-1/+5
| | | | | | * Bump in Cargo.toml * Deal with `${Xmeta as ...}` incompatible change, by always specifying an `as`, and changing `as tokens`.
* tor-rpcbase: Add facility to downcast to Arc<dyn Trait>.Nick Mathewson2024-05-091-7/+28
| | | | | Previously we could only downcast to &dyn Trait, which is not adequate.
* Make cast_to_trait inherent on dyn Object.Nick Mathewson2024-05-091-4/+10
| | | | | This makes `ObjectRefExt` less necessary, and will let us make it Arc-only.
* rpc: Revise backend for dispatchable-object macro.Nick Mathewson2024-04-221-12/+0
| | | | | | | | | 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.
* Add TODO RPC items from review.Nick Mathewson2024-04-111-0/+1
|
* Fix a comment.Nick Mathewson2024-04-111-2/+1
|
* rpc: Add a missing not() to generic test.Nick Mathewson2024-04-111-1/+1
|
* Remove a duplicate $twheres.Nick Mathewson2024-04-111-1/+1
|
* rpc: Move deftly attributes into an `rpc` namespace.Nick Mathewson2024-04-111-9/+9
|
* Refactor: remove existence of HasConstTypeId_ as a traitNick Mathewson2024-04-081-0/+11
| | | | | | | | | 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-94/+90
| | | | | | 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.
* rpcbase: Require that every Object is Send + Sync + 'staticNick Mathewson2024-04-041-2/+2
| | | | | (We don't plan to have any Object that can't be used as an `Arc<dyn Object>`.)
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* 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: Functionality to downcast dyn Object to a dyn Trait.Nick Mathewson2023-06-121-7/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+1
|
* RPC: Let objects declare that they need a GlobalId.Nick Mathewson2023-06-051-1/+17
|
* tor-rpcbase: Rename and rephrase "command" to "method"Nick Mathewson2023-04-121-1/+1
|
* Rename tor-rpccmd to tor-rpcbase.Nick Mathewson2023-04-121-0/+61