aboutsummaryrefslogtreecommitdiff
path: root/crates/arti-rpc-client-core/src/ffi.rs
Commit message (Collapse)AuthorAgeFilesLines
* typo fixes from @jnewsomeNick Mathewson2026-03-231-1/+1
|
* rpc: add ffi wrappers for nonblocking and event-loop functions.Nick Mathewson2026-03-231-3/+313
| | | | | This commit adds FFI wrappers for the "poll" API, which lets the user integrate with a poll(2)-style event loop.
* rpc: define FFI wrappers for nonblocking request APIsNick Mathewson2026-03-231-1/+137
| | | | | | This commit adds wrappers for the "submit/wait" methods on RpcConn (which are used to submit tagged requests, and then wait for responses to all tagged requests at once).
* rpc-client: add support to prefer/require su permissionNick Mathewson2026-03-161-0/+32
|
* rpclib: Rename `OutPtr` to `OutBoxedPtr`Neel Chauhan2025-11-061-15/+15
| | | | Closes #1588.
* Fix warnings and errors from edition 2024.Nick Mathewson2025-08-071-14/+14
| | | | | | | | | | The two main causes of errors were: - Since some of the lifetime rules have changed, we no longer need to do as many "bind a variable and immediately return it" patterns, and so clippy now warns about them. - We needed to adjust the explicit captures (`use<...>`) in a couple of our RPIT instances.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-3/+3
| | | | | | | | | | | | | | 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.
* Merge branch 'rpc_document_internal_optimism' into 'main'Nick Mathewson2025-01-301-6/+0
|\ | | | | | | | | | | | | rpc: Document what is actually going on with stream optimism. Closes #1583 See merge request tpo/core/arti!2753
| * rpc: Correct API documentation about optimismNick Mathewson2025-01-301-6/+0
| | | | | | | | | | | | | | | | | | | | | | Our documentation had dated to an older version of our RPC stream code, where all streams were automatically optimistic. But as explained, our use of "optimistic"ness in RPC stream code is now purely internal, to make it possible to get an DataStreamCtrl. This isn't user-visible in our rpc_conn_open_stream code. Closes #1583
* | fix: fix typosDimitris Apostolou2025-01-301-1/+1
|/
* arti-rpc-client-core: Document that dropping a request does not cancel it.Nick Mathewson2025-01-221-2/+2
| | | | | | | I hope that this limitation is acceptable; the alternative involves some significant refactoring to give Request a Weak reference to RpcConn -- but RpcConn isn't currently kept in an Arc<> at all, and so we'd need some fairly heavy hacking.
* arti-rpc-client-core: Implement and expose cancellation.Nick Mathewson2025-01-221-0/+30
|
* artilib: Revise C and Python APIs for builders.Nick Mathewson2024-12-091-19/+123
| | | | | | | | | | | | | | | Expose ArtiRpcConnBuilder and appropriate C wrapper functions in our FFI code, and wrap those functions in our python wrapper. This breaks the old C API, but that's allowed since the API is still experimental. Some design decisions: * I've wrapped the builder in a Mutex, so that we can continue our FFI rule that we do not require non-Rust code to wrap `&mut`. * I've removed the non-builder connect() function from the C API as extraneous. * I've made a single function to prepend elements to the search path.
* rpc-client: Initial implementation for RPC connect points.Nick Mathewson2024-12-091-1/+3
| | | | | | | | | This commit covers the major points of the design: Parsing the environment, parsing and resolving connect points, connecting to Arti, and handling errors. There are a few areas that need to be fixed, all marked with XXXXs.
* rpclib: Use prop351 protocol to open streams.Nick Mathewson2024-09-181-1/+4
| | | | | | | | | | | Now that prop351 is what Arti speaks, it's what the rpclib needs to provide. Note one change in particular: the `isolation` string is no longer an optional argument when opening a stream. (With prop351, there is no longer such a thing as an "absent" isolation string, and we don't want to imply that there is a difference between None and "".)
* rpclib: Rename "connect" to "open_stream" as appropriate.Nick Mathewson2024-09-101-6/+6
|
* rpclib: FFI for opening data streams.Nick Mathewson2024-09-091-2/+142
| | | | | There's a blocking TODO here about exposing socks error codes that I still need to solve.
* rpclib, ffi: Allow simultaneous calls to `arti_rpc_handle_wait()`Nick Mathewson2024-08-271-6/+5
| | | | | | | | | | | | | | 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/+157
| | | | | This API allows the caller to launch a request and then watch for updates on it.
* ffi: New out_val_opt type for outptrs to non-pointersNick Mathewson2024-08-121-2/+2
| | | | | | | | 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: Expose the object ID for the session.Nick Mathewson2024-08-061-0/+31
| | | | (Without this, it isn't actually possible to use the RPC subsystem.)
* ffi: Add some explicit ()s to prove they are there.Nick Mathewson2024-07-311-1/+4
|
* ffi: Document safety for each function using ffi_body_raw.Nick Mathewson2024-07-311-0/+6
|
* ffi: rename ffi_body_simple to ffi_body_rawNick Mathewson2024-07-311-4/+4
|
* ffi: use void to omit unreachable "on invalid" blocksNick Mathewson2024-07-311-3/+0
|
* ffi: Remove all non-opt conversionsNick Mathewson2024-07-311-14/+23
| | | | | | | 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-3/+0
|
* Use macros to make FFI functions simpler to read and check.Nick Mathewson2024-07-311-63/+51
| | | | | | | | | | | | | | | | | | | | 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.
* Rename Utf8CStr=>Utf8CStringNick Mathewson2024-07-311-3/+3
|
* rpclib ffi: Grand identifier renamingNick Mathewson2024-07-311-10/+20
| | | | In brief: Everything now starts with ARTI_RPC, arti_rpc, or ArtiRpc.
* rpclib: Revise/condense "safety" docs for C functionsNick Mathewson2024-07-311-23/+10
| | | | | | | | | | | | | | | These documents are no longer called "safety". They are now mostly collected as a big list of "correctness requirements" at the start of the cbindgen header. Because of these requirements, most functions no longer need their own "safety" sections. I am explicitly using `#[allow(clippy::missing_safety_doc)]` on each function, rather than adding a blanket exception: - There are other unsafe functions in this code, to which we wouldn't want an exception to apply. - Documenting the safety^W correctness requirements of a function is important enough to make sure that we aren't skipping out on it unintentionally.
* rpc: Rename OutPtr functions for clarityNick Mathewson2024-07-311-5/+5
|
* rpclib: Grand error refactoring: outparam, not thread-localNick Mathewson2024-07-311-11/+17
| | | | | | | | 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-7/+32
| | | | | | | | | | | | | 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-20/+15
|
* rpc: Initial core of an FFI interface.Nick Mathewson2024-07-311-0/+151
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).