Skip to content

Commit 3299db4

Browse files
committed
feat(client): gate native backends behind Cargo features and add ConfigBuilder
Cargo features * `default = []`; consumers now opt into exactly what they need. * New matrix: `sound`, `clipboard`, `rdpdr`, `smartcard`, `gateway`, `qoi`, `qoiz`, `dvc-pipe-proxy`, `dvc-com-plugin`, plus the existing `rustls` / `native-tls` selection. * `ironrdp-rdpsnd-native`, `ironrdp-cliprdr-native`, `ironrdp-mstsgu`, `reqwest`, `ironrdp-dvc-pipe-proxy`, and `ironrdp-dvc-com-plugin` become optional and are only pulled in by the matching feature. * Native backend instantiation (cpal RDPSND, native clipboard, NoopRdpdrBackend, Windows COM DVC plugin, gateway/WS transport) moves into the library behind those `cfg`s, with `with_<feature>_backend(custom)` escape hatches. Public API * Introduce `Config` + `ConfigBuilder` with typed fields and per-feature runtime toggles (`with_sound(bool)`, `with_clipboard(bool)`, ...). Setters always compile and are documented no-ops when the matching Cargo feature is disabled, so generic embedders don't need to sprinkle `cfg!`. * Drop `PartialConfig` from the library's public surface; `.rdp` / `PropertySet` / clap / inquire parsing now lives entirely in the viewer and produces a `Config` directly.
1 parent d5b3fa7 commit 3299db4

8 files changed

Lines changed: 1176 additions & 723 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ironrdp-client/Cargo.toml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,41 @@ doctest = false
1919
test = false
2020

2121
[features]
22-
default = ["rustls"]
23-
rustls = ["ironrdp-tls/rustls", "tokio-tungstenite/rustls-tls-native-roots", "ironrdp-mstsgu/rustls"]
24-
native-tls = ["ironrdp-tls/native-tls", "tokio-tungstenite/native-tls", "ironrdp-mstsgu/native-tls"]
22+
# No defaults. Each consumer enables exactly what it needs.
23+
#
24+
# Two-layer opt-out model:
25+
# * Cargo features (this section) drop the dependency, native backend,
26+
# and channel-construction code from the compiled artifact.
27+
# * `ConfigBuilder::with_<feature>(bool)` runtime gates exist
28+
# unconditionally; setting `true` for a feature that is not compiled
29+
# in is a documented no-op.
30+
#
31+
# TLS backends (`rustls` vs `native-tls`) are mutually exclusive at link
32+
# time and have no runtime gate.
33+
default = []
34+
35+
rustls = [
36+
"ironrdp-tls/rustls",
37+
"tokio-tungstenite/rustls-tls-native-roots",
38+
"ironrdp-mstsgu?/rustls",
39+
]
40+
native-tls = [
41+
"ironrdp-tls/native-tls",
42+
"tokio-tungstenite/native-tls",
43+
"ironrdp-mstsgu?/native-tls",
44+
]
45+
46+
sound = ["ironrdp/rdpsnd", "dep:ironrdp-rdpsnd-native"]
47+
clipboard = ["ironrdp/cliprdr"]
48+
rdpdr = ["ironrdp/rdpdr"]
49+
smartcard = ["rdpdr"]
50+
gateway = ["dep:ironrdp-mstsgu", "ironrdp-tokio/reqwest"]
2551
qoi = ["ironrdp/qoi"]
2652
qoiz = ["ironrdp/qoiz"]
53+
dvc-pipe-proxy = ["dep:ironrdp-dvc-pipe-proxy"]
54+
# `dvc-com-plugin` is also `cfg(windows)`; enabling it on a non-Windows
55+
# target compiles cleanly but contributes no code.
56+
dvc-com-plugin = []
2757

2858
[dependencies]
2959
# Protocols
@@ -33,20 +63,26 @@ ironrdp = { path = "../ironrdp", version = "0.14", features = [
3363
"graphics",
3464
"dvc",
3565
"svc",
36-
"rdpdr",
37-
"rdpsnd",
38-
"cliprdr",
3966
"displaycontrol",
4067
"connector",
4168
"echo",
4269
] }
4370
ironrdp-core = { path = "../ironrdp-core", version = "0.1", features = ["alloc"] }
44-
ironrdp-rdpsnd-native = { path = "../ironrdp-rdpsnd-native", version = "0.5" }
4571
ironrdp-tls = { path = "../ironrdp-tls", version = "0.2" }
46-
ironrdp-mstsgu = { path = "../ironrdp-mstsgu" }
47-
ironrdp-tokio = { path = "../ironrdp-tokio", version = "0.8", features = ["reqwest"] }
72+
ironrdp-tokio = { path = "../ironrdp-tokio", version = "0.8" }
4873
ironrdp-rdcleanpath.path = "../ironrdp-rdcleanpath"
49-
ironrdp-dvc-pipe-proxy.path = "../ironrdp-dvc-pipe-proxy"
74+
ironrdp-propertyset = { path = "../ironrdp-propertyset" }
75+
ironrdp-cfg = { path = "../ironrdp-cfg" }
76+
77+
# Optional protocol/native backend crates.
78+
ironrdp-rdpsnd-native = { path = "../ironrdp-rdpsnd-native", version = "0.5", optional = true }
79+
ironrdp-mstsgu = { path = "../ironrdp-mstsgu", optional = true }
80+
ironrdp-dvc-pipe-proxy = { path = "../ironrdp-dvc-pipe-proxy", optional = true }
81+
82+
# `reqwest` is only pulled in via `ironrdp-tokio/reqwest` (enabled by the
83+
# `gateway` feature). When the `gateway` feature is disabled, the library
84+
# uses an internal stub network client (KDC proxy over HTTP is unavailable
85+
# in that configuration).
5086

5187
# Logging
5288
tracing = { version = "0.1", features = ["log"] }
@@ -62,9 +98,13 @@ futures-util = { version = "0.3", features = ["sink"] }
6298
anyhow = "1"
6399
smallvec = "1.15"
64100
url = "2"
101+
whoami = "2.1"
65102
x509-cert = { version = "0.2", default-features = false, features = ["std"] }
66103

67104
[target.'cfg(windows)'.dependencies]
105+
# `ironrdp-dvc-com-plugin` is intentionally not marked `optional`: cargo does
106+
# not allow `dep:` references to target-specific optional deps. The `dvc-com-plugin`
107+
# Cargo feature gates the code paths only; on Windows the crate is always linked.
68108
ironrdp-dvc-com-plugin = { path = "../ironrdp-dvc-com-plugin" }
69109

70110
[lints]

0 commit comments

Comments
 (0)