aboutsummaryrefslogtreecommitdiff
path: root/crates/arti-rpc-client-core/src/ffi/util.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.
* rpclib: Rename `OutPtr` to `OutBoxedPtr`Neel Chauhan2025-11-061-22/+22
| | | | Closes #1588.
* 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.
* fix `clippy::doc_overindented_list_items`Steven Engler2025-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | Example: ```text warning: doc list item overindented --> crates/arti-rpc-client-core/src/conn/connimpl.rs:322:9 | 322 | /// indicates that no more messages will be received for this request. | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items note: the lint level is defined here --> crates/arti-rpc-client-core/src/lib.rs:8:9 | 8 | #![warn(clippy::all)] | ^^^^^^^^^^^ = note: `#[warn(clippy::doc_overindented_list_items)]` implied by `#[warn(clippy::all)]` ```
* artilib: Take a different approach to sealing a pair of traits.Nick Mathewson2024-10-011-34/+41
| | | | This resolves a "TODO MSRV" comment.
* rpclib: FFI for opening data streams.Nick Mathewson2024-09-091-2/+57
| | | | | There's a blocking TODO here about exposing socks error codes that I still need to solve.
* Fix typosDimitris Apostolou2024-09-031-1/+1
|
* rpclib: Remove in_mut_ptr_opt, and document why.Nick Mathewson2024-08-271-25/+7
|
* rpclib, ffi: Allow simultaneous calls to `arti_rpc_handle_wait()`Nick Mathewson2024-08-271-0/+1
| | | | | | | | | | | | | | Its underlying function previously took `&mut RpcHandle`, which was an accident waiting to happen. Now it takes `&RpcHandle` and includes a Mutex to prevent multiple threads from waiting for updates on the same request ID at once. As an alternative, we *could* try to update connimpl::Receiver to allow multiple simultaneous listeners on the same request ID. But that would (I think) require a lot more bookkeeping, and thus would be a bit more error-prone. Closes #1532.
* ffi: Add support for request handlesNick Mathewson2024-08-121-3/+0
| | | | | This API allows the caller to launch a request and then watch for updates on it.
* ffi: New in_mut_ptr_opt type for receiving *mut T.Nick Mathewson2024-08-121-0/+25
| | | | | | | | Previously, we had in_ptr_opt for functions that want to take a nullable `*const T` without consuming it. This is the equivalent for taking a nullable `*mut T` without consuming it.
* ffi: New out_val_opt type for outptrs to non-pointersNick Mathewson2024-08-121-19/+77
| | | | | | | | Previously, we had out_ptr_opt for functions that wanted to return a newly allocated `ArtiRpcFoo` via a `struct ArtiRpcFoo **` argument. But we didn't have a way to return non-allocated `int` via an `int *` argument. This code provides that.
* ffi: Make "sealed" a little less effective.Nick Mathewson2024-07-311-7/+7
| | | | | Rust 1.70 (our MSRV) will not allow us to use a trait from a private module in this way, unfortunately.
* ffi: rename ffi_body_simple to ffi_body_rawNick Mathewson2024-07-311-8/+8
|
* ffi: Document rules for ensuring return valuesNick Mathewson2024-07-311-0/+13
|
* ffi: Clean up long lines and confusing expressions.Nick Mathewson2024-07-311-3/+9
|
* ffi: use void to omit unreachable "on invalid" blocksNick Mathewson2024-07-311-18/+47
|
* RPC: Re-wrap some macro definitions and usages.Nick Mathewson2024-07-311-14/+41
|
* ffi: Remove all non-opt conversionsNick Mathewson2024-07-311-181/+82
| | | | | | | Additionally, inline the related conversion functions. This should reduce the total amount of unsafe code that somebody would need to look at.
* ffi: Always abort on panic.Nick Mathewson2024-07-311-14/+4
|
* ffi: Refactor @init macro expansions into new functions.Nick Mathewson2024-07-311-23/+102
| | | | (Documentation movement still needed.)
* ffi: Document internal ffi_initialize macro.Nick Mathewson2024-07-311-0/+14
|
* Apply suggestions about macro behavior, design, and usageNick Mathewson2024-07-311-0/+18
|
* Apply safety-related suggestions from DizietNick Mathewson2024-07-311-1/+10
|
* RPC FFI: Write a bit more text for the C no-UB requirements.Nick Mathewson2024-07-311-0/+2
| | | | | | | I got this by reading over all the relevant Rust stdlib safety documentation (now linked to in the macro definitions), and making sure that the C no-UB text is sufficient to guarantee that those requirements are met.
* ffi: Ensures every converter tries to run.Nick Mathewson2024-07-311-30/+55
| | | | | | | | | Previously, some of our conversion macros tried to exit early with `?`. This is undesirable, since the OutPtr conversion has the side effect of writing NULL to a pointer (if it is present). Now, every conversion runs, and _then_ we exit with an error if any of them fails.
* Use macros to make FFI functions simpler to read and check.Nick Mathewson2024-07-311-35/+301
| | | | | | | | | | | | | | | | | | | | These macros do the only part of our FFI functions that needs to be `unsafe`: converting input pointers into types that can be used in safe rust. I've added documentation about what requirements each of these conversions puts onto out inputs: both informally, and via a reference to the relevant parts of the Rust library documentation. While doing this I found a safety bug in `OutPtr::from_opt_ptr`: it should have been using `MaybeUninit`. These macros should allow us to build a "proof sketch" for the safety of our FFI code. We need to show, for each input parameter: - That the documented requirements for its conversion method are also documented requirements for that kind of input, in our header file. - That the documented requirements for how it can be used after conversion are in fact followed in the code.
* rpclib: Suggestions from @diziet for improving safety docs.Nick Mathewson2024-07-311-1/+2
|
* rpclib ffi: Grand identifier renamingNick Mathewson2024-07-311-2/+2
| | | | In brief: Everything now starts with ARTI_RPC, arti_rpc, or ArtiRpc.
* rpc: Rename OutPtr functions for clarityNick Mathewson2024-07-311-6/+6
|
* rpclib: Grand error refactoring: outparam, not thread-localNick Mathewson2024-07-311-0/+8
| | | | | | | | Per discussion, we'd rather have an optional output parameter for error objects rather than mess with thread-local variables. This is possibly less convenient for direct usage from C, but likely more convenient for wrapper functions in other languages.
* rpclib: _Sketch_ of string API.Nick Mathewson2024-07-311-15/+0
| | | | | | | | | | | | | In this API, borrowed strings are `const char *`, and owned strings are `ArtiRpcStr *`. You can get the former from the latter with `arti_rpc_str_get()`, which returns a `const char *` in hopes that you will neither modify nor free() that `const char *` (Note that there are no places where string ownership needs to be passed into this library; and at present, there is only one case where it is passed out. I do not anticipate that we will need to do intake of owned strings. We will probably need to return these in a few more cases as we add more API surface.)
* rpc ffi: Try a more reference-driven approach to pointer handling.Nick Mathewson2024-07-311-1/+180
|
* rpc: Initial core of an FFI interface.Nick Mathewson2024-07-311-0/+40
This only covers the absolute minimal API in order to launch a connection and run simple requests, and it doesn't document anything nearly well enough. Nonetheless I think it's good enough for an initial review, to make sure that we've got the basics right (as well as a general consensus on the error handling API, naming, and so forth).