Skip to content

feat(rsync_io): sync/async bridge for embedded SSH streams (#1806) - #4295

Merged
oferchen merged 1 commit into
masterfrom
feat/sync-async-bridge-embedded-ssh-1806
May 17, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/sync-async-bridge-embedded-ssh-1806

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds ssh::embedded::sync_bridge (gated embedded-ssh) with two complementary bridge primitives that let the existing sync multiplex and transfer code drive an async russh-backed stream:
    • SyncAsyncBridge<S> wraps any AsyncRead + AsyncWrite + Unpin + Send + 'static (including russh's ChannelStream) and exposes std::io::Read + std::io::Write by driving an internal current-thread tokio runtime via block_on.
    • into_sync_halves(russh::Channel) -> (SyncReader, SyncWriter) returns halves backed by a background pump task and bounded std::sync::mpsc / tokio::sync::mpsc queues - the inverse of channel_adapter::{ChannelReader, ChannelWriter}.
  • Mirrors the queue-pump pattern already used by embedded::connect_and_exec so wiring stays consistent across the two call-sites.
  • Defaults to a 64-message queue (DEFAULT_CHANNEL_CAPACITY); into_sync_halves_with_capacity lets tests size it down to exercise backpressure.

Test plan

  • cargo nextest run -p rsync_io --features embedded-ssh -E 'test(sync_bridge)' covers the new tests:
    • sync/async round-trip across an in-memory tokio::io::duplex
    • EOF semantics on async stream close
    • SyncReader chunk drain across reads + EOF on sender drop
    • SyncWriter BrokenPipe on closed receiver
    • bounded SyncWriter backpressure (writer blocks until receiver drains)
    • dropping the SyncWriter closes the underlying channel
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings

Builds on PR #4290 (#1805); default builds are unchanged.

Adds the bridge primitives that let the existing synchronous multiplex
and transfer code drive an async russh channel without being ported to
async. Builds on PR #4290 (#1805) which wired the async SshTransport
into the client driver via the OC_RSYNC_ASYNC_SSH env var.

The new `ssh::embedded::sync_bridge` module is gated under
`embedded-ssh` and exposes:

- `SyncAsyncBridge<S>`: a generic facade that takes any
  `AsyncRead + AsyncWrite + Unpin + Send + 'static` stream (including
  russh's `ChannelStream`) and exposes `std::io::Read + std::io::Write`
  by driving an internal current-thread tokio runtime via `block_on`.
- `into_sync_halves(russh::Channel)` returning `(SyncReader, SyncWriter)`
  halves backed by a background pump task and bounded
  `std::sync::mpsc` / `tokio::sync::mpsc` queues - the inverse of the
  existing `ChannelReader`/`ChannelWriter` adapters in
  `channel_adapter.rs`.
- `into_sync_halves_with_capacity` for callers that need a different
  queue depth (used by the backpressure test).
@oferchen
oferchen merged commit f6de897 into master May 17, 2026
9 of 13 checks passed
@github-actions github-actions Bot added the enhancement New feature or request label May 17, 2026
oferchen added a commit that referenced this pull request May 18, 2026
…4295)

Adds the bridge primitives that let the existing synchronous multiplex
and transfer code drive an async russh channel without being ported to
async. Builds on PR #4290 (#1805) which wired the async SshTransport
into the client driver via the OC_RSYNC_ASYNC_SSH env var.

The new `ssh::embedded::sync_bridge` module is gated under
`embedded-ssh` and exposes:

- `SyncAsyncBridge<S>`: a generic facade that takes any
  `AsyncRead + AsyncWrite + Unpin + Send + 'static` stream (including
  russh's `ChannelStream`) and exposes `std::io::Read + std::io::Write`
  by driving an internal current-thread tokio runtime via `block_on`.
- `into_sync_halves(russh::Channel)` returning `(SyncReader, SyncWriter)`
  halves backed by a background pump task and bounded
  `std::sync::mpsc` / `tokio::sync::mpsc` queues - the inverse of the
  existing `ChannelReader`/`ChannelWriter` adapters in
  `channel_adapter.rs`.
- `into_sync_halves_with_capacity` for callers that need a different
  queue depth (used by the backpressure test).
oferchen added a commit that referenced this pull request May 18, 2026
…4295)

Adds the bridge primitives that let the existing synchronous multiplex
and transfer code drive an async russh channel without being ported to
async. Builds on PR #4290 (#1805) which wired the async SshTransport
into the client driver via the OC_RSYNC_ASYNC_SSH env var.

The new `ssh::embedded::sync_bridge` module is gated under
`embedded-ssh` and exposes:

- `SyncAsyncBridge<S>`: a generic facade that takes any
  `AsyncRead + AsyncWrite + Unpin + Send + 'static` stream (including
  russh's `ChannelStream`) and exposes `std::io::Read + std::io::Write`
  by driving an internal current-thread tokio runtime via `block_on`.
- `into_sync_halves(russh::Channel)` returning `(SyncReader, SyncWriter)`
  halves backed by a background pump task and bounded
  `std::sync::mpsc` / `tokio::sync::mpsc` queues - the inverse of the
  existing `ChannelReader`/`ChannelWriter` adapters in
  `channel_adapter.rs`.
- `into_sync_halves_with_capacity` for callers that need a different
  queue depth (used by the backpressure test).
@oferchen
oferchen deleted the feat/sync-async-bridge-embedded-ssh-1806 branch May 19, 2026 19:29
oferchen added a commit that referenced this pull request Aug 24, 2026
…4295)

Adds the bridge primitives that let the existing synchronous multiplex
and transfer code drive an async russh channel without being ported to
async. Builds on PR #4290 (#1805) which wired the async SshTransport
into the client driver via the OC_RSYNC_ASYNC_SSH env var.

The new `ssh::embedded::sync_bridge` module is gated under
`embedded-ssh` and exposes:

- `SyncAsyncBridge<S>`: a generic facade that takes any
  `AsyncRead + AsyncWrite + Unpin + Send + 'static` stream (including
  russh's `ChannelStream`) and exposes `std::io::Read + std::io::Write`
  by driving an internal current-thread tokio runtime via `block_on`.
- `into_sync_halves(russh::Channel)` returning `(SyncReader, SyncWriter)`
  halves backed by a background pump task and bounded
  `std::sync::mpsc` / `tokio::sync::mpsc` queues - the inverse of the
  existing `ChannelReader`/`ChannelWriter` adapters in
  `channel_adapter.rs`.
- `into_sync_halves_with_capacity` for callers that need a different
  queue depth (used by the backpressure test).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant