Skip to main content
Version: 0.7.0
Docs.rs: ironrdp-pdu

Overview

The ironrdp-pdu crate provides structures and functions for encoding and decoding RDP Protocol Data Units. This crate implements the binary protocol layer for:
  • Connection negotiation (X.224, MCS)
  • Graphics and input PDUs
  • Virtual channel messages
  • Fast-path and legacy transport

Key Modules

Connection & Negotiation

  • nego - Initial protocol negotiation (CredSSP, TLS, RDP security)
  • x224 - X.224 connection-oriented transport
  • tpkt - TPKT framing headers
  • tpdu - T.125 transport PDUs
  • mcs - Multipoint Communication Service layer
  • gcc - Generic Conference Control (client/server data blocks)

Core Protocol

  • rdp - Core RDP PDUs (client info, capability sets, licensing)
  • rdp::vc - Virtual channel PDU headers
  • rdp::capability_sets - Capability negotiation structures

Graphics & Input

  • input - Keyboard, mouse, and synchronization events
  • input::fast_path - Fast-path input encoding
  • fast_path - Fast-path output decoding
  • bitmap - Bitmap compression and encoding
  • surface_commands - Graphics surface commands
  • pointer - Pointer (cursor) definitions
  • codecs - Image compression codecs (RFX, etc.)
  • geometry - Rectangle and region structures

Dynamic Channels

  • dvc - Dynamic Virtual Channel (DRDYNVC) PDUs

Core Types

Result & Error

PDU Detection

Example:

PDU Hints

Use hints with framing code to detect PDU boundaries.

Negotiation PDUs

X.224 Connection Request

Client Info PDU

See ironrdp-connector for higher-level connection APIs.

Graphics PDUs

Fast-Path Output

Bitmap Data

Input PDUs

Fast-Path Input

Example:
See ironrdp-input for higher-level input event builders.

Design Patterns

Plain Old Data Structures

Most PDUs are simple structs with public fields:
This enables:
  • Pattern matching
  • Field struct expressions
  • Functional update syntax
  • Moving individual fields

Resilient Parsing with Newtype Enums

Instead of Rust enums, protocol codes use newtype structs:
This allows:
  • Forward compatibility (unknown values are preserved)
  • Round-trip encoding (decode(encode(x)) == x)
  • Non-destructive parsing
See the README section on “Enumeration-like types” for rationale.

Bit Flags

The const _ = !0 pattern enables resilient flag parsing.

Encoding Utilities

UTF-16 Strings

Padding

Features

feature
Enables standard library support (includes alloc)
feature
Enables heap allocations
feature
Enable QOI image codec support
feature
Enable QOI + Zstd compressed image support

Usage Notes

Temporary Re-exports:
ironrdp-pdu currently re-exports ironrdp-core types for backwards compatibility:
New code should import from ironrdp_core directly.
Size Constants:
When computing PDU sizes, annotate each addend:
This makes the size calculation self-documenting.

See Also