Skip to main content
ironrdp-futures provides futures-rs runtime integration for IronRDP, implementing the framing traits from ironrdp-async using the futures crate’s async I/O traits.

Overview

This crate enables IronRDP to work with any executor compatible with the futures crate by:
  • Implementing FramedRead and FramedWrite for futures I/O types
  • Providing stream wrappers for different Send scenarios
  • Offering runtime-agnostic async I/O
Use this crate when working with async-std, smol, or other executors compatible with futures::io::AsyncRead and futures::io::AsyncWrite.

Quick Start

Stream Wrappers

The crate provides two stream wrapper types:

FuturesStream (Send + Sync)

For streams that are both Send and Sync:
Type bounds: S: Send + Sync + Unpin + AsyncRead/AsyncWrite

LocalFuturesStream (Local)

For local (non-Send) streams:
Type bounds: S: Unpin + AsyncRead/AsyncWrite (no Send requirement)

FramedRead Implementation

The FuturesStream implements FramedRead using futures::io::AsyncReadExt:
Unlike Tokio’s implementation which uses read_buf for zero-copy, the futures implementation reads into a fixed buffer and copies into BytesMut. This is slightly less efficient but compatible with the standard AsyncRead trait.

FramedWrite Implementation

The FuturesStream implements FramedWrite with automatic flushing:

Reading Frames

All the ironrdp-async frame reading methods work seamlessly:
All read operations are cancel safe - partial reads are buffered internally.

Writing Frames

Write operations are not cancel safe. Avoid using them in select expressions that may cancel.

Connection Example with async-std

Connection Example with smol

Performance Considerations

The futures implementation has slightly different performance characteristics than Tokio:
  • Buffer copying: Reads go through an intermediate buffer (1024 bytes) before copying to BytesMut
  • Portability: Works with any futures-compatible runtime
  • Simplicity: Standard trait implementation without runtime-specific optimizations
For maximum performance with Tokio specifically, use ironrdp-tokio instead, which leverages Tokio’s read_buf for zero-copy reads.

When to Use

Use ironrdp-futures when:
  • Working with async-std, smol, or other non-Tokio runtimes
  • Need runtime-agnostic async code
  • Want maximum portability across executors
  • Building libraries that should work with any runtime
For Tokio-specific projects, use ironrdp-tokio for better performance. For blocking I/O, use ironrdp-blocking.

Compatible Runtimes

This crate works with any runtime that supports futures::io traits:
  • async-std: Full-featured async runtime
  • smol: Lightweight async executor
  • futures::executor: Basic executor from futures crate
  • custom executors: Any executor implementing futures traits

Dependencies

  • ironrdp-async: Core async abstractions (re-exported)
  • futures-util: futures I/O traits and utilities
  • bytes: Efficient byte buffers

Re-exports

This crate re-exports all of ironrdp-async:
You can use all async traits, types, and functions directly from ironrdp_futures.