ironrdp-error
A lightweight,no_std-compatible generic error type used throughout the IronRDP project.
Overview
Theironrdp-error crate provides a flexible Error<Kind> type that combines a static context string with a user-defined error kind enum. It supports optional error chaining through source errors and works in no_std environments with or without allocation.
Source: crates/ironrdp-error/
Features
- Generic Error Kind: Parameterized by user-defined error kind enums
- Static Context: Zero-allocation context strings using
&'static str - Source Chaining: Optional error source tracking (requires
allocfeature) no_stdSupport: Works in embedded and bare-metal environments- Conversion Support: Convert between different error kinds
Feature Flags
| Feature | Default | Description |
|---|---|---|
std | Yes | Enable standard library support and std::error::Error trait |
alloc | Enabled by std | Enable allocations for error sources (requires alloc crate) |
API Reference
Error<Kind>
Generic error type combining context and kind.Construction
Methods
ErrorReport
Wrapper for formatted error output including full source chain.ErrorReport type implements Display and formats the error with all causes in the chain.
Error Source Trait
Source Trait
Abstraction over error sources that works in bothstd and no_std environments.
Source.
Usage Examples
Basic Error Handling
Error Chaining
Converting Error Kinds
no_std Usage
Integration with IronRDP
Throughout IronRDP, crates define their own error kind enums and useironrdp_error::Error as the error type:
IronRDP Connector Errors
IronRDP Session Errors
IronRDP PDU Errors
Context Best Practices
Context strings should:- Be lowercase snake_case or function names
- Describe the operation that failed
- Be static strings (zero allocation)
- Be concise (used as a prefix)
"connect""send_request""decode_packet""establish_channel"
- Complete sentences
- Duplicating error kind information
- Dynamic strings
Display Format
The error displays as[context] kind:
Conversion to std::io::Error
When the std feature is enabled, Error<Kind> can be converted to std::io::Error:
Dependencies
- core: Rust core library (always available)
- alloc: Allocation support (optional, for error sources in
no_std)
Related Crates
All IronRDP crates useironrdp-error for error handling:
ironrdp-core: Core encoding/decoding errorsironrdp-pdu: PDU parsing errorsironrdp-connector: Connection establishment errorsironrdp-session: Session management errorsironrdp-svc: Static virtual channel errorsironrdp-dvc: Dynamic virtual channel errors
Design Rationale
Why Generic Error Kind?
Rather than a single global error enum,Error<Kind> allows each crate to define its own error taxonomy while sharing the error infrastructure (context, sources, reporting).
Why Static Context?
Static context strings have zero runtime cost and don’t require allocations, making them suitable for performance-critical andno_std code paths.

