Commit 92ebf1e
committed
feat(egfx): cascade Arbitrary derives across ironrdp-egfx public PDU types
Extends the Arbitrary cascade from PR Devolutions#1272 (ironrdp-pdu) and PR Devolutions#1284
(extension to pdu types in ironrdp-pdu's egfx-related modules) to the
ironrdp-egfx crate's own public type surface.
Adds the arbitrary feature to ironrdp-egfx and adds the standard
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] gate
to every public PDU type in crates/ironrdp-egfx/src/pdu/:
- common.rs: Point, Color, PixelFormat
- avc.rs: Avc420BitmapStream, Avc444BitmapStream, Avc420Region
- cmd.rs: GfxPdu plus all 23 variant types, RawCapabilitySet,
CapabilitySet, CapabilityVersion, Codec1Type, Codec2Type, QueueDepth,
CacheEntryMetadata, and the six CapabilitiesV*Flags bitflags structs.
Three types use a manual Arbitrary impl rather than the derive because
their fields have implicit wire-bit-width constraints the derive cannot
express. derive(Arbitrary) on these types generates values in the full
underlying type range, which the encoder then panics on when packing
into the narrower wire range. Manual impls mask each field to its
spec-defined width:
- Timestamp (cmd.rs): milliseconds and hours into 10 bits each,
seconds and minutes into 6 bits each. The encoder packs all four
into a single u32 via set_bits.
- QuantQuality (avc.rs): quantization_parameter into 6 bits. Encoder
packs into a u8 via set_bits(0..6).
- Encoding bitflag (avc.rs): masked to 2 bits. The bitflag's
`const _ = !0` clause otherwise accepts any u8 value, but the
encoder for Avc444BitmapStream packs encoding.bits() into bits
30..32 of the stream-info field.
The arbitrary feature cascades through ironrdp-pdu/arbitrary so types
in egfx's variant payloads (ExclusiveRectangle, etc.) pick up their
existing Arbitrary impls. bitflags/arbitrary is activated so the
CapabilitiesV*Flags bitflag types get Arbitrary via the bitflags
crate's own derive support.
Adds the ironrdp-egfx/arbitrary case to the xtask feature matrix
(xtask/src/features.rs), mirroring the ironrdp-pdu/arbitrary entry,
so CI verifies the feature builds cleanly.
Default build (no arbitrary feature) is unchanged. Existing tests
pass. cargo xtask check features --case ironrdp-egfx/arbitrary clean.
This is the prerequisite cascade for the egfx_multi_frame fuzz target
(target 5 under Devolutions#1316), which will use Arbitrary-derived Vec<GfxPdu>
to drive a single decoder + surface-cache pair across each fuzz
iteration. The target itself follows in a separate PR. Per the Devolutions#1122
guidance ("either implement Arbitrary manually and reject invalid
values, or generate a raw value and then sanitize it"), the three
manual impls here follow the sanitize-via-mask shape so generated
values always round-trip through Encode.
Refs Devolutions#1316.1 parent 059ca90 commit 92ebf1e
6 files changed
Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
18 | 33 | | |
19 | 34 | | |
20 | 35 | | |
| |||
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
| 76 | + | |
61 | 77 | | |
62 | 78 | | |
63 | 79 | | |
| |||
152 | 168 | | |
153 | 169 | | |
154 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
155 | 184 | | |
156 | 185 | | |
157 | 186 | | |
| |||
263 | 292 | | |
264 | 293 | | |
265 | 294 | | |
| 295 | + | |
266 | 296 | | |
267 | 297 | | |
268 | 298 | | |
| |||
0 commit comments