summaryrefslogtreecommitdiff
path: root/crates/tor-rtcompat/src/traits.rs
Commit message (Collapse)AuthorAgeFilesLines
* rtcompat: Spawn every future in_current_span.Nick Mathewson2025-11-051-2/+4
| | | | | If we need to override this in the future, we can provide a new method that takes a Span as an argument.
* tor-rtcompat: add our own `SpawnExt` traitSteven Engler2025-11-041-2/+42
| | | | This new trait is compatible with tokio-console.
* Typo fixes (automatic and hand-verified)Nick Mathewson2025-07-091-2/+2
| | | | Made with https://crates.io/crates/typos-cli
* tor-rtmock: Blocking::blocking_io: add clarificationIan Jackson2025-06-231-0/+3
|
* tor-rtmock: Blocking::spawn_blocking: clarify drop behaviourIan Jackson2025-06-231-0/+6
| | | | | Explain that you don't need to .await the returned future, and say what happens when you drop it.
* tor-rtcompat: BlockOn: relax bounds on reenter_block_onIan Jackson2025-04-091-1/+1
| | | | The future no longer needs to be `Send + 'static`.
* tor-rtcompat: Fix grammar in docIan Jackson2025-03-041-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3168425
* tor-rtcompat: Rename spawn_thread to spawn_blockingIan Jackson2025-03-041-28/+27
| | | | Let's use Tokio terminology here.
* tor-rtcompat: Give a reason in blocking_io for not using for cpu workIan Jackson2025-03-041-1/+4
| | | | | As requested https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167979
* tor-rtcompat: Fix docs typoIan Jackson2025-03-041-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167978
* tor-rtcompat: Change the title of RuntimeIan Jackson2025-03-041-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167977
* tor-rtcompat: Clarify reentrancy restrictions on `block_on`Ian Jackson2025-03-041-2/+5
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167976
* tor-rtcompat: Explain Sendness of reenter_block_on futureIan Jackson2025-03-041-0/+6
| | | | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167975 Also allow ourselves the option of changing this in the future.
* tor-rtcompat: Clarify distinction between Runtime and ToplevelIan Jackson2025-03-041-2/+8
| | | | | Prompted by and partially taken from https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167973
* tor-rtcompat: Linkify a mention of spawn_threadIan Jackson2025-03-041-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167972
* tor-rtcompat: Clarify docs (3)Ian Jackson2025-03-041-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167970
* tor-rtcompat: Make a precise example for mpsc::channelIan Jackson2025-03-041-1/+1
| | | | | See https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167969
* tor-rtcompat: Blocking::spawn_thread semantics correctionIan Jackson2025-03-041-2/+11
| | | | | | | | | The: table entry for `spawn_thread` was wrong. We use AsyncExecutors' spawn_blocking which uses tokio::task::spawn_blocking. This has implications for the semantics, as per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167967 https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167968
* tor-rtcompat: Clarify docs (2)Ian Jackson2025-03-041-1/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167966
* tor-rtcompat: Clarify docsIan Jackson2025-03-041-1/+1
| | | | | As suggested https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2810#note_3167965
* tor-rtmocK; Detect wrong-context blocking_io and spawn_threadIan Jackson2025-03-041-2/+0
|
* tor-rtmocK; Detect re-entry into MockExecutorIan Jackson2025-03-041-1/+0
|
* tor-rtcompat: Remove ToplevelBlockon from RuntimeIan Jackson2025-03-041-3/+3
| | | | | | | | Introduce ToplevelRuntime as an alias, and use it in the top-level programs. Now none of the principal protocol implementation code has access to the executor's toplevel entrypoint, and can't call it by mistake.
* tor-rtcompat: Provide Blocking::blocking_ioIan Jackson2025-03-041-2/+51
| | | | | | | | | This was referenced and explained from the docs, but didn't exist yet. Here it is. Everyone except the Tokio glue, and the CompoundRuntime, just use the default implementation in terms of spawn_thread. spawn_thread has a more relaxed contract, so this is correct.
* tor-rtcompat: Provide a new function for executor re-entryIan Jackson2025-03-041-3/+44
| | | | | | | | | | | | | | | Forbid re-entering the executor using ToplevelBlockOn::block_on. This was always forbidden in the case of MockExecutor, but that meant that tests using MockExecutor would malfunction if the code under test needed to re-enter the executor from sync code (since the code under test would have to use block_on, which wrong). See #1835. Provide a function which *can* do this, reenter_block_on. The MockExecutor needs to know the difference, and other runtimes may too. They are conceptually quite different operations. Introduce ToplevelRuntime as a convenience alias.
* tor-rtcompat: New plan for blocking interaction, Blocking traitIan Jackson2025-03-041-16/+109
| | | | | | | | | | | | | | | * Document the new plan for blocking interaction in the trait-level docs for the Blocking trait (used to be SpawnBlocking). Add cross-references (in some cases to not-yet-existing pieces). * Rename: spawn_blocking to spawn_thread. We're going to distinguish thread-creation (relatively expensive) from brief entry to sync code (relatively cheap, but more restricted). * Rename the SpawnBlocking trait to Blocking, and its ThreadHandle to ThreadHandle. This trait is going to gain more functionality. * Add the missing mention of `Blocking` to the docs for `Runtime`.
* tor-rtcompat: Rename BlockOn to ToplevelBlockOnIan Jackson2025-03-041-5/+5
| | | | | | | | | | We're going to distinguish top-level runtime entry, from *re*-entry to an existing executor. It is most convenient to rename this trait first. Documentation of the distinction will come later. (We're going to retain the function name `block_on`, but we want the trait to be more obviously a top-level only thing, though, so we give it a name that will hopefully avoid it peroulating throughout the codebase..)
* tor-rtcompat: Rename UnsupportedStreamOps to NoOpStreamOpsHandle.Gabriela Moldovan2025-01-151-3/+3
| | | | | This renames UnsupportedStreamOpsHandle to NoOpStreamOpsHandle for clarity (the old name kind of sounded like the name of an error type).
* tor-rtcompat: Big invasive change adding StreamOps bound everywhere.Gabriela Moldovan2025-01-151-2/+2
| | | | | | This is unfortunately necessary, because after the channel handshake, we need to give the channel reactor a `StreamOps` handle to the underlying stream.
* tor-rtcompat: Implement StreamOps for Framed.Gabriela Moldovan2025-01-151-0/+13
|
* tor-rtcompat: Add the ability to get a StreamOps handle.Gabriela Moldovan2025-01-151-0/+20
| | | | | | | | | | | | | | | | | | | | | | | Needed for cases where we wrap an object that implements `StreamOps` in an external type, thereby losing access to the `StreamOps` functionality. For example, during the channel handshake, we `.split()` the stream that implements `StreamOps`, which leaves us with a `SplitSink` and a `SplitStream`, neither of which implement `StreamOps`. Getting a handle to the underlying object that implements `StreamOps` (for example, a file handle) *before* the stream is `.split()` enables us to use `StreamOps` to manipulate the underlying split stream. This commit also introduces a special `UnsupportedStreamOpsHandle`, which is a type that implements `StreamOps`, but always returns an error. This type is meant to simplify error handling and usage, and is meant to be used in cases where `StreamOps` is not supported. TODO: the name of this type is pretty confusing (it's very similar to `UnsupportedStreamOp`, which is an error type), and should probably be renamed to something else (`NoOpStreamOpsHandle`, `BrokenStreamOpsHandle`, `DummyStreamOpsHandle` come to mind...). Note: this changes the `StreamOps` trait to be slightly different from what I originally envisioned in !2660 and #1769
* tor-rtcompat: Note that SpawnBlocking isn't for CPU-bound tasks.Wesley Aptekar-Cassels2025-01-071-1/+1
|
* tor-rtcompat: Use GAT instead of RPIT in SpawnBlocking trait.Wesley Aptekar-Cassels2025-01-071-1/+4
| | | | Due to the limitations on RPIT, it's better to use a GAT for now.
* tor-rtcompat: Add note about what to use spawn_blocking for.Wesley Aptekar-Cassels2025-01-071-1/+5
|
* tor-rtcompat: Link to spawn_blocking docs.Wesley Aptekar-Cassels2025-01-071-0/+6
|
* tor-rtcompat: Add spawn_blocking to Runtime trait.Wesley Aptekar-Cassels2025-01-071-0/+11
| | | | | This adds a new SpawnBlocking trait, which exposes the spawn_blocking function that tokio, async-std, and other runtimes have.
* tor-rtcompat: Replace bad_api_usage with UnsupportedStreamOp.Gabriela Moldovan2024-12-101-6/+6
|
* tor-rtcompat: Add an error type for unsupported StreamOps.Gabriela Moldovan2024-12-101-0/+27
|
* tor-rtcompat: Add a default implementation for StreamOps::set_tcp_notsent_lowat.Gabriela Moldovan2024-12-101-2/+8
|
* tor-rtcompat: Clarify the StreamOps documentation.Gabriela Moldovan2024-12-101-4/+6
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2660#note_3139562
* tor-rtcompat: Require NetStream{Listener,Provider} streams to impl StreamOps.Gabriela Moldovan2024-12-101-2/+2
| | | | Part of #1769
* tor-rtcompat: Add a StreamOps trait.Gabriela Moldovan2024-12-101-0/+10
| | | | | | | | This trait will provide additional operations on `Stream`s. For now, the only supported operation is `set_tcp_notsent_lowat` (needed for #1728). Part of #1769
* Remove re-export of "unix" from tor_rtcompat.Nick Mathewson2024-10-291-1/+1
|
* rtcompat: Fix some rustdoc links.Nick Mathewson2024-09-241-1/+1
|
* rtcompat: remove async_trait from NetStreamListener.Nick Mathewson2024-09-241-2/+0
| | | | (The trait no longer has any async methods.)
* Make Runtime require NetStreamProvider<unix::SocketAddr>Nick Mathewson2024-09-241-4/+7
|
* rtcompat: Require Sync and 'static for NetStreamListener::IncomingNick Mathewson2024-09-241-1/+5
|
* rtcompat: Add ADDR parameter to NetStream{Provider,Listener}Nick Mathewson2024-09-241-11/+11
| | | | | | | | | This change will let us make a NetStreamProvider that works for AF_UNIX addresses, and for "abstract" addresses. I've decided to let this parameter have a default value of `std::net::SocketAddr` for now. We can remove the default later if we decide it's confusing.
* Documentation updates for "NetStreamProvider" renameNick Mathewson2024-09-241-15/+16
| | | | | | Stop referring to TCP streams in its documentation; update other documentation to refer to NetStreamProvider rather than TcpProvider.
* rtcompat: Rename TcpProvider to NetStreamProvider.Nick Mathewson2024-09-241-12/+12
| | | | | | | | | | | | | | (And similarly rename TcpListener to NetStreamListener, along with their TcpStream/TcpListener associated types.) These types are about to become generic over addresses, and therefore shouldn't be named after TCP. Renaming was done mostly with Rust Analyzer, except for some macros that needed to be hand-edited. (I'll revise the comments in the next commit; this one is all about renaming.)