The ironrdp-server public API uses anyhow::Result for trait signatures and method return types:
RdpServerDisplayUpdates::next_update() -> Result<Option<DisplayUpdate>>
RdpServerDisplay::updates() -> Result<Box<dyn RdpServerDisplayUpdates>>
RdpServer::run() -> Result<()>
RdpServer::run_connection() -> Result<()>
ConnectionHandler::on_disconnected(error: Option<&anyhow::Error>)
TlsIdentityCtx::init_from_paths() -> anyhow::Result<Self>
EchoServerHandle::send_request() -> Result<()>
The rest of the IronRDP library crates use typed errors via ironrdp_error::Error<Kind> (e.g. SessionError, ConnectorError). Using anyhow in the server crate means consumers can't pattern-match on error kinds, and every consumer takes an implicit dependency on the anyhow crate.
A ServerError / ServerErrorKind type following the same pattern as ironrdp-session and ironrdp-connector would bring the server crate in line with the rest of the library. Rough sketch of what that would look like:
pub type ServerError = ironrdp_error::Error<ServerErrorKind>;
pub type ServerResult<T> = Result<T, ServerError>;
#[non_exhaustive]
pub enum ServerErrorKind {
Io,
Pdu,
Encode,
Security,
Channel,
General,
Custom,
}
Files that would need changes:
- New
error.rs module with the type definitions and ServerErrorExt convenience trait
display.rs: trait signatures (next_update, updates)
server.rs: run(), run_connection(), ConnectionHandler::on_disconnected
echo.rs: send_request
helper.rs: init_from_paths, make_acceptor
builder.rs: noop trait impls (NoopDisplayUpdates, NoopDisplay)
encoder/mod.rs: internal anyhow usage could stay or migrate
- Example server (
examples/server.rs): trait impl return types
- Doc examples in
display.rs
The main complication is the consumer-implemented traits (RdpServerDisplay, RdpServerDisplayUpdates). Changing their return types is semver-breaking and requires all downstream implementors to update. The Custom variant with with_source() preserves the flexibility consumers currently get from anyhow.
Would this be welcome as a PR? Happy to do the work if so.
The
ironrdp-serverpublic API usesanyhow::Resultfor trait signatures and method return types:RdpServerDisplayUpdates::next_update() -> Result<Option<DisplayUpdate>>RdpServerDisplay::updates() -> Result<Box<dyn RdpServerDisplayUpdates>>RdpServer::run() -> Result<()>RdpServer::run_connection() -> Result<()>ConnectionHandler::on_disconnected(error: Option<&anyhow::Error>)TlsIdentityCtx::init_from_paths() -> anyhow::Result<Self>EchoServerHandle::send_request() -> Result<()>The rest of the IronRDP library crates use typed errors via
ironrdp_error::Error<Kind>(e.g.SessionError,ConnectorError). Usinganyhowin the server crate means consumers can't pattern-match on error kinds, and every consumer takes an implicit dependency on the anyhow crate.A
ServerError/ServerErrorKindtype following the same pattern asironrdp-sessionandironrdp-connectorwould bring the server crate in line with the rest of the library. Rough sketch of what that would look like:Files that would need changes:
error.rsmodule with the type definitions andServerErrorExtconvenience traitdisplay.rs: trait signatures (next_update,updates)server.rs:run(),run_connection(),ConnectionHandler::on_disconnectedecho.rs:send_requesthelper.rs:init_from_paths,make_acceptorbuilder.rs: noop trait impls (NoopDisplayUpdates,NoopDisplay)encoder/mod.rs: internal anyhow usage could stay or migrateexamples/server.rs): trait impl return typesdisplay.rsThe main complication is the consumer-implemented traits (
RdpServerDisplay,RdpServerDisplayUpdates). Changing their return types is semver-breaking and requires all downstream implementors to update. TheCustomvariant withwith_source()preserves the flexibility consumers currently get from anyhow.Would this be welcome as a PR? Happy to do the work if so.