ironrdp-async provides async I/O abstractions that wrap IronRDP state machines with Future-based APIs, enabling concurrent RDP connections with runtime-agnostic implementations.
Overview
This crate builds Futures on top of ironrdp-connector state machines, providing:
- Runtime-agnostic async I/O traits
- Framed wrapper for buffered async protocol handling
- Cancel-safe async operations
- Integration points for Tokio, futures, and other runtimes
Core Traits
FramedRead
Defines async reading from a stream into a buffer:
This trait is implemented by runtime-specific wrappers like TokioStream or FuturesStream.
FramedWrite
Defines async writing to a stream:
StreamWrapper
Adapter trait for wrapping runtime-specific stream types:
Framed Wrapper
The Framed<S> type provides buffered async frame reading and writing:
Reading Frames (Cancel Safe)
All read operations are cancel safe - you can safely drop the future and recreate it later without data loss. Partial reads are buffered internally.
Read Exact Bytes
Read PDU Frames
Read by Hint
Writing Frames (Not Cancel Safe)
Write operations are not cancel safe. If cancelled mid-write, partial data may be written:
Do not use write_all in tokio::select! branches unless you’re prepared to handle partial writes.
Stream Access
Connection Sequence
Async functions to drive the RDP connection sequence.
Basic Flow
NetworkClient Trait
For CredSSP and network authentication:
Implement this trait to handle HTTP requests needed for authentication protocols.
Single Sequence Step
For manual sequence control:
You can also split this into read and write phases:
Runtime Integration
This crate is runtime-agnostic. It defines traits that runtime-specific crates implement:
- ironrdp-tokio: Tokio runtime integration
- ironrdp-futures: futures-rs runtime integration
You typically don’t use ironrdp-async directly. Instead, use one of the runtime-specific crates that re-exports everything from ironrdp-async plus runtime adapters.
Cancel Safety
Understanding cancel safety is crucial when using this crate with select! or other cancellation mechanisms:
Cancel Safe Operations
read_exact - Partial reads are buffered internally
read_pdu - Frame parsing state is maintained
read_by_hint - Buffering ensures no data loss
Not Cancel Safe Operations
write_all - May result in partial writes if cancelled
Architecture Pattern
The async layer follows a clean separation:
This design:
- Keeps protocol logic separate from I/O
- Allows supporting multiple async runtimes
- Enables testing without real I/O
When to Use
Use ironrdp-async (via runtime crates) when:
- You need concurrent RDP connections
- You’re building high-performance services
- You’re already using Tokio or async-std
- You need efficient resource utilization
For simpler blocking I/O, use ironrdp-blocking instead.
Dependencies
- ironrdp-connector: Connection state machines
- ironrdp-core: Core RDP types
- ironrdp-pdu: PDU encoding/decoding
- bytes: Efficient byte buffers
- tracing: Structured logging